DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ASSIGNMENT_API

Source


1 Package Body hr_assignment_api as
2 /* $Header: peasgapi.pkb 120.37.12020000.11 2013/02/28 09:37:22 lbodired 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     l_group_name1    varchar2(2000); --added for bug#7601790
69     --
70   begin
71     if g_debug then
72     hr_utility.set_location('Entering:'|| l_proc, 10);
73     end if;
74     --
75     -- The outer procedure has already establish that an update is
76     -- required. This sub-procedure uses an autonomous transaction
77     -- to ensure that any commits do not impact the main transaction.
78     -- If the row is successfully locked then continue and update the
79     -- row. If the row cannot be locked then another transaction must
80     -- be performing the update. So it is acceptable for this
81     -- transaction to silently trap the error and continue.
82     --
83     -- Note: It is necessary to perform the lock test because in
84     -- a batch data upload scenario multiple sessions could be
85     -- attempting to insert or update the same Key Flexfield
86     -- combination at the same time. Just directly updating the row,
87     -- without first locking, can cause sessions to hang and reduce
88     -- batch throughput.
89     --
90     open csr_pgp_lock;
91     fetch csr_pgp_lock into l_exists;
92     if csr_pgp_lock%found then
93       close csr_pgp_lock;
94 
95       if g_debug then
96       hr_utility.set_location(l_proc, 20);
97       end if;
98 
99       --
100       -- Bug#7601790
101       -- Added the code to check whether p_group_name is greater
102       -- than 240 characters. If yes, only first 240 characters
103       -- are updated into the table pay_people_groups
104       --
105       -- fix for Bug#7601790 starts
106 
107       l_group_name1:=p_group_name;
108       if length(p_group_name) > 240 then
109          l_group_name1:=substr(p_group_name,1,240);
110       end if;
111 
112       -- fix for Bug#7601790 ends
113       --
114       -- Lock obtained by this transaction, updating the concatenated
115       -- segment string should be performed.
116       --
117       update pay_people_groups
118          --set group_name      = p_group_name  fix for Bug#7601790
119          set group_name      = l_group_name1
120        where people_group_id = p_people_group_id
121          and (group_name     <> p_group_name
122           or group_name is null);
123       --
124       -- Commit this change so the change is immediately visible to
125       -- other transactions. Also ensuring that it is not undone if
126       -- the main transaction is rolled back. This commit is only
127       -- acceptable inside an API because it is being performed inside
128       -- an autonomous transaction and AOL code has previously
129       -- inserted the Key Flexfield combination row in another
130       -- autonomous transaction.
131       commit;
132     else
133       close csr_pgp_lock;
134       rollback; -- Added for bug 3578845.
135     end if;
136     --
137     if g_debug then
138     hr_utility.set_location('Leaving:'|| l_proc, 30);
139     end if;
140 
141   Exception
142     When HR_Api.Object_Locked then
143       --
144       -- This autonomous transaction was unable to lock the row.
145       -- It can be assumed that another transaction has locked the
146       -- row and is performing the update. Hence the error can
147       -- be suppressed without raising it to the end user.
148       --
149       rollback; -- Added for bug 3578845.
150       hr_utility.set_location('Leaving:'|| l_proc, 40);
151   end update_pgp_concat_segs_auto;
152 begin
153 --
154   if g_debug then
155   hr_utility.set_location('Entering:'|| l_proc, 10);
156   end if;
157   --
158   -- First find out if it is necessary to update the concatenated
159   -- segment string column. This select is being done to avoid the
160   -- performance unnecessary overhead of set-up an autonomous
161   -- transaction when an update is not required. Updates are only
162   -- expected immediately after the combination row was first inserted.
163   --
164   open csr_chk_pgp;
165   fetch csr_chk_pgp into l_exists;
166   if csr_chk_pgp%found then
167     close csr_chk_pgp;
168     update_pgp_concat_segs_auto
169       (p_people_group_id => p_people_group_id
170       ,p_group_name      => p_group_name
171       );
172   else
173     close csr_chk_pgp;
174   end if;
175   --
176  if g_debug then
177   hr_utility.set_location('Leaving:'|| l_proc, 20);
178  end if;
179   --
180 end update_pgp_concat_segs;
181 --
182 -- ER FPT
183 PROCEDURE reverse_term_apln_fut ( p_effective_date date ,p_business_group_id number ,
184                                p_assignment_id number, p_person_id number,
185 			       p_status_change_reason   in  varchar2 default null
186 			       ,p_return_status out nocopy varchar2) is
187 -- declare all cursors and variables
188 l_proc               varchar2(72);
189 l_date_end          date;
190 l_asg_end_date      date;
191 l_cost_warning      boolean;
192 l_assignment_status_id number;
193 l_date_recieved date;
194 l_eot date := hr_api.g_eot;
195 l_ass_status varchar2(20);
196 l_dummy varchar2(10);
197 l_asg_status_id  number;
198 l_object_version_number number;
199 l_application_id number;
200 l_asg_start_date date;
201 l_ovn number;
202 
203 l_validation_start_date  date;
204 l_validation_end_date date;
205 
206 
207 cursor c1 is
208 select date_end ,date_received, application_id
209 from per_applications papp
210 where application_id =
211            ( select distinct (application_id)
212          from per_all_assignments_f
213             where assignment_id = p_assignment_id and
214                 business_group_id = p_business_group_id )
215 for update nowait;
216 
217 cursor c2 is
218   select 1
219   from per_all_assignments_f a
220   where assignment_id = p_assignment_id
221   and exists
222        (select null
223         from   per_assignment_status_types b
224         where  b.per_system_status in ('TERM_APL','ACTIVE_ASSIGN')
225         and    a.assignment_status_type_id = b.assignment_status_type_id) ;
226 
227 -- ER FPT
228 cursor c3(p_date_end date) is
229   SELECT 1
230   FROM   PER_PERSON_TYPE_USAGES_F PTU, PER_PERSON_TYPES PPT
231   WHERE  PTU.PERSON_ID = P_PERSON_ID
232   AND    PTU.EFFECTIVE_START_DATE > p_DATE_END
233   AND    PTU.PERSON_TYPE_ID = PPT.PERSON_TYPE_ID
234   AND    PPT.SYSTEM_PERSON_TYPE IN ('EMP','CWK');
235 
236 cursor csr_ptu_row (p_date_received in date ) is
237 select ptu.person_type_usage_id,
238        ptu.effective_start_date
239 from   per_person_type_usages_f ptu
240       ,per_person_types ppt
241 where  ptu.person_id = p_person_id
242 and    ptu.effective_start_date > p_date_received
243 and    ptu.person_type_id = ppt.person_type_id
244 and    ppt.system_person_type = 'EX_APL'
245 order by ptu.effective_start_date;
246 
247 --start changes for bug 7217475
248 
249 cursor csr_chk_bg_exists is
250  select 1
251  from per_business_groups
252  where business_group_id = p_business_group_id;
253 
254 cursor csr_chk_person_exists is
255  select 1
256  from per_all_people_f
257  where business_group_id = p_business_group_id
258   and person_id = p_person_id
259   and p_effective_date between effective_start_date and effective_end_date;
260 
261 cursor csr_chk_asg_exists is
262  select 1
263  from per_all_assignments_f
264  where business_group_id = p_business_group_id
265   and person_id = p_person_id
266   and assignment_id = p_assignment_id;
267   --and p_effective_date between effective_start_date and effective_end_date;
268   -- Commented above condition for Bug#9049586
269 
270 l_bg_exists number;
271 l_person_exists number;
272 l_asg_exists number;
273 
274 --end changes for bug 7217475
275 
276 -- end of declaration
277 
278 cursor future_apl(p_date_received date) is
279 select rowid, application_id,date_received from per_applications
280 where date_received > p_date_received
281 and   person_id = p_person_id;
282 
283   l_apl_person_type_id number;
284   l_max_ptu_end_date date;
285   cursor get_max_end_date(p_date_received date) is
286   select nvl(max(effective_end_date),hr_api.g_eot)
287   from  per_person_type_usages_f ptu, per_person_types ppt
288   where ptu.person_type_id = ppt.person_type_id
289   and   ppt.system_person_type = 'APL'
290   and   ptu.effective_start_date > p_date_received;
291 
292 begin
293 --            l_proc := 'reverse_term_apln_fut';
294  p_return_status:='S';
295 
296  --start changes for bug 7217475
297  --
298  -- hr_multi_message.enable_message_list;
299  hr_utility.set_location('Entering:'|| l_proc, 10);
300 
301  --
302  open csr_chk_bg_exists;
303  fetch csr_chk_bg_exists into l_bg_exists;
304  if csr_chk_bg_exists%notfound then
305   hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
306   hr_utility.raise_error;
307  end if;
308  close csr_chk_bg_exists;
309  --
310  hr_utility.set_location('reverse_term_apln_fut - p_business_group_id:'|| p_business_group_id, 10);
311 
312  --
313  open csr_chk_person_exists;
314  fetch csr_chk_person_exists into l_person_exists;
315  if csr_chk_person_exists%notfound then
316   hr_utility.set_message(800,'HR_52786_SUC_CHK_PERSON_EXISTS');
317   hr_utility.raise_error;
318  end if;
319  close csr_chk_person_exists;
320  --
321  hr_utility.set_location('reverse_term_apln_fut - p_person_id:'|| p_person_id, 10);
322 
323  --
324  open csr_chk_asg_exists;
325  fetch csr_chk_asg_exists into l_asg_exists;
326  if csr_chk_asg_exists%notfound then
327     hr_utility.set_message(801,'HR_52360_ASG_DOES_NOT_EXIST');
328     hr_utility.raise_error;
329  end if;
330  close csr_chk_asg_exists;
331  --
332 
333  hr_utility.set_location('reverse_term_apln_fut - p_assignment_id:'|| p_assignment_id, 10);
334 
335  --
336  if p_status_change_reason is not null then
337   if hr_api.not_exists_in_dt_hr_lookups
338    (p_effective_date        => p_effective_date
339     ,p_validation_start_date => p_effective_date
340     ,p_validation_end_date   => p_effective_date
341     ,p_lookup_type           => 'APL_ASSIGN_REASON'
342     ,p_lookup_code           =>  p_status_change_reason
343     )
344   then
345    hr_utility.set_message(801, 'HR_51229_ASG_INV_AASG_CH_REAS');
346    hr_utility.raise_error;
347   end if;
348  end if;
349  --
350 
351  hr_multi_message.enable_message_list;
352  --end changes for bug 7217475
353 
354  -- check whether the Person is an Applicant or an Ex-applicant
355  open c1;
356  fetch c1 into l_date_end ,l_date_recieved, l_application_id;
357  --close c1;
358  --
359 
360 
361 --  hr_multi_message.enable_message_list;
362 
363 
364   --fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
365   --fnd_message.raise_error ;
366   --  hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
367   --  hr_utility.raise_error ;
368   --fnd_message.set_token('ATTRIBUTE_NAME','ERROR');
369   -- hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
370    --                      , p_message_type  => hr_multi_message.g_error_msg);
371 
372 
373 
374  hr_utility.set_location('reverse_term_apln_fut - p_effective_date:'|| p_effective_date, 10);
375  hr_utility.set_location('reverse_term_apln_fut - l_date_end:'|| l_date_end, 10);
376 
377 
378  select effective_start_date, effective_end_date,object_version_number into l_asg_start_date,l_asg_end_date,l_ovn
379  from per_all_assignments_f
380  where assignment_id = p_assignment_id
381  and effective_end_date = (select max(effective_end_date)
382  from per_all_assignments_f
383  where assignment_id = p_assignment_id );
384 
385  hr_utility.set_location('reverse_term_apln_fut - l_asg_end_date:'|| l_asg_end_date, 20);
386 
387    select assignment_status_type_id into l_assignment_status_id
388    from per_all_assignments_f
389    where assignment_id = p_assignment_id
390    and effective_end_date = l_asg_end_date ;
391 
392  hr_utility.set_location('reverse_term_apln_fut - l_assignment_status_id:'|| l_assignment_status_id, 30);
393 
394 if l_date_end is null then
395   --  then the person is currently an Applicant with any flavour of persontype
396    hr_utility.set_location('reverse_term_apln_fut - Entering:'|| l_proc, 40);
397  open c2;
398  fetch c2 into l_dummy;
399  if c2%found then
400     close c2 ;
401     fnd_message.set_name ( 'PAY', 'HR_6083_APP_ASS_APPL_STAT_END' );
402     app_exception.raise_exception ;
403  end if;
404  close c2;
405 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
406 --to be in sync with the  assignments data
407 
408  hr_utility.set_location('Entering:'|| l_proc, 50);
409  hr_assignment.tidy_up_ref_int ( p_assignment_id,
410                                  'FUTURE',
411                                   null,
412                                   l_asg_end_date,
413                                   null,
414                                   null,
415                                  l_cost_warning ) ;
416 -- clean up the letter requests.
417  per_app_asg_pkg.cleanup_letters
418    (p_assignment_id => p_assignment_id);
419     hr_utility.set_location('Entering:'|| l_proc, 60);
420 
421 -- calling the IRC packages to maintain the IRC Assignment Statuses
422 
423 
424        IRC_ASG_STATUS_API.create_irc_asg_status
425            ( p_validate                   => FALSE
426            , p_assignment_id              => p_assignment_id
427             , p_assignment_status_type_id  => l_assignment_status_id
428            , p_status_change_date         =>  p_effective_date
429            , p_assignment_status_id       => l_asg_status_id
430            , p_object_version_number      => l_object_version_number
431 	   ,p_status_change_reason         => p_status_change_reason
432             );
433 
434 -- now update the assignments table
435 -- we must lock the row before we update it
436 
437 per_asg_shd.lck (p_effective_date =>l_asg_end_date ,
438      p_datetrack_mode => 'CORRECTION',
439      p_assignment_id  =>p_assignment_id,
440      p_object_version_number =>l_ovn,
441      p_validation_start_date =>l_validation_start_date,
442      p_validation_end_date => l_validation_end_date);
443 
444 
445  hr_utility.set_location('Entering:'|| l_proc, 70);
446 
447    update per_all_assignments_f
448    set effective_end_date =  l_eot
449    where assignment_id = p_assignment_id
450       and person_id=p_person_id
451       and business_group_id= p_business_group_id
452       and effective_end_date = l_asg_end_date;
453 
454 hr_utility.set_location(' Leaving : '||l_proc  ,80);
455 
456 
457  else  --  CASE  2
458 
459  hr_utility.set_location('Entering:'|| l_proc, 90);
460 
461  -- Person is currently an Ex-Applicant with any falvour of Person Type
462 -- Check if the person is currently hired as Emp with that Assignment if so raise an error
463 
464 PER_APPLICATIONS_PKG .cancel_chk_current_emp(p_person_id  => p_person_id ,
465                                              p_business_group_id => p_business_group_id ,
466                                               p_date_end          => l_date_end );
467 
468  hr_utility.set_location('Entering:'|| l_proc, 100);
469 
470  --Check for Future Person type changes
471  -- throw error when EMP or CWK person type is found in the future
472 
473  open c3(l_date_end) ;
474  fetch c3 into l_dummy ;
475  if c3%found then
476     close c3 ;
477  hr_utility.set_location('Entering:'|| l_proc, 105);
478     fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
479     hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
480     hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
481                          , p_message_type  => hr_multi_message.g_error_msg);
482 
483     hr_utility.raise_error ;
484  end if;
485  close c3 ;
486 
487   hr_utility.set_location('Entering:'|| l_proc, 110);
488 
489 -- Maintain the Person data by deleting the Ex-Appl Record and the same with PTU Data.
490 
491   DELETE FROM per_all_people_f papf
492    WHERE       papf.person_id               = p_person_id
493    AND         papf.business_group_id + 0   = p_Business_group_id
494    AND         papf.effective_start_date    > l_date_end;
495 --
496 
497  hr_utility.set_location('reverse_term_apln_fut - l_date_end:'|| l_date_end, 120);
498 
499     UPDATE  per_all_people_f papf
500     SET     papf.effective_end_date  = l_eot
501     WHERE   papf.person_id           = p_person_id
502     AND     papf.BUSINESS_GROUP_ID + 0  = p_Business_group_id
503     AND     papf.effective_end_date  = l_date_end;
504 
505      hr_utility.set_location('Entering:'|| l_proc, 130);
506 
507   hr_utility.set_location('reverse_term_apln_fut - l_date_recieved:'|| l_date_recieved, 140);
508     hr_utility.set_location('reverse_term_apln_fut - l_application_id:'|| l_application_id, 140);
509 
510 
511   for ex_apl_rec in csr_ptu_row (l_date_recieved)
512   loop
513 
514   hr_per_type_usage_internal.cancel_person_type_usage
515      (
516         p_effective_date         => ex_apl_rec.effective_start_date
517        ,p_person_id              => p_person_id
518        ,p_system_person_type     => 'EX_APL'
519      );
520 
521  end loop;
522 
523   l_apl_person_type_id := hr_person_type_usage_info.get_default_person_type_id (p_business_group_id,'APL');
524 
525   -- merging PTU APL data
526   open  get_max_end_date(l_date_recieved);
527   fetch get_max_end_date into l_max_ptu_end_date;
528   close get_max_end_date;
529 
530   update per_person_type_usages_f
531   set    effective_end_date = l_max_ptu_end_date
532   where  l_date_recieved between effective_start_date and effective_end_date
533   and    person_type_id = l_apl_person_type_id;
534 
535   hr_utility.set_location('At reverse_term_apln_fut',150);
536 
537   delete from per_person_type_usages_f
538   where  effective_start_date > l_date_recieved
539   and    person_type_id = l_apl_person_type_id;
540   -- merging PTU APL data
541 
542        hr_utility.set_location('Entering:'|| l_proc, 160);
543        hr_utility.set_location('At reverse_term_apln_fut',160);
544 
545 -- 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);
546 
547 irc_asg_status_api.create_irc_asg_status
548                 (p_validate                => FALSE,
549                  p_assignment_id              => p_assignment_id,
550                  p_assignment_status_type_id  => l_assignment_status_id,
551                  p_status_change_date         => p_effective_date,
552                  p_assignment_status_id       => l_asg_status_id,
553                  p_object_version_number      => l_object_version_number,
554 		 p_status_change_reason         => p_status_change_reason);
555 
556 hr_utility.set_location('Entering:'|| l_proc, 170);
557 hr_utility.set_location('At reverse_term_apln_fut',170);
558 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
559 --to be in sync with the  assignments data
560 
561  hr_assignment.tidy_up_ref_int ( p_assignment_id,
562                                  'FUTURE',
563                                   null,
564                                   l_asg_end_date,
565                                   null,
566                                   null,
567                                  l_cost_warning ) ;
568 -- clean up the letter requests.
569 hr_utility.set_location('Entering:'|| l_proc, 180);
570 hr_utility.set_location('At reverse_term_apln_fut',180);
571 
572  per_app_asg_pkg.cleanup_letters
573    (p_assignment_id => p_assignment_id);
574 
575     UPDATE PER_APPLICATIONS
576     SET date_end =null
577     where APPLICATION_ID =l_application_id
578     and person_id= p_person_id ;
579 
580 	 hr_utility.set_location('AT REV TERM APL FUTURE',183);
581 
582 	-- update the future asgs with the application ID
583 	for apl in future_apl(l_date_recieved)
584 	loop
585 
586 		update per_all_assignments_f
587 		set application_id = l_application_id
588 		where person_id = p_person_id
589         and application_id =apl.application_id
590 		and effective_start_date >= apl.date_received
591 		and assignment_type = 'A';
592 
593  hr_utility.set_location('AT REV TERM APL FUTURE',185);
594 
595     per_applications_pkg.delete_row(apl.rowid);
596 
597  end loop;
598 
599 hr_utility.set_location('At reverse_term_apln_fut',188);
600 
601 -- now update the assignments table
602 
603    update per_all_assignments_f
604    set effective_end_date =  l_eot
605    where assignment_id = p_assignment_id
606    and person_id=p_person_id
607    and business_group_id= p_business_group_id
608    and effective_end_date = l_asg_end_date;
609 
610    hr_utility.set_location('Entering:'|| l_proc, 190);
611 end if;
612 close c1;
613 p_return_status := hr_multi_message.get_return_status_disable;
614 EXCEPTION
615 
616 when hr_multi_message.error_message_exist then
617 
618     p_return_status:='E';
619     hr_utility.set_location(' Leaving:' || l_proc, 30);
620 when others then
621   if c1%isopen then
622    close c1;
623   end if;
624   p_return_status:='E';
625   hr_utility.set_location('Entering:'|| l_proc, 200);
626   raise; --uncommented for bug 7217475
627 end;
628 -- ER FPT
629 
630 -- Start of fix for bug 6008188
631 ----------------------------------------------------------------------------
632 -- |----------------------< reverse_term_apln >------------------------|
633 ----------------------------------------------------------------------------
634 -- {Start Of Comments}
635 --
636 
637 -- Description:
638 --   This procedure is used to reverse the termination of an applicant at
639 -- application level.
640 --
641 -- Prerequisites:
642 --   data must exists in the table per_all_assignments_f for an Person
643 --
644 -- In Parameters:
645 --   Name                           Reqd Type     Description
646 --  p_effective_date			yes        Effective date
647 --  p_business_group_id			yes        Business Group id
648 --  p_assignment_id			yes	   Assignment id
649 --   p_person_id			yes	   Person id of the person
650 -- p_status_change_reason               No         Reason for reverse termination .
651 --
652 -- Post Success:
653 --   The row is updated
654 --
655 -- Post Failure:
656 --   The procedure will raise an error.
657 --
658 -- Access Status:
659 --   Internal use only.
660 --
661 -- {End Of Comments}
662 
663 PROCEDURE reverse_term_apln ( p_effective_date date ,p_business_group_id number ,
664                                p_assignment_id number, p_person_id number,
665 			       p_status_change_reason   in  varchar2 default null
666 			       ,p_return_status out nocopy varchar2) is
667 -- declare all cursors and variables
668 l_proc               varchar2(72);
669 l_date_end          date;
670 l_asg_end_date      date;
671 l_cost_warning      boolean;
672 l_assignment_status_id number;
673 l_date_recieved date;
674 l_eot date := hr_api.g_eot;
675 l_ass_status varchar2(20);
676 l_dummy varchar2(10);
677 l_asg_status_id  number;
678 l_object_version_number number;
679 l_ptu_date_end date;
680 l_application_id number;
681 l_asg_start_date date;
682 l_ovn number;
683 
684 l_validation_start_date  date;
685 l_validation_end_date date;
686 
687 
688 cursor c1 is
689 select date_end ,date_received, application_id
690 from per_applications papp
691 where application_id =
692            ( select distinct (application_id)
693          from per_all_assignments_f
694             where assignment_id = p_assignment_id and
695                 business_group_id = p_business_group_id )
696 for update nowait;
697 
698 cursor c2 is
699   select 1
700   from per_all_assignments_f a
701   where assignment_id = p_assignment_id
702   and exists
703        (select null
704         from   per_assignment_status_types b
705         where  b.per_system_status in ('TERM_APL','ACTIVE_ASSIGN')
706         and    a.assignment_status_type_id = b.assignment_status_type_id) ;
707 
708 cursor c3(p_date_end date) is
709   SELECT 1
710   FROM   PER_ALL_PEOPLE_F PAPF
711   WHERE  PAPF.PERSON_ID = P_PERSON_ID
712   AND    PAPF.EFFECTIVE_START_DATE > p_DATE_END + 1 ;
713 
714 
715 cursor csr_ptu_row (p_date_received in date ) is
716 select   ptu.effective_start_date
717 from  per_person_type_usages_f ptu
718       ,per_person_types ppt
719 where    ptu.person_id = p_person_id
720 and   ptu.effective_start_date > p_date_received
721 and   ptu.person_type_id = ppt.person_type_id
722 and     ppt.system_person_type = 'EX_APL'
723 order by ptu.effective_start_date;
724 
725 --start changes for bug 7217475
726 
727 cursor csr_chk_bg_exists is
728  select 1
729  from per_business_groups
730  where business_group_id = p_business_group_id;
731 
732 cursor csr_chk_person_exists is
733  select 1
734  from per_all_people_f
735  where business_group_id = p_business_group_id
736   and person_id = p_person_id
737   and p_effective_date between effective_start_date and effective_end_date;
738 
739 cursor csr_chk_asg_exists is
740  select 1
741  from per_all_assignments_f
742  where business_group_id = p_business_group_id
743   and person_id = p_person_id
744   and assignment_id = p_assignment_id;
745   --and p_effective_date between effective_start_date and effective_end_date;
746   -- Commented above condition for Bug#9049586
747 
748 l_bg_exists number;
749 l_person_exists number;
750 l_asg_exists number;
751 
752 --end changes for bug 7217475
753 
754 -- end of declaration
755 
756 begin
757 --            l_proc := 'REVERSE_TERM_APLN';
758  p_return_status:='S';
759 
760  --start changes for bug 7217475
761  --
762  -- hr_multi_message.enable_message_list;
763  hr_utility.set_location('Entering:'|| l_proc, 10);
764 
765  --
766  open csr_chk_bg_exists;
767  fetch csr_chk_bg_exists into l_bg_exists;
768  if csr_chk_bg_exists%notfound then
769   hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
770   hr_utility.raise_error;
771  end if;
772  close csr_chk_bg_exists;
773  --
774  hr_utility.set_location('REVERSE_TERM_APLN - p_business_group_id:'|| p_business_group_id, 10);
775 
776  --
777  open csr_chk_person_exists;
778  fetch csr_chk_person_exists into l_person_exists;
779  if csr_chk_person_exists%notfound then
780   hr_utility.set_message(800,'HR_52786_SUC_CHK_PERSON_EXISTS');
781   hr_utility.raise_error;
782  end if;
783  close csr_chk_person_exists;
784  --
785  hr_utility.set_location('REVERSE_TERM_APLN - p_person_id:'|| p_person_id, 10);
786 
787  --
788  open csr_chk_asg_exists;
789  fetch csr_chk_asg_exists into l_asg_exists;
790  if csr_chk_asg_exists%notfound then
791     hr_utility.set_message(801,'HR_52360_ASG_DOES_NOT_EXIST');
792     hr_utility.raise_error;
793  end if;
794  close csr_chk_asg_exists;
795  --
796 
797  hr_utility.set_location('REVERSE_TERM_APLN - p_assignment_id:'|| p_assignment_id, 10);
798 
799  --
800  if p_status_change_reason is not null then
801   if hr_api.not_exists_in_dt_hr_lookups
802    (p_effective_date        => p_effective_date
803     ,p_validation_start_date => p_effective_date
804     ,p_validation_end_date   => p_effective_date
805     ,p_lookup_type           => 'APL_ASSIGN_REASON'
806     ,p_lookup_code           =>  p_status_change_reason
807     )
808   then
809    hr_utility.set_message(801, 'HR_51229_ASG_INV_AASG_CH_REAS');
810    hr_utility.raise_error;
811   end if;
812  end if;
813  --
814 
815  hr_multi_message.enable_message_list;
816  --end changes for bug 7217475
817 
818  -- check whether the Person is an Applicant or an Ex-applicant
819  open c1;
820  fetch c1 into l_date_end ,l_date_recieved, l_application_id;
821  --close c1;
822  --
823 
824 
825 --  hr_multi_message.enable_message_list;
826 
827 
828   --fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
829   --fnd_message.raise_error ;
830   --  hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
831   --  hr_utility.raise_error ;
832   --fnd_message.set_token('ATTRIBUTE_NAME','ERROR');
833   -- hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
834    --                      , p_message_type  => hr_multi_message.g_error_msg);
835 
836 
837 
838  hr_utility.set_location('REVERSE_TERM_APLN - p_effective_date:'|| p_effective_date, 10);
839  hr_utility.set_location('REVERSE_TERM_APLN - l_date_end:'|| l_date_end, 10);
840 
841 
842  select effective_start_date, effective_end_date,object_version_number into l_asg_start_date,l_asg_end_date,l_ovn
843  from per_all_assignments_f
844  where assignment_id = p_assignment_id
845  and effective_end_date = (select max(effective_end_date)
846  from per_all_assignments_f
847  where assignment_id = p_assignment_id );
848 
849  hr_utility.set_location('REVERSE_TERM_APLN - l_asg_end_date:'|| l_asg_end_date, 20);
850 
851    select assignment_status_type_id into l_assignment_status_id
852    from per_all_assignments_f
853    where assignment_id = p_assignment_id
854    and effective_end_date = l_asg_end_date ;
855 
856  hr_utility.set_location('REVERSE_TERM_APLN - l_assignment_status_id:'|| l_assignment_status_id, 30);
857 
858 if l_date_end is null then
859   --  then the person is currently an Applicant with any flavour of persontype
860    hr_utility.set_location('REVERSE_TERM_APLN - Entering:'|| l_proc, 40);
861  open c2;
862  fetch c2 into l_dummy;
863  if c2%found then
864     close c2 ;
865     fnd_message.set_name ( 'PAY', 'HR_6083_APP_ASS_APPL_STAT_END' );
866     app_exception.raise_exception ;
867  end if;
868  close c2;
869 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
870 --to be in sync with the  assignments data
871 
872  hr_utility.set_location('Entering:'|| l_proc, 50);
873  hr_assignment.tidy_up_ref_int ( p_assignment_id,
874                                  'FUTURE',
875                                   null,
876                                   l_asg_end_date,
877                                   null,
878                                   null,
879                                  l_cost_warning ) ;
880 -- clean up the letter requests.
881  per_app_asg_pkg.cleanup_letters
882    (p_assignment_id => p_assignment_id);
883     hr_utility.set_location('Entering:'|| l_proc, 60);
884 
885 -- calling the IRC packages to maintain the IRC Assignment Statuses
886 
887 
888        IRC_ASG_STATUS_API.create_irc_asg_status
889            ( p_validate                   => FALSE
890            , p_assignment_id              => p_assignment_id
891             , p_assignment_status_type_id  => l_assignment_status_id
892            , p_status_change_date         =>  p_effective_date
893            , p_assignment_status_id       => l_asg_status_id
894            , p_object_version_number      => l_object_version_number
895 	   ,p_status_change_reason         => p_status_change_reason
896             );
897 
898 -- now update the assignments table
899 -- we must lock the row before we update it
900 
901 per_asg_shd.lck (p_effective_date =>l_asg_end_date ,
902      p_datetrack_mode => 'CORRECTION',
903      p_assignment_id  =>p_assignment_id,
904      p_object_version_number =>l_ovn,
905      p_validation_start_date =>l_validation_start_date,
906      p_validation_end_date => l_validation_end_date);
907 
908 
909  hr_utility.set_location('Entering:'|| l_proc, 70);
910 
911    update per_all_assignments_f
912    set effective_end_date =  l_eot
913    where assignment_id = p_assignment_id
914       and person_id=p_person_id
915       and business_group_id= p_business_group_id
916       and effective_end_date = l_asg_end_date;
917 
918 hr_utility.set_location(' Leaving : '||l_proc  ,80);
919 
920 
921  else  --  CASE  2
922 
923  hr_utility.set_location('Entering:'|| l_proc, 90);
924 
925  -- Person is currently an Ex-Applicant with any falvour of Person Type
926 -- Check if the person is currently hired as Emp with that Assignment if so raise an error
927 
928 PER_APPLICATIONS_PKG .cancel_chk_current_emp(p_person_id  => p_person_id ,
929                                              p_business_group_id => p_business_group_id ,
930                                               p_date_end          => l_date_end );
931 
932  hr_utility.set_location('Entering:'|| l_proc, 100);
933 
934   --Check for Future Person type changes
935 
936   open c3(l_date_end) ;
937   fetch c3 into l_dummy ;
938   if c3%found then
939     close c3 ;
940   -- ER FPT
941 	if (nvl(fnd_profile.value('HR_ALLOW_FPT_UPDATES'),'N') = 'Y') then
942 	hr_utility.set_location('Calling reverse_term_apln_fut', 105);
943 	 reverse_term_apln_fut ( p_effective_date
944 							,p_business_group_id
945 							,p_assignment_id
946 							,p_person_id
947 							,p_status_change_reason
948 							,p_return_status);
949 	 return;
950 	else
951 		fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
952 		hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
953 		hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
954 							 ,p_message_type  => hr_multi_message.g_error_msg);
955 		hr_utility.raise_error ;
956 	end if;
957     -- ER FPT
958     end if;
959  close c3 ;
960 
961   hr_utility.set_location('Entering:'|| l_proc, 110);
962 
963 -- Maintain the Person data by deleting the Ex-Appl Record and the same with PTU Data.
964 
965   DELETE FROM per_all_people_f papf
966    WHERE       papf.person_id               = p_person_id
967    AND         papf.business_group_id + 0   = p_Business_group_id
968    AND         papf.effective_start_date    = l_date_end + 1;
969 --
970 
971  hr_utility.set_location('REVERSE_TERM_APLN - l_date_end:'|| l_date_end, 120);
972 
973     UPDATE  per_all_people_f papf
974     SET     papf.effective_end_date  = l_eot
975     WHERE   papf.person_id           = p_person_id
976     AND     papf.BUSINESS_GROUP_ID + 0  = p_Business_group_id
977     AND     papf.effective_end_date  = l_date_end;
978 
979      hr_utility.set_location('Entering:'|| l_proc, 130);
980 
981   hr_utility.set_location('REVERSE_TERM_APLN - l_date_recieved:'|| l_date_recieved, 140);
982     hr_utility.set_location('REVERSE_TERM_APLN - l_application_id:'|| l_application_id, 140);
983 
984  open csr_ptu_row (l_date_recieved );
985      fetch csr_ptu_row into l_ptu_date_end;
986      close csr_ptu_row;
987 
988   hr_utility.set_location('REVERSE_TERM_APLN - l_ptu_date_end:'|| l_ptu_date_end, 150);
989 
990  hr_per_type_usage_internal.cancel_person_type_usage
991      (
992         p_effective_date         => l_ptu_date_end
993        ,p_person_id              => p_person_id
994        ,p_system_person_type     => 'EX_APL'
995      );
996 
997        hr_utility.set_location('Entering:'|| l_proc, 160);
998 
999 -- 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);
1000 
1001 irc_asg_status_api.create_irc_asg_status
1002                 (p_validate                => FALSE,
1003                  p_assignment_id              => p_assignment_id,
1004                  p_assignment_status_type_id  => l_assignment_status_id,
1005                  p_status_change_date         => p_effective_date,
1006                  p_assignment_status_id       => l_asg_status_id,
1007                  p_object_version_number      => l_object_version_number,
1008 		 p_status_change_reason         => p_status_change_reason);
1009 
1010 hr_utility.set_location('Entering:'|| l_proc, 170);
1011 
1012 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
1013 --to be in sync with the  assignments data
1014 
1015  hr_assignment.tidy_up_ref_int ( p_assignment_id,
1016                                  'FUTURE',
1017                                   null,
1018                                   l_asg_end_date,
1019                                   null,
1020                                   null,
1021                                  l_cost_warning ) ;
1022 -- clean up the letter requests.
1023 hr_utility.set_location('Entering:'|| l_proc, 180);
1024 
1025  per_app_asg_pkg.cleanup_letters
1026    (p_assignment_id => p_assignment_id);
1027 
1028     UPDATE PER_APPLICATIONS
1029     SET date_end =null
1030     where APPLICATION_ID =l_application_id
1031           and person_id= p_person_id ;
1032 
1033 -- now update the assignments table
1034 -- we must lock the row before we update it
1035 
1036 per_asg_shd.lck (p_effective_date =>l_asg_end_date ,
1037      p_datetrack_mode => 'CORRECTION',
1038      p_assignment_id  =>p_assignment_id,
1039      p_object_version_number =>l_ovn,
1040      p_validation_start_date =>l_validation_start_date,
1041      p_validation_end_date => l_validation_end_date);
1042 
1043 
1044    update per_all_assignments_f
1045    set effective_end_date =  l_eot
1046    where assignment_id = p_assignment_id
1047       and person_id=p_person_id
1048       and business_group_id= p_business_group_id
1049         and effective_end_date = l_asg_end_date;
1050 
1051    hr_utility.set_location('Entering:'|| l_proc, 190);
1052 end if;
1053 close c1;
1054 p_return_status := hr_multi_message.get_return_status_disable;
1055 EXCEPTION
1056 
1057 when hr_multi_message.error_message_exist then
1058 
1059     p_return_status:='E';
1060     hr_utility.set_location(' Leaving:' || l_proc, 30);
1061 when others then
1062   if c1%isopen then
1063    close c1;
1064   end if;
1065   p_return_status:='E';
1066   hr_utility.set_location('Entering:'|| l_proc, 200);
1067   raise; --uncommented for bug 7217475
1068 end;
1069 --
1070 --
1071 -- end of fix for bug 6008188
1072 ----------------------------------------------------------------------------
1073 -- |----------------------< update_scl_concat_segs >------------------------|
1074 ----------------------------------------------------------------------------
1075 -- {Start Of Comments}
1076 --
1077 -- Description:
1078 --   This procedure updates the hr_soft_coding_keyflex table after the flexfield
1079 --   segments have been inserted to keep the concatenated segment field up to
1080 --   date.
1081 --
1082 -- Prerequisites:
1083 --   A row must exist in the hr_soft_coding_keyflex table for p_soft_coding_keyflex_id
1084 --
1085 -- In Parameters:
1086 --   Name                           Reqd Type     Description
1087 --   p_soft_coding_keyflex_id       Yes  number   The primary key
1088 --   p_concatenated_segments        Yes  varchar2 The concatenated segments
1089 --
1090 -- Post Success:
1091 --   The row is updated
1092 --
1093 -- Post Failure:
1094 --   The procedure will raise an error.
1095 --
1096 -- Access Status:
1097 --   Internal use only.
1098 --
1099 -- {End Of Comments}
1100 --
1101 procedure update_scl_concat_segs
1102   (p_soft_coding_keyflex_id       in     number
1103   ,p_concatenated_segments        in     varchar2
1104   ) is
1105   --
1106   --
1107   CURSOR csr_chk_scl is
1108     SELECT null
1109       FROM 	hr_soft_coding_keyflex
1110      where  soft_coding_keyflex_id =  p_soft_coding_keyflex_id
1111        and (concatenated_segments  <> p_concatenated_segments
1112         or concatenated_segments is null);
1113   --
1114   l_exists  varchar2(30);
1115   l_proc   varchar2(72) := g_package||'update_scl_concat_segs ';
1116   --
1117   procedure update_scl_concat_segs_auto
1118    ( p_soft_coding_keyflex_id       in     number
1119     ,p_concatenated_segments        in     varchar2
1120    ) is
1121     PRAGMA AUTONOMOUS_TRANSACTION;
1122     --
1123     CURSOR csr_scl_lock is
1124       SELECT null
1125        FROM 	hr_soft_coding_keyflex
1126        where  soft_coding_keyflex_id =  p_soft_coding_keyflex_id
1127          for update nowait;
1128     --
1129     l_exists  varchar2(30);
1130     l_proc    varchar2(72) := g_package||'update_scl_concat_segs_auto';
1131     --
1132   begin
1133     if g_debug then
1134     hr_utility.set_location('Entering:'|| l_proc, 10);
1135     end if;
1136     --
1137     -- The outer procedure has already establish that an update is
1138     -- required. This sub-procedure uses an autonomous transaction
1139     -- to ensure that any commits do not impact the main transaction.
1140     -- If the row is successfully locked then continue and update the
1141     -- row. If the row cannot be locked then another transaction must
1142     -- be performing the update. So it is acceptable for this
1143     -- transaction to silently trap the error and continue.
1144     --
1145     -- Note: It is necessary to perform the lock test because in
1146     -- a batch data upload scenario multiple sessions could be
1147     -- attempting to insert or update the same Key Flexfield
1148     -- combination at the same time. Just directly updating the row,
1149     -- without first locking, can cause sessions to hang and reduce
1150     -- batch throughput.
1151     --
1152     open csr_scl_lock;
1153     fetch csr_scl_lock into l_exists;
1154     if csr_scl_lock%found then
1155       close csr_scl_lock;
1156 
1157       if g_debug then
1158       hr_utility.set_location(l_proc, 20);
1159       end if;
1160       --
1161       -- Lock obtained by this transaction, updating the concatenated
1162       -- segment string should be performed.
1163       --
1164       update  hr_soft_coding_keyflex
1165   	  set     concatenated_segments  = p_concatenated_segments
1166   	  where   soft_coding_keyflex_id = p_soft_coding_keyflex_id
1167          and (concatenated_segments   <> p_concatenated_segments
1168           or  concatenated_segments is null);
1169       --
1170       -- Commit this change so the change is immediately visible to
1171       -- other transactions. Also ensuring that it is not undone if
1172       -- the main transaction is rolled back. This commit is only
1173       -- acceptable inside an API because it is being performed inside
1174       -- an autonomous transaction and AOL code has previously
1175       -- inserted the Key Flexfield combination row in another
1176       -- autonomous transaction.
1177       commit;
1178     else
1179       close csr_scl_lock;
1180       rollback; -- Added for bug 3578845.
1181     end if;
1182     --
1183     if g_debug then
1184     hr_utility.set_location('Leaving:'|| l_proc, 30);
1185     end if;
1186 
1187   Exception
1188     When HR_Api.Object_Locked then
1189       --
1190       -- This autonomous transaction was unable to lock the row.
1191       -- It can be assumed that another transaction has locked the
1192       -- row and is performing the update. Hence the error can
1193       -- be suppressed without raising it to the end user.
1194       --
1195       rollback; -- Added for bug 3578845.
1196       hr_utility.set_location('Leaving:'|| l_proc, 40);
1197   end update_scl_concat_segs_auto;
1198 begin
1199 --
1200   if g_debug then
1201   hr_utility.set_location('Entering:'|| l_proc, 10);
1202   end if;
1203   --
1204   -- First find out if it is necessary to update the concatenated
1205   -- segment string column. This select is being done to avoid the
1206   -- performance unnecessary overhead of set-up an autonomous
1207   -- transaction when an update is not required. Updates are only
1208   -- expected immediately after the combination row was first inserted.
1209   --
1210   open csr_chk_scl;
1211   fetch csr_chk_scl into l_exists;
1212   if csr_chk_scl%found then
1213     close csr_chk_scl;
1214     update_scl_concat_segs_auto
1215       (p_soft_coding_keyflex_id  => p_soft_coding_keyflex_id
1216       ,p_concatenated_segments   => p_concatenated_segments
1217       );
1218   else
1219     close csr_chk_scl;
1220   end if;
1221   --
1222  if g_debug then
1223   hr_utility.set_location('Leaving:'|| l_proc, 20);
1224  end if;
1225   --
1226 end update_scl_concat_segs;
1227 -----------------------------------------------------------------------
1228 -- | ---------------<validate_SCL > --------------------------------| --
1229 -----------------------------------------------------------------------
1230 --
1231 -- Start of fix for bug 2622747
1232 procedure validate_SCL (
1233    p_validate                     in     boolean
1234   ,p_assignment_id                in     number
1235   ,p_effective_date               in     date
1236   ,p_business_group_id            in     number
1237   ,p_soft_coding_keyflex_id       in out nocopy number
1238   ,p_concatenated_segments           out nocopy varchar2
1239   ,p_concat_segments              in     varchar2
1240   ,p_segment1                     in     varchar2
1241   ,p_segment2                     in     varchar2
1242   ,p_segment3                     in     varchar2
1243   ,p_segment4                     in     varchar2
1244   ,p_segment5                     in     varchar2
1245   ,p_segment6                     in     varchar2
1246   ,p_segment7                     in     varchar2
1247   ,p_segment8                     in     varchar2
1248   ,p_segment9                     in     varchar2
1249   ,p_segment10                    in     varchar2
1250   ,p_segment11                    in     varchar2
1251   ,p_segment12                    in     varchar2
1252   ,p_segment13                    in     varchar2
1253   ,p_segment14                    in     varchar2
1254   ,p_segment15                    in     varchar2
1255   ,p_segment16                    in     varchar2
1256   ,p_segment17                    in     varchar2
1257   ,p_segment18                    in     varchar2
1258   ,p_segment19                    in     varchar2
1259   ,p_segment20                    in     varchar2
1260   ,p_segment21                    in     varchar2
1261   ,p_segment22                    in     varchar2
1262   ,p_segment23                    in     varchar2
1263   ,p_segment24                    in     varchar2
1264   ,p_segment25                    in     varchar2
1265   ,p_segment26                    in     varchar2
1266   ,p_segment27                    in     varchar2
1267   ,p_segment28                    in     varchar2
1268   ,p_segment29                    in     varchar2
1269   ,p_segment30                    in     varchar2
1270   )
1271  AS
1272   --
1273   -- Local Variables
1274   --
1275   --
1276   l_proc                         VARCHAR2(72) := g_package||'validate_scl';
1277   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
1278   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
1279   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
1280   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
1281   l_scl_null_ind               number(1) := 0;
1282 
1283   l_scl_segment1               varchar2(60) := p_segment1;
1284   l_scl_segment2               varchar2(60) := p_segment2;
1285   l_scl_segment3               varchar2(60) := p_segment3;
1286   l_scl_segment4               varchar2(60) := p_segment4;
1287   l_scl_segment5               varchar2(60) := p_segment5;
1288   l_scl_segment6               varchar2(60) := p_segment6;
1289   l_scl_segment7               varchar2(60) := p_segment7;
1290   l_scl_segment8               varchar2(60) := p_segment8;
1291   l_scl_segment9               varchar2(60) := p_segment9;
1292   l_scl_segment10              varchar2(60) := p_segment10;
1293   l_scl_segment11              varchar2(60) := p_segment11;
1294   l_scl_segment12              varchar2(60) := p_segment12;
1295   l_scl_segment13              varchar2(60) := p_segment13;
1296   l_scl_segment14              varchar2(60) := p_segment14;
1297   l_scl_segment15              varchar2(60) := p_segment15;
1298   l_scl_segment16              varchar2(60) := p_segment16;
1299   l_scl_segment17              varchar2(60) := p_segment17;
1300   l_scl_segment18              varchar2(60) := p_segment18;
1301   l_scl_segment19              varchar2(60) := p_segment19;
1302   l_scl_segment20              varchar2(60) := p_segment20;
1303   l_scl_segment21              varchar2(60) := p_segment21;
1304   l_scl_segment22              varchar2(60) := p_segment22;
1305   l_scl_segment23              varchar2(60) := p_segment23;
1306   l_scl_segment24              varchar2(60) := p_segment24;
1307   l_scl_segment25              varchar2(60) := p_segment25;
1308   l_scl_segment26              varchar2(60) := p_segment26;
1309   l_scl_segment27              varchar2(60) := p_segment27;
1310   l_scl_segment28              varchar2(60) := p_segment28;
1311   l_scl_segment29              varchar2(60) := p_segment29;
1312   l_scl_segment30              varchar2(60) := p_segment30;
1313 
1314   --
1315   -- Cursor Defination.
1316   --
1317   cursor csr_get_soft_coding_keyflex is
1318     select asg.soft_coding_keyflex_id
1319       from per_all_assignments_f asg
1320      where asg.assignment_id = p_assignment_id
1321        and p_effective_date  between asg.effective_start_date
1322                            and     asg.effective_end_date;
1323 
1324   --
1325   cursor csr_scl_idsel is
1326     select plr.rule_mode                       id_flex_num
1327     from   pay_legislation_rules               plr,
1328            per_business_groups_perf            pgr
1329     where  plr.legislation_code                = pgr.legislation_code
1330     and    pgr.business_group_id               = p_business_group_id
1331     and    plr.rule_type                       = 'S'
1332     and    exists
1333           (select 1
1334            from   fnd_segment_attribute_values fsav
1335            where  to_char(fsav.id_flex_num)    = plr.rule_mode    -- Fix For Bug # 12813119
1336            and    fsav.application_id          = 800
1337            and    fsav.id_flex_code            = 'SCL'
1338            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
1339            and    fsav.attribute_value         = 'Y')
1340     and    exists
1341           (select 1
1342            from   pay_legislation_rules        plr2
1343            where  plr2.legislation_code        = plr.legislation_code
1344            and    plr2.rule_type               = 'SDL'
1345            and    plr2.rule_mode               = 'A') ;
1346   --
1347   --
1348   cursor c_scl_segments is
1349      select concatenated_segments,
1350 	    segment1,
1351             segment2,
1352             segment3,
1353             segment4,
1354             segment5,
1355             segment6,
1356             segment7,
1357             segment8,
1358             segment9,
1359             segment10,
1360             segment11,
1361             segment12,
1362             segment13,
1363             segment14,
1364             segment15,
1365             segment16,
1366             segment17,
1367             segment18,
1368             segment19,
1369             segment20,
1370             segment21,
1371             segment22,
1372             segment23,
1373             segment24,
1374             segment25,
1375             segment26,
1376             segment27,
1377             segment28,
1378             segment29,
1379             segment30
1380      from   hr_soft_coding_keyflex
1381      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
1382 
1383 --
1384 --  Start of Fix for Bug 2643451
1385      l_old_conc_segs      hr_soft_coding_keyflex.concatenated_segments%TYPE;
1386      l_old_scl_segments   c_scl_segments%rowtype;
1387 --  End of Fix for Bug 2643451
1388 --
1389 
1390 
1391   BEGIN
1392 
1393  if g_debug then
1394  hr_utility.set_location('Entering:'|| l_proc, 5);
1395  end if;
1396 
1397  l_old_conc_segments:=p_concat_segments;
1398 
1399   --
1400   -- Issue a savepoint.
1401   --
1402   savepoint validate_SCL;
1403   --
1404 
1405   --
1406   -- If SCL ID is passed then
1407   -- Select Segments from SCL table
1408   --
1409 
1410     if l_soft_coding_keyflex_id is not null
1411     then
1412        l_scl_null_ind := 1;
1413        open c_scl_segments;
1414        fetch c_scl_segments into l_old_conc_segs,
1415 				 l_scl_segment1,
1416                                  l_scl_segment2,
1417                                  l_scl_segment3,
1418                                  l_scl_segment4,
1419                                  l_scl_segment5,
1420                                  l_scl_segment6,
1421                                  l_scl_segment7,
1422                                  l_scl_segment8,
1423                                  l_scl_segment9,
1424                                  l_scl_segment10,
1425                                  l_scl_segment11,
1426                                  l_scl_segment12,
1427                                  l_scl_segment13,
1428                                  l_scl_segment14,
1429                                  l_scl_segment15,
1430                                  l_scl_segment16,
1431                                  l_scl_segment17,
1432                                  l_scl_segment18,
1433                                  l_scl_segment19,
1434                                  l_scl_segment20,
1435                                  l_scl_segment21,
1436                                  l_scl_segment22,
1437                                  l_scl_segment23,
1438                                  l_scl_segment24,
1439                                  l_scl_segment25,
1440                                  l_scl_segment26,
1441                                  l_scl_segment27,
1442                                  l_scl_segment28,
1443                                  l_scl_segment29,
1444                                  l_scl_segment30;
1445     close c_scl_segments;
1446   else
1447     l_scl_null_ind := 0;
1448  if g_debug then
1449     hr_utility.set_location(l_proc, 16);
1450  end if;
1451   end if;
1452 
1453 
1454 
1455 
1456  if l_scl_null_ind = 0
1457  then
1458        open csr_get_soft_coding_keyflex;
1459          fetch csr_get_soft_coding_keyflex into l_soft_coding_keyflex_id;
1460 
1461 
1462  if g_debug then
1463         hr_utility.set_location('SCL ID' ||l_soft_coding_keyflex_id, 10);
1464  end if;
1465        --
1466        if csr_get_soft_coding_keyflex%NOTFOUND then
1467          close csr_get_soft_coding_keyflex;
1468          hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
1469          hr_utility.raise_error;
1470  --
1471  -- Start of Fix for bug 2643451
1472  --
1473      else
1474        if l_soft_coding_keyflex_id is not null then
1475         open c_scl_segments;
1476         fetch c_scl_segments into l_old_scl_segments;
1477         close c_scl_segments;
1478        end if;
1479  --
1480  -- End of Fix for Bug 2643451
1481  --
1482      end if;
1483 
1484        --
1485        close csr_get_soft_coding_keyflex;
1486 
1487 
1488     -- Start of Fix for Bug 2643451
1489     -- Start of Fix for   Bug 2548555
1490      --
1491      if   nvl(l_scl_segment1,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment1 ,hr_api.g_varchar2)
1492        or nvl(l_scl_segment2,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment2 ,hr_api.g_varchar2)
1493        or nvl(l_scl_segment3,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment3 ,hr_api.g_varchar2)
1494        or nvl(l_scl_segment4,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment4 ,hr_api.g_varchar2)
1495        or nvl(l_scl_segment5,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment5 ,hr_api.g_varchar2)
1496        or nvl(l_scl_segment6,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment6 ,hr_api.g_varchar2)
1497        or nvl(l_scl_segment7,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment7 ,hr_api.g_varchar2)
1498        or nvl(l_scl_segment8,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment8 ,hr_api.g_varchar2)
1499        or nvl(l_scl_segment9,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment9 ,hr_api.g_varchar2)
1500        or nvl(l_scl_segment10,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment10 ,hr_api.g_varchar2)
1501        or nvl(l_scl_segment11,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment11 ,hr_api.g_varchar2)
1502        or nvl(l_scl_segment12,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment12 ,hr_api.g_varchar2)
1503        or nvl(l_scl_segment13,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment13 ,hr_api.g_varchar2)
1504        or nvl(l_scl_segment14,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment14 ,hr_api.g_varchar2)
1505        or nvl(l_scl_segment15,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment15 ,hr_api.g_varchar2)
1506        or nvl(l_scl_segment16,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment16 ,hr_api.g_varchar2)
1507        or nvl(l_scl_segment17,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment17 ,hr_api.g_varchar2)
1508        or nvl(l_scl_segment18,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment18 ,hr_api.g_varchar2)
1509        or nvl(l_scl_segment19,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment19 ,hr_api.g_varchar2)
1510        or nvl(l_scl_segment20,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment20 ,hr_api.g_varchar2)
1511        or nvl(l_scl_segment21,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment21 ,hr_api.g_varchar2)
1512        or nvl(l_scl_segment22,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment22 ,hr_api.g_varchar2)
1513        or nvl(l_scl_segment23,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment23 ,hr_api.g_varchar2)
1514        or nvl(l_scl_segment24,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment24 ,hr_api.g_varchar2)
1515        or nvl(l_scl_segment25,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment25 ,hr_api.g_varchar2)
1516        or nvl(l_scl_segment26,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment26 ,hr_api.g_varchar2)
1517        or nvl(l_scl_segment27,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment27 ,hr_api.g_varchar2)
1518        or nvl(l_scl_segment28,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment28 ,hr_api.g_varchar2)
1519        or nvl(l_scl_segment29,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment29 ,hr_api.g_varchar2)
1520        or nvl(l_scl_segment30,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment30 ,hr_api.g_varchar2)
1521        -- bug 944911
1522        -- changed p_concatenated_segments to p_concat_segments
1523         or nvl(p_concat_segments,hr_api.g_varchar2) <> nvl(l_old_scl_segments.concatenated_segments ,hr_api.g_varchar2)
1524  --
1525  -- End of Fix for Bug 2548555
1526  -- End of Fix for Bug 2643451
1527  --
1528 
1529 
1530        then
1531            open csr_scl_idsel;
1532            fetch csr_scl_idsel into l_flex_num;
1533 
1534  if g_debug then
1535            hr_utility.set_location('SCL_ID_SEL'||l_flex_num, 10);
1536  end if;
1537            --
1538            if csr_scl_idsel%NOTFOUND then
1539               close csr_scl_idsel;
1540 
1541               if   l_scl_segment1 is not null
1542                 or l_scl_segment2 is not null
1543                 or l_scl_segment3 is not null
1544                 or l_scl_segment4 is not null
1545                 or l_scl_segment5 is not null
1546                 or l_scl_segment6 is not null
1547                 or l_scl_segment7 is not null
1548                 or l_scl_segment8 is not null
1549                 or l_scl_segment9 is not null
1550                 or l_scl_segment10 is not null
1551                 or l_scl_segment11 is not null
1552                 or l_scl_segment12 is not null
1553                 or l_scl_segment13 is not null
1554                 or l_scl_segment14 is not null
1555                 or l_scl_segment15 is not null
1556                 or l_scl_segment16 is not null
1557                 or l_scl_segment17 is not null
1558                 or l_scl_segment18 is not null
1559                 or l_scl_segment19 is not null
1560                 or l_scl_segment20 is not null
1561                 or l_scl_segment21 is not null
1562                 or l_scl_segment22 is not null
1563                 or l_scl_segment23 is not null
1564                 or l_scl_segment24 is not null
1565                 or l_scl_segment25 is not null
1566                 or l_scl_segment26 is not null
1567                 or l_scl_segment27 is not null
1568                 or l_scl_segment28 is not null
1569                 or l_scl_segment29 is not null
1570                 or l_scl_segment30 is not null
1571                 or p_concat_segments is not null
1572               then
1573               --
1574               hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1575               hr_utility.set_message_token('PROCEDURE', l_proc);
1576               hr_utility.set_message_token('STEP','6');
1577               hr_utility.raise_error;
1578               end if;
1579            else -- csr_scl_idsel is found
1580               close csr_scl_idsel;
1581               --
1582               -- Process Logic
1583               --
1584               --
1585               -- Update or select the soft_coding_keyflex_id
1586               --
1587               hr_kflex_utility.upd_or_sel_keyflex_comb
1588               (p_appl_short_name        => 'PER'
1589               ,p_flex_code              => 'SCL'
1590               ,p_flex_num               => l_flex_num
1591               ,p_segment1               => l_scl_segment1
1592               ,p_segment2               => l_scl_segment2
1593               ,p_segment3               => l_scl_segment3
1594               ,p_segment4               => l_scl_segment4
1595               ,p_segment5               => l_scl_segment5
1596               ,p_segment6               => l_scl_segment6
1597               ,p_segment7               => l_scl_segment7
1598               ,p_segment8               => l_scl_segment8
1599               ,p_segment9               => l_scl_segment9
1600               ,p_segment10              => l_scl_segment10
1601               ,p_segment11              => l_scl_segment11
1602               ,p_segment12              => l_scl_segment12
1603               ,p_segment13              => l_scl_segment13
1604               ,p_segment14              => l_scl_segment14
1605               ,p_segment15              => l_scl_segment15
1606               ,p_segment16              => l_scl_segment16
1607               ,p_segment17              => l_scl_segment17
1608               ,p_segment18              => l_scl_segment18
1609               ,p_segment19              => l_scl_segment19
1610               ,p_segment20              => l_scl_segment20
1611               ,p_segment21              => l_scl_segment21
1612               ,p_segment22              => l_scl_segment22
1613               ,p_segment23              => l_scl_segment23
1614               ,p_segment24              => l_scl_segment24
1615               ,p_segment25              => l_scl_segment25
1616               ,p_segment26              => l_scl_segment26
1617               ,p_segment27              => l_scl_segment27
1618               ,p_segment28              => l_scl_segment28
1619               ,p_segment29              => l_scl_segment29
1620               ,p_segment30              => l_scl_segment30
1621               ,p_concat_segments_in     => l_old_conc_segments
1622               ,p_ccid                   => l_soft_coding_keyflex_id
1623               ,p_concat_segments_out    => l_concatenated_segments
1624               );
1625               --
1626               -- update the combinations column
1627               --
1628  if g_debug then
1629               hr_utility.set_location(l_proc, 17);
1630  end if;
1631               update_scl_concat_segs
1632               (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
1633               ,p_concatenated_segments   => l_concatenated_segments
1634               );
1635              --
1636            end if; -- csr_scl_idsel%NOTFOUND
1637            --
1638        end if;  -- l_scl_segment1 <> hr_api.g_varchar2
1639        --
1640  end if; -- l_soft_coding_key_flex_id is null
1641 
1642   --
1643   -- When in validation only mode raise the Validate_Enabled exception
1644   --
1645   if p_validate then
1646     raise hr_api.validate_enabled;
1647   end if;
1648 
1649  --
1650  -- Setting Output Variables
1651  --
1652   p_concatenated_segments        := l_concatenated_segments;
1653   p_soft_coding_keyflex_id       := l_soft_coding_keyflex_id;
1654 
1655 
1656 EXCEPTION
1657   when hr_api.validate_enabled then
1658      ROLLBACK TO validate_SCL;
1659 
1660      p_concatenated_segments  := l_old_conc_segments;
1661 
1662      if l_scl_null_ind = 0
1663      then
1664        p_soft_coding_keyflex_id  := null;
1665      end if;
1666 
1667   when others then
1668     --
1669     -- A validation or unexpected error has occurred
1670 
1671     IF csr_get_soft_coding_keyflex%isopen then
1672        close csr_get_soft_coding_keyflex;
1673     END IF;
1674 
1675     IF 	csr_scl_idsel%isOpen then
1676        close csr_scl_idsel;
1677     END IF;
1678 
1679     IF 	c_scl_segments%isOpen then
1680        close c_scl_segments;
1681     END IF;
1682 
1683     RAISE;
1684 
1685 END validate_SCL;
1686 
1687 -- End of fix for Bug 2622747
1688 
1689 -- -----------------------------------------------------------------------------
1690 -- |--------------------------< last_apl_asg >---------------------------------|
1691 -- -----------------------------------------------------------------------------
1692 --
1693 
1694 -- {Start of Comments}
1695 --
1696 -- Description:
1697 --   Determines if the assignment is the last applicant assignment on a given
1698 --   date
1699 --
1700 -- Prerequisites:
1701 --   None
1702 --
1703 -- In Parameters
1704 --   Name                           Reqd Type     Description
1705 --   p_assignment_id                Yes  number   Assignment id
1706 --   p_effective_date               Yes  date     Effective date
1707 --
1708 -- Post Success:
1709 --   A boolean indicator signifying if the assignment is the last applicant
1710 --   assignment on the effective date is returned.
1711 --
1712 -- Post Failure:
1713 --   An error is raised
1714 --
1715 -- Access Status:
1716 --   Internal Development Use Only
1717 --
1718 -- {End of Comments}
1719 --
1720 FUNCTION last_apl_asg
1721   (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
1722   ,p_effective_date               IN     DATE
1723   )
1724 RETURN BOOLEAN
1725 IS
1726   --
1727   -- Local variables
1728   --
1729   l_proc                         VARCHAR2(72) ;
1730   --
1731   l_last_apl_asg                 BOOLEAN;
1732   --
1733   -- Local cursors
1734   --
1735   CURSOR csr_last_apl_asg
1736     (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
1737     ,p_effective_date               IN     DATE
1738     )
1739   IS
1740     SELECT as2.assignment_id
1741       FROM per_all_assignments_f as2
1742           ,per_all_assignments_f as1
1743      WHERE as2.person_id = as1.person_id
1744        AND as2.assignment_type = as1.assignment_type
1745        AND csr_last_apl_asg.p_effective_date BETWEEN as2.effective_start_date
1746                                                  AND as2.effective_end_date
1747        AND as2.assignment_id <> as1.assignment_id
1748        AND as1.assignment_id = csr_last_apl_asg.p_assignment_id;
1749   l_last_apl_asg_rec             csr_last_apl_asg%ROWTYPE;
1750 --
1751 BEGIN
1752   --
1753  if g_debug then
1754   l_proc := g_package||'last_apl_asg';
1755   hr_utility.set_location('Entering:'||l_proc,10);
1756  end if;
1757   --
1758   -- If another applicant assignment exists on this date
1759   -- then this is NOT the last applicant assignment
1760   --
1761   OPEN csr_last_apl_asg
1762     (p_assignment_id                => p_assignment_id
1763     ,p_effective_date               => p_effective_date
1764     );
1765   FETCH csr_last_apl_asg INTO l_last_apl_asg_rec;
1766   l_last_apl_asg := csr_last_apl_asg%NOTFOUND;
1767   CLOSE csr_last_apl_asg;
1768   --
1769  if g_debug then
1770   hr_utility.set_location(' Leaving:'||l_proc,10);
1771  end if;
1772   --
1773   RETURN(l_last_apl_asg);
1774 --
1775 EXCEPTION
1776   WHEN OTHERS
1777   THEN
1778     IF csr_last_apl_asg%ISOPEN
1779     THEN
1780       CLOSE csr_last_apl_asg;
1781     END IF;
1782     RAISE;
1783 --
1784 END last_apl_asg;
1785 --
1786 -- ----------------------------------------------------------------------------
1787 -- |--------------------------< activate_emp_asg >----------------------------|
1788 -- ----------------------------------------------------------------------------
1789 --
1790 procedure activate_emp_asg
1791   (p_validate                     in     boolean
1792   ,p_effective_date               in     date     -- default value removed. Bug 2364484
1793   ,p_datetrack_update_mode        in     varchar2
1794   ,p_assignment_id                in     number
1795   ,p_change_reason                in     varchar2
1796   ,p_object_version_number        in out nocopy number
1797   ,p_assignment_status_type_id    in     number
1798   ,p_effective_start_date            out nocopy date
1799   ,p_effective_end_date              out nocopy date
1800   ) is
1801   --
1802   -- Declare cursors and local variables
1803   --
1804   l_effective_date             date;
1805   --
1806   -- Out variables
1807   --
1808   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1809   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1810   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1811   --
1812   lv_object_version_number     number := p_object_version_number ;
1813   --
1814   l_proc                       varchar2(72);
1815   --
1816 begin
1817  if g_debug then
1818   l_proc := g_package||'activate_emp_asg';
1819   hr_utility.set_location('Entering:'|| l_proc, 5);
1820  end if;
1821   --
1822   --
1823   l_object_version_number := p_object_version_number;
1824   --
1825   -- Corrected assignment from trunc(l_effective_date) to
1826   -- trunc(p_effective_date). RMF 25-Aug-97.
1827   --
1828   l_effective_date        := trunc(p_effective_date);
1829   --
1830   -- Issue a savepoint.
1831   --
1832   savepoint activate_emp_asg;
1833   --
1834  if g_debug then
1835   hr_utility.set_location(l_proc, 10);
1836  end if;
1837   --
1838   -- Validation in addition to Table Handlers
1839   --
1840   -- None required.
1841   --
1842   -- Process Logic
1843   --
1844   --
1845   -- Start of API User Hook for the before hook of activate_emp_asg.
1846   --
1847   begin
1848      hr_assignment_bk6.activate_emp_asg_b
1849           (p_effective_date               => l_effective_date
1850           ,p_datetrack_update_mode        => p_datetrack_update_mode
1851           ,p_assignment_id                => p_assignment_id
1852           ,p_change_reason                => p_change_reason
1853           ,p_object_version_number        => p_object_version_number
1854           ,p_assignment_status_type_id    => p_assignment_status_type_id
1855           );
1856   exception
1857      when hr_api.cannot_find_prog_unit then
1858        hr_api.cannot_find_prog_unit_error
1859          (p_module_name       => 'ACTIVATE_EMP_ASG',
1860           p_hook_type         => 'BP'
1861          );
1862   end;
1863   --
1864   -- Update employee assignment.
1865   --
1866   hr_assignment_internal.update_status_type_emp_asg
1867     (p_effective_date               => l_effective_date
1868     ,p_datetrack_update_mode        => p_datetrack_update_mode
1869     ,p_assignment_id                => p_assignment_id
1870     ,p_change_reason                => p_change_reason
1871     ,p_object_version_number        => l_object_version_number
1872     ,p_expected_system_status       => 'ACTIVE_ASSIGN'
1873     ,p_assignment_status_type_id    => p_assignment_status_type_id
1874     ,p_effective_start_date         => l_effective_start_date
1875     ,p_effective_end_date           => l_effective_end_date
1876     );
1877   --
1878  if g_debug then
1879   hr_utility.set_location(l_proc, 20);
1880  end if;
1881   --
1882   -- Start of API User Hook for the after hook of activate_emp_asg.
1883   --
1884   begin
1885      hr_assignment_bk6.activate_emp_asg_a
1886            (p_effective_date               => l_effective_date
1887            ,p_datetrack_update_mode        => p_datetrack_update_mode
1888            ,p_assignment_id                => p_assignment_id
1889            ,p_change_reason                => p_change_reason
1890            ,p_object_version_number        => l_object_version_number
1891            ,p_assignment_status_type_id    => p_assignment_status_type_id
1892            ,p_effective_start_date         => l_effective_start_date
1893            ,p_effective_end_date           => l_effective_end_date
1894            );
1895   exception
1896      when hr_api.cannot_find_prog_unit then
1897        hr_api.cannot_find_prog_unit_error
1898          (p_module_name       => 'ACTIVATE_EMP_ASG',
1899           p_hook_type         => 'AP'
1900          );
1901   end;
1902   --
1903   -- End of API User Hook for the after hook of activate_emp_asg.
1904   --
1905   --
1906   -- When in validation only mode raise the Validate_Enabled exception
1907   --
1908   if p_validate then
1909     raise hr_api.validate_enabled;
1910   end if;
1911   --
1912   -- Set all output arguments
1913   --
1914   p_object_version_number := l_object_version_number;
1915   p_effective_start_date  := l_effective_start_date;
1916   p_effective_end_date    := l_effective_end_date;
1917   --
1918  if g_debug then
1919   hr_utility.set_location(' Leaving:'||l_proc, 100);
1920  end if;
1921 exception
1922   when hr_api.validate_enabled then
1923     --
1924     -- As the Validate_Enabled exception has been raised
1925     -- we must rollback to the savepoint
1926     --
1927     ROLLBACK TO activate_emp_asg;
1928     --
1929     -- Only set output warning arguments
1930     -- (Any key or derived arguments must be set to null
1931     -- when validation only mode is being used.)
1932     --
1933     p_object_version_number  := p_object_version_number;
1934     p_effective_start_date   := null;
1935     p_effective_end_date     := null;
1936     --
1937   when others then
1938     --
1939     -- A validation or unexpected error has occurred
1940     --
1941     -- Added as part of fix to bug 632479
1942     --
1943     p_object_version_number   := lv_object_version_number ;
1944     p_effective_start_date    := null ;
1945     p_effective_end_date      := null ;
1946 
1947     ROLLBACK TO activate_emp_asg;
1948     raise;
1949     --
1950     -- End of fix.
1951     --
1952 end activate_emp_asg;
1953 --
1954 -- ----------------------------------------------------------------------------
1955 -- |--------------------------< activate_cwk_asg >----------------------------|
1956 -- ----------------------------------------------------------------------------
1957 --
1958 procedure activate_cwk_asg
1959   (p_validate                     in     boolean
1960   ,p_effective_date               in     date
1961   ,p_datetrack_update_mode        in     varchar2
1962   ,p_assignment_id                in     number
1963   ,p_change_reason                in     varchar2
1964   ,p_object_version_number        in out nocopy number
1965   ,p_assignment_status_type_id    in     number
1966   ,p_effective_start_date            out nocopy date
1967   ,p_effective_end_date              out nocopy date
1968   ) is
1969   --
1970   -- Declare cursors and local variables
1971   --
1972   l_effective_date             date;
1973   --
1974   -- Out variables
1975   --
1976   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1977   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1978   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1979   --
1980   lv_object_version_number     number := p_object_version_number ;
1981   --
1982   l_proc                       varchar2(72);
1983   --
1984 begin
1985  if g_debug then
1986   l_proc := g_package||'activate_cwk_asg';
1987   hr_utility.set_location('Entering:'|| l_proc, 5);
1988  end if;
1989   --
1990   --
1991   l_object_version_number := p_object_version_number;
1992   --
1993   -- Corrected assignment from trunc(l_effective_date) to
1994   -- trunc(p_effective_date). RMF 25-Aug-97.
1995   --
1996   l_effective_date        := trunc(p_effective_date);
1997   --
1998   -- Issue a savepoint.
1999   --
2000   savepoint activate_cwk_asg;
2001   --
2002  if g_debug then
2003   hr_utility.set_location(l_proc, 10);
2004  end if;
2005   --
2006   -- Validation in addition to Table Handlers
2007   --
2008   -- None required.
2009   --
2010   -- Process Logic
2011   --
2012   --
2013   -- Start of API User Hook for the before hook of activate_cwk_asg.
2014   --
2015   begin
2016      hr_assignment_bkj.activate_cwk_asg_b
2017           (p_effective_date               => l_effective_date
2018           ,p_datetrack_update_mode        => p_datetrack_update_mode
2019           ,p_assignment_id                => p_assignment_id
2020           ,p_change_reason                => p_change_reason
2021           ,p_object_version_number        => p_object_version_number
2022           ,p_assignment_status_type_id    => p_assignment_status_type_id
2023           );
2024   exception
2025      when hr_api.cannot_find_prog_unit then
2026        hr_api.cannot_find_prog_unit_error
2027          (p_module_name       => 'ACTIVATE_CWK_ASG',
2028           p_hook_type         => 'BP'
2029          );
2030   end;
2031   --
2032   -- Update contingent worker assignment.
2033   --
2034   hr_assignment_internal.update_status_type_cwk_asg
2035     (p_effective_date               => l_effective_date
2036     ,p_datetrack_update_mode        => p_datetrack_update_mode
2037     ,p_assignment_id                => p_assignment_id
2038     ,p_change_reason                => p_change_reason
2039     ,p_object_version_number        => l_object_version_number
2040     ,p_expected_system_status       => 'ACTIVE_CWK'
2041     ,p_assignment_status_type_id    => p_assignment_status_type_id
2042     ,p_effective_start_date         => l_effective_start_date
2043     ,p_effective_end_date           => l_effective_end_date
2044     );
2045   --
2046  if g_debug then
2047   hr_utility.set_location(l_proc, 20);
2048  end if;
2049   --
2050   -- Start of API User Hook for the after hook of activate_cwk_asg.
2051   --
2052   begin
2053      hr_assignment_bkj.activate_cwk_asg_a
2054            (p_effective_date               => l_effective_date
2055            ,p_datetrack_update_mode        => p_datetrack_update_mode
2056            ,p_assignment_id                => p_assignment_id
2057            ,p_change_reason                => p_change_reason
2058            ,p_object_version_number        => l_object_version_number
2059            ,p_assignment_status_type_id    => p_assignment_status_type_id
2060            ,p_effective_start_date         => l_effective_start_date
2061            ,p_effective_end_date           => l_effective_end_date
2062            );
2063   exception
2064      when hr_api.cannot_find_prog_unit then
2065        hr_api.cannot_find_prog_unit_error
2066          (p_module_name       => 'ACTIVATE_CWK_ASG',
2067           p_hook_type         => 'AP'
2068          );
2069   end;
2070   --
2071   -- End of API User Hook for the after hook of activate_cwk_asg.
2072   --
2073   --
2074   -- When in validation only mode raise the Validate_Enabled exception
2075   --
2076   if p_validate then
2077     raise hr_api.validate_enabled;
2078   end if;
2079   --
2080   -- Set all output arguments
2081   --
2082   p_object_version_number := l_object_version_number;
2083   p_effective_start_date  := l_effective_start_date;
2084   p_effective_end_date    := l_effective_end_date;
2085   --
2086  if g_debug then
2087   hr_utility.set_location(' Leaving:'||l_proc, 100);
2088  end if;
2089 exception
2090   when hr_api.validate_enabled then
2091     --
2092     -- As the Validate_Enabled exception has been raised
2093     -- we must rollback to the savepoint
2094     --
2095     ROLLBACK TO activate_cwk_asg;
2096     --
2097     -- Only set output warning arguments
2098     -- (Any key or derived arguments must be set to null
2099     -- when validation only mode is being used.)
2100     --
2101     p_object_version_number  := p_object_version_number;
2102     p_effective_start_date   := null;
2103     p_effective_end_date     := null;
2104     --
2105   when others then
2106     --
2107     -- A validation or unexpected error has occurred
2108     --
2109     -- Added as part of fix to bug 632479
2110     --
2111     p_object_version_number := lv_object_version_number;
2112     p_effective_start_date   := null;
2113     p_effective_end_date     := null;
2114 
2115     ROLLBACK TO activate_cwk_asg;
2116     raise;
2117     --
2118     -- End of fix.
2119     --
2120 end activate_cwk_asg;
2121 --
2122 -- ----------------------------------------------------------------------------
2123 -- |---------------------< actual_termination_cwk_asg >-----------------------|
2124 -- ----------------------------------------------------------------------------
2125 --
2126 procedure actual_termination_cwk_asg
2127   (p_validate                     in     boolean
2128   ,p_assignment_id                in     number
2129   ,p_object_version_number        in out nocopy number
2130   ,p_actual_termination_date      in     date
2131   ,p_assignment_status_type_id    in     number
2132   ,p_effective_start_date            out nocopy date
2133   ,p_effective_end_date              out nocopy date
2134   ,p_asg_future_changes_warning      out nocopy boolean
2135   ,p_entries_changed_warning         out nocopy varchar2
2136   ,p_pay_proposal_warning            out nocopy boolean
2137   ) is
2138   --
2139   -- Declare cursors and local variables
2140   --
2141   -- Out variables
2142   --
2143   l_asg_future_changes_warning boolean := FALSE;
2144   l_pay_proposal_warning       boolean := FALSE;
2145   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
2146   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
2147   l_entries_changed_warning    varchar2(1) := 'N';
2148   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
2149   --
2150   l_assignment_status_type_id
2151                                per_all_assignments_f.assignment_status_type_id%TYPE;
2152   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
2153   l_asg_business_group_id      per_all_assignments_f.business_group_id%TYPE;
2154   l_exists                     varchar2(1);
2155   l_last_standard_process_date
2156                        per_periods_of_service.last_standard_process_date%TYPE;
2157   l_actual_termination_date
2158 		       per_periods_of_service.actual_termination_date%TYPE;
2159   l_legislation_code           per_business_groups.legislation_code%TYPE;
2160   l_payroll_id                 per_all_assignments_f.payroll_id%TYPE;
2161   l_per_system_status      per_assignment_status_types.per_system_status%TYPE;
2162   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
2163   l_proc                       varchar2(72)
2164                                := g_package || 'actual_termination_cwk_asg';
2165   --
2166   lv_object_version_number     number := p_object_version_number ;
2167   --
2168   cursor csr_get_asg_details is
2169     select asg.assignment_type
2170          , asg.payroll_id
2171          , asg.primary_flag
2172          , bus.business_group_id
2173          , bus.legislation_code
2174       from per_all_assignments_f   asg
2175 	     , per_business_groups_perf bus
2176      where asg.assignment_id         = p_assignment_id
2177        and l_actual_termination_date between asg.effective_start_date
2178                                      and     asg.effective_end_date
2179        and bus.business_group_id+0    = asg.business_group_id;
2180   --
2181   cursor csr_invalid_term_assign is
2182     select null
2183       from per_all_assignments_f           asg
2184          , per_assignment_status_types ast
2185      where asg.assignment_id             =  p_assignment_id
2186        and asg.effective_end_date        >= l_actual_termination_date
2187        and ast.assignment_status_type_id =  asg.assignment_status_type_id
2188        and ast.per_system_status         =  'TERM_CWK_ASG';
2189   --
2190   cursor csr_get_period_end_date is
2191     select tpe.end_date
2192       from per_time_periods tpe
2193      where tpe.payroll_id            = l_payroll_id
2194        and l_actual_termination_date between tpe.start_date
2195                                      and     tpe.end_date;
2196   --
2197 begin
2198  if g_debug then
2199   hr_utility.set_location('Entering:'|| l_proc, 1);
2200  end if;
2201   --
2202   l_assignment_status_type_id := p_assignment_status_type_id;
2203   l_object_version_number     := p_object_version_number;
2204   l_actual_termination_date   := trunc(p_actual_termination_date);
2205   --
2206   -- Issue a savepoint.
2207   --
2208   savepoint actual_termination_cwk_asg;
2209   --
2210  if g_debug then
2211   hr_utility.set_location(l_proc, 10);
2212  end if;
2213   --
2214   -- Validation in addition to Table Handlers
2215   --
2216   -- Get assignment and business group details for validation.
2217   --
2218   hr_api.mandatory_arg_error
2219      (p_api_name       => l_proc
2220      ,p_argument       => 'assignment_id'
2221      ,p_argument_value => p_assignment_id
2222      );
2223   --
2224   hr_api.mandatory_arg_error
2225      (p_api_name       => l_proc
2226      ,p_argument       => 'actual_termination_date'
2227      ,p_argument_value => l_actual_termination_date
2228      );
2229   --
2230  if g_debug then
2231   hr_utility.set_location(l_proc, 20);
2232  end if;
2233   --
2234   open  csr_get_asg_details;
2235   fetch csr_get_asg_details
2236    into l_assignment_type
2237       , l_payroll_id
2238       , l_primary_flag
2239       , l_asg_business_group_id
2240       , l_legislation_code;
2241   --
2242   if csr_get_asg_details%NOTFOUND
2243   then
2244     --
2245  if g_debug then
2246     hr_utility.set_location(l_proc, 30);
2247  end if;
2248     --
2249     close csr_get_asg_details;
2250     --
2251     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
2252     hr_utility.raise_error;
2253   end if;
2254   --
2255   close csr_get_asg_details;
2256   --
2257   -- Start of API User Hook for the before hook of actual_termination_cwk_asg.
2258   --
2259   begin
2260      hr_assignment_bkk.actual_termination_cwk_asg_b
2261        (p_assignment_id                 =>  p_assignment_id
2262        ,p_object_version_number         =>  p_object_version_number
2263        ,p_actual_termination_date       =>  l_actual_termination_date
2264        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
2265        ,p_business_group_id             =>  l_asg_business_group_id
2266        );
2267   exception
2268      when hr_api.cannot_find_prog_unit then
2269        hr_api.cannot_find_prog_unit_error
2270          (p_module_name       => 'ACTUAL_TERMINATION_CWK_ASG',
2271           p_hook_type         => 'BP'
2272          );
2273   end;
2274   --
2275   -- End of API User Hook for the before hook of actual_termination_cwk_asg.
2276   --
2277  if g_debug then
2278   hr_utility.set_location(l_proc, 40);
2279  end if;
2280   --
2281   -- The assignment must not be a primary assignment.
2282   --
2283   if l_primary_flag <> 'N'
2284   then
2285     --
2286  if g_debug then
2287     hr_utility.set_location(l_proc, 50);
2288  end if;
2289     --
2290     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
2291     hr_utility.raise_error;
2292   end if;
2293   --
2294  if g_debug then
2295   hr_utility.set_location(l_proc, 60);
2296  end if;
2297   --
2298   -- The assignment must be a contingent worker assignment.
2299   --
2300   if l_assignment_type <> 'C'
2301   then
2302     --
2303  if g_debug then
2304     hr_utility.set_location(l_proc, 70);
2305  end if;
2306     --
2307     hr_utility.set_message('PER','HR_289616_ASG_NOT_CWK');
2308     hr_utility.raise_error;
2309   end if;
2310   --
2311  if g_debug then
2312   hr_utility.set_location(l_proc, 80);
2313  end if;
2314   --
2315   -- The assignment status type must not already be TERM_CWK_ASSIGN on
2316   -- or after the actual termination date.
2317   --
2318   open  csr_invalid_term_assign;
2319   fetch csr_invalid_term_assign
2320    into l_exists;
2321   --
2322   if csr_invalid_term_assign%FOUND
2323   then
2324     --
2325  if g_debug then
2326     hr_utility.set_location(l_proc, 90);
2327  end if;
2328     --
2329     close csr_invalid_term_assign;
2330     --
2331     hr_utility.set_message('PER','HR_289617_ASG_ALREADY_TERM');
2332     hr_utility.raise_error;
2333   end if;
2334   --
2335   close csr_invalid_term_assign;
2336   --
2337  if g_debug then
2338   hr_utility.set_location(l_proc, 100);
2339  end if;
2340   --
2341   -- Process Logic
2342   --
2343   -- If p_assignment_status_type_id is g_number then derive it's default value,
2344   -- otherwise validate it.
2345   --
2346   per_asg_bus1.chk_assignment_status_type
2347     (p_assignment_status_type_id => l_assignment_status_type_id
2348     ,p_business_group_id         => l_asg_business_group_id
2349     ,p_legislation_code          => l_legislation_code
2350     ,p_expected_system_status    => 'TERM_ASSIGN'  --Fix for bug 8337789.
2351     );
2352   --
2353  if g_debug then
2354   hr_utility.set_location(l_proc, 110);
2355  end if;
2356   --
2357   -- Derive the last standard process date.
2358   --
2359   -- Bug 1711085. VS. 27-MAR-01. Commented out the code associated with
2360   -- disabling last_standard_process  for US legislature.
2361   --
2362   -- if l_legislation_code = 'US'
2363   -- then
2364     --
2365  if g_debug then
2366      hr_utility.set_location(l_proc, 120);
2367  end if;
2368     --
2369     -- l_last_standard_process_date := l_actual_termination_date;
2370   -- else
2371     --
2372  if g_debug then
2373     hr_utility.set_location(l_proc, 130);
2374  end if;
2375     --
2376     if l_payroll_id is not null
2377     then
2378       --
2379  if g_debug then
2380       hr_utility.set_location(l_proc, 140);
2381  end if;
2382       --
2383       -- Assignment is assigned to a payroll, so set the last standard process
2384       -- to date to the payroll's period end date as of the actual termination
2385       -- date.
2386       --
2387       open  csr_get_period_end_date;
2388       fetch csr_get_period_end_date
2389        into l_last_standard_process_date;
2390       --
2391       if csr_get_period_end_date%NOTFOUND then
2392         --
2393  if g_debug then
2394         hr_utility.set_location(l_proc, 150);
2395  end if;
2396         --
2397         -- No payroll period found for the actual termination date.
2398         --
2399         close csr_get_period_end_date;
2400         --
2401         hr_utility.set_message(801,'HR_51003_ASG_INV_NO_TERM_PRD');
2402         hr_utility.raise_error;
2403       end if;
2404       --
2405       close csr_get_period_end_date;
2406       --
2407  if g_debug then
2408       hr_utility.set_location(l_proc, 160);
2409  end if;
2410     else
2411       --
2412  if g_debug then
2413       hr_utility.set_location(l_proc, 170);
2414  end if;
2415       --
2416       -- Assignment is not assigned to a payroll, so set the last standard
2417       -- process date to the actual termination date.
2418       --
2419       l_last_standard_process_date := l_actual_termination_date;
2420     end if;
2421   -- end if;
2422   --
2423  if g_debug then
2424   hr_utility.set_location(l_proc, 180);
2425  end if;
2426   --
2427   -- Call the business support process to update assignment and maintain the
2428   -- element entries. We call this procedure for contingent workers
2429   -- because they are processed in the same way as employees.
2430   --
2431   hr_assignment_internal.actual_term_cwk_asg
2432     (p_assignment_id              => p_assignment_id
2433     ,p_object_version_number      => l_object_version_number
2434     ,p_actual_termination_date    => l_actual_termination_date
2435     ,p_last_standard_process_date => l_last_standard_process_date
2436     ,p_assignment_status_type_id  => l_assignment_status_type_id
2437     ,p_effective_start_date       => l_effective_start_date
2438     ,p_effective_end_date         => l_effective_end_date
2439     ,p_asg_future_changes_warning => l_asg_future_changes_warning
2440     ,p_entries_changed_warning    => l_entries_changed_warning
2441     ,p_pay_proposal_warning       => l_pay_proposal_warning
2442     );
2443   --
2444  if g_debug then
2445   hr_utility.set_location(l_proc, 190);
2446  end if;
2447   --
2448   -- When in validation only mode raise the Validate_Enabled exception
2449   --
2450   --
2451   -- Start of API User Hook for the after hook of actual_termination_cwk_asg.
2452   -- Local vars are passed in for all OUT parms because the hook needs to
2453   -- be placed before the validate check and therefore before the code that
2454   -- sets all out parms.
2455   --
2456   begin
2457      hr_assignment_bkk.actual_termination_cwk_asg_a
2458        (p_assignment_id                 =>  p_assignment_id
2459        ,p_object_version_number         =>  l_object_version_number
2460        ,p_actual_termination_date       =>  l_actual_termination_date
2461        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
2462        ,p_effective_start_date          =>  l_effective_start_date
2463        ,p_effective_end_date            =>  l_effective_end_date
2464        ,p_asg_future_changes_warning    =>  l_asg_future_changes_warning
2465        ,p_entries_changed_warning       =>  l_entries_changed_warning
2466        ,p_pay_proposal_warning          =>  l_pay_proposal_warning
2467        ,p_business_group_id             =>  l_asg_business_group_id
2468        );
2469   exception
2470      when hr_api.cannot_find_prog_unit then
2471        hr_api.cannot_find_prog_unit_error
2472          (p_module_name       => 'ACTUAL_TERMINATION_CWK_ASG',
2473           p_hook_type         => 'AP'
2474          );
2475   end;
2476   --
2477   -- End of API User Hook for the after hook of actual_termination_cwk_asg.
2478   --
2479   if p_validate then
2480     raise hr_api.validate_enabled;
2481   end if;
2482   --
2483   -- Set all output arguments
2484   --
2485   p_asg_future_changes_warning := l_asg_future_changes_warning;
2486   p_effective_end_date         := l_effective_end_date;
2487   p_effective_start_date       := l_effective_start_date;
2488   p_entries_changed_warning    := l_entries_changed_warning;
2489   p_pay_proposal_warning       := l_pay_proposal_warning;
2490   p_object_version_number      := l_object_version_number;
2491   --
2492  if g_debug then
2493   hr_utility.set_location(' Leaving:'||l_proc, 200);
2494  end if;
2495 exception
2496   when hr_api.validate_enabled then
2497     --
2498     -- As the Validate_Enabled exception has been raised
2499     -- we must rollback to the savepoint
2500     --
2501     ROLLBACK TO actual_termination_cwk_asg;
2502     --
2503     -- Only set output warning arguments
2504     -- (Any key or derived arguments must be set to null
2505     -- when validation only mode is being used.)
2506     --
2507     p_asg_future_changes_warning := l_asg_future_changes_warning;
2508     p_effective_end_date         := null;
2509     p_effective_start_date       := null;
2510     p_entries_changed_warning    := l_entries_changed_warning;
2511     p_pay_proposal_warning       := l_pay_proposal_warning;
2512     p_object_version_number      := p_object_version_number;
2513     --
2514   when others then
2515     --
2516     -- A validation or unexpected error has occurred
2517     --
2518     -- Added as part of fix to bug 632479
2519     --
2520     p_object_version_number := lv_object_version_number;
2521     p_effective_start_date       := null ;
2522     p_effective_end_date         := null ;
2523     p_asg_future_changes_warning  := null ;
2524     p_entries_changed_warning     := null ;
2525     p_pay_proposal_warning        := null ;
2526 
2527     ROLLBACK TO actual_termination_cwk_asg;
2528     raise;
2529     --
2530 end actual_termination_cwk_asg;
2531 --
2532 -- ----------------------------------------------------------------------------
2533 -- |------------------------< final_process_cwk_asg >-------------------------|
2534 -- ----------------------------------------------------------------------------
2535 --
2536 procedure final_process_cwk_asg
2537   (p_validate                     in     boolean
2538   ,p_assignment_id                in     number
2539   ,p_object_version_number        in out nocopy number
2540   ,p_final_process_date           in     date
2541   ,p_effective_start_date            out nocopy date
2542   ,p_effective_end_date              out nocopy date
2543   ,p_org_now_no_manager_warning      out nocopy boolean
2544   ,p_asg_future_changes_warning      out nocopy boolean
2545   ,p_entries_changed_warning         out nocopy varchar2
2546   ) is
2547   --
2548   -- Declare cursors and local variables
2549   --
2550   -- Out variables
2551   --
2552   l_asg_future_changes_warning boolean := FALSE;
2553   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
2554   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
2555   l_entries_changed_warning    varchar2(1) := 'N';
2556   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
2557   l_org_now_no_manager_warning boolean := FALSE;
2558   --
2559   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
2560   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
2561   l_proc                       varchar2(72)
2562                                      := g_package || 'final_process_cwk_asg';
2563   l_actual_termination_date    date;
2564   l_final_process_date         date;
2565   l_max_asg_end_date           date;
2566   --
2567   lv_object_version_number     number := p_object_version_number ;
2568   --
2569   cursor csr_get_derived_details is
2570     select asg.assignment_type
2571          , asg.primary_flag
2572       from per_all_assignments_f      asg
2573      where asg.assignment_id        = p_assignment_id
2574        and l_final_process_date     between asg.effective_start_date
2575                                     and     asg.effective_end_date;
2576   --
2577   cursor csr_valid_term_assign is
2578     select min(asg.effective_start_date) - 1
2579       from per_all_assignments_f           asg
2580      where asg.assignment_id             = p_assignment_id
2581        and exists ( select null
2582 		    from per_assignment_status_types ast
2583 		    where ast.assignment_status_type_id
2584 		     = asg.assignment_status_type_id
2585                      and ast.per_system_status = 'TERM_CWK_ASG');
2586 
2587 --
2588   cursor csr_invalid_term_assign is
2589     select max(asg.effective_end_date)
2590       from per_all_assignments_f           asg
2591      where asg.assignment_id      = p_assignment_id
2592        and exists ( select null
2593 		    from per_assignment_status_types ast
2594 		    where ast.assignment_status_type_id
2595 		     = asg.assignment_status_type_id
2596                      and ast.per_system_status = 'TERM_CWK_ASG');
2597 
2598 --
2599 begin
2600  if g_debug then
2601   hr_utility.set_location('Entering:'|| l_proc, 1);
2602  end if;
2603   --
2604   l_object_version_number := p_object_version_number;
2605   l_final_process_date    := trunc(p_final_process_date);
2606   --
2607   -- Issue a savepoint.
2608   --
2609   savepoint final_process_cwk_asg;
2610   --
2611  if g_debug then
2612   hr_utility.set_location(l_proc, 10);
2613  end if;
2614   --
2615   -- Validation in addition to Table Handlers
2616   --
2617   -- Get assignment and business group details for validation.
2618   --
2619   hr_api.mandatory_arg_error
2620      (p_api_name       => l_proc
2621      ,p_argument       => 'assignment_id'
2622      ,p_argument_value => p_assignment_id
2623      );
2624   --
2625   hr_api.mandatory_arg_error
2626      (p_api_name       => l_proc
2627      ,p_argument       => 'final_process_date'
2628      ,p_argument_value => l_final_process_date
2629      );
2630   --
2631  if g_debug then
2632   hr_utility.set_location(l_proc, 20);
2633  end if;
2634   --
2635   open  csr_get_derived_details;
2636   fetch csr_get_derived_details
2637    into l_assignment_type
2638       , l_primary_flag;
2639   --
2640   if csr_get_derived_details%NOTFOUND
2641   then
2642     --
2643  if g_debug then
2644     hr_utility.set_location(l_proc, 30);
2645  end if;
2646     --
2647     close csr_get_derived_details;
2648     --
2649     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
2650     hr_utility.raise_error;
2651   end if;
2652   --
2653   close csr_get_derived_details;
2654   --
2655   -- Start of API User Hook for the before hook of final_process_cwk_asg.
2656   --
2657   begin
2658      hr_assignment_bkh.final_process_cwk_asg_b
2659        (p_assignment_id                 =>  p_assignment_id
2660        ,p_object_version_number         =>  p_object_version_number
2661        ,p_final_process_date            =>  l_final_process_date
2662        );
2663   exception
2664      when hr_api.cannot_find_prog_unit then
2665        hr_api.cannot_find_prog_unit_error
2666          (p_module_name       => 'FINAL_PROCESS_CWK_ASG',
2667           p_hook_type         => 'BP'
2668          );
2669   end;
2670   --
2671   --
2672  if g_debug then
2673   hr_utility.set_location(l_proc, 40);
2674  end if;
2675   --
2676   -- The assignment must not be a primary assignment.
2677   --
2678   if l_primary_flag <> 'N'
2679   then
2680     --
2681  if g_debug then
2682     hr_utility.set_location(l_proc, 50);
2683  end if;
2684     --
2685     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
2686     hr_utility.raise_error;
2687   end if;
2688   --
2689  if g_debug then
2690   hr_utility.set_location(l_proc, 60);
2691  end if;
2692   --
2693   -- The assignment must be an contingent worker assignment.
2694   --
2695   if l_assignment_type <> 'C'
2696   then
2697     --
2698  if g_debug then
2699     hr_utility.set_location(l_proc, 70);
2700  end if;
2701     --
2702     hr_utility.set_message('PER','HR_289616_ASG_NOT_CWK');
2703     hr_utility.raise_error;
2704   end if;
2705 
2706   -- Ensure that the assignment has not been terminated previously
2707 
2708   --
2709   open  csr_invalid_term_assign;
2710   fetch csr_invalid_term_assign
2711    into l_max_asg_end_date;
2712   close csr_invalid_term_assign;
2713 
2714   --
2715   if l_max_asg_end_date <> hr_api.g_eot
2716   then
2717     --
2718  if g_debug then
2719     hr_utility.set_location(l_proc, 90);
2720  end if;
2721     --
2722     hr_utility.set_message(801,'HR_7962_PDS_INV_FP_CHANGE');
2723     hr_utility.raise_error;
2724   end if;
2725   --
2726  if g_debug then
2727   hr_utility.set_location(l_proc, 80);
2728  end if;
2729   --
2730   -- Ensure that the the final process date is on or after the actual
2731   -- termination date by checking that the assignment status is
2732   -- TERM_CWK_ASG for the day after the final process date.
2733   --
2734     --Fix for bug 8337789 starts here.
2735 /*  open  csr_valid_term_assign;
2736   fetch csr_valid_term_assign
2737    into l_actual_termination_date;
2738   close csr_valid_term_assign;
2739 
2740   --
2741   if l_actual_termination_date is null
2742   then
2743     --
2744  if g_debug then
2745     hr_utility.set_location(l_proc, 90);
2746  end if;
2747     --
2748     hr_utility.set_message(801,'HR_51007_ASG_INV_NOT_ACT_TERM');
2749     hr_utility.raise_error;
2750   end if;
2751   */
2752 
2753  l_actual_termination_date:=l_final_process_date;
2754 
2755   --Fix for bug 8337789 ends here.
2756 
2757   if l_final_process_date < l_actual_termination_date then
2758 
2759  if g_debug then
2760     hr_utility.set_location(l_proc, 95);
2761  end if;
2762 
2763     -- This error message has been set temporarily
2764 
2765     hr_utility.set_message(801,'HR_7963_PDS_INV_FP_BEFORE_ATT');
2766     hr_utility.raise_error;
2767   end if;
2768   --
2769   --
2770  if g_debug then
2771   hr_utility.set_location(l_proc, 100);
2772  end if;
2773   --
2774   -- Process Logic
2775   --
2776   -- Call the business support process to update assignment and maintain the
2777   -- element entries. Here we call the emp procedure because processing
2778   -- for a contingent worker is identical from this point.
2779   --
2780   hr_assignment_internal.final_process_cwk_asg
2781     (p_assignment_id              => p_assignment_id
2782     ,p_object_version_number      => l_object_version_number
2783     ,p_final_process_date         => l_final_process_date
2784     ,p_actual_termination_date    => l_actual_termination_date
2785     ,p_effective_start_date       => l_effective_start_date
2786     ,p_effective_end_date         => l_effective_end_date
2787     ,p_org_now_no_manager_warning => l_org_now_no_manager_warning
2788     ,p_asg_future_changes_warning => l_asg_future_changes_warning
2789     ,p_entries_changed_warning    => l_entries_changed_warning
2790     );
2791   --
2792  if g_debug then
2793   hr_utility.set_location(l_proc, 110);
2794  end if;
2795   --
2796   -- Start of API User Hook for the after hook of final_process_cwk_asg.
2797   --
2798   begin
2799      hr_assignment_bkh.final_process_cwk_asg_a
2800         (p_assignment_id                 =>     p_assignment_id
2801         ,p_object_version_number         =>     l_object_version_number
2802         ,p_final_process_date            =>     p_final_process_date
2803         ,p_effective_start_date          =>     l_effective_start_date
2804         ,p_effective_end_date            =>     l_effective_end_date
2805         ,p_org_now_no_manager_warning    =>     l_org_now_no_manager_warning
2806         ,p_asg_future_changes_warning    =>     l_asg_future_changes_warning
2807         ,p_entries_changed_warning       =>     l_entries_changed_warning
2808         );
2809   exception
2810      when hr_api.cannot_find_prog_unit then
2811        hr_api.cannot_find_prog_unit_error
2812          (p_module_name       => 'FINAL_PROCESS_CWK_ASG',
2813           p_hook_type         => 'AP'
2814          );
2815   end;
2816   --
2817   -- End of API User Hook for the after hook of final_process_cwk_asg.
2818   --
2819   --
2820   -- When in validation only mode raise the Validate_Enabled exception
2821   --
2822   if p_validate then
2823     raise hr_api.validate_enabled;
2824   end if;
2825   --
2826   -- Set all output arguments
2827   --
2828   p_asg_future_changes_warning := l_asg_future_changes_warning;
2829   p_effective_end_date         := l_effective_end_date;
2830   p_effective_start_date       := l_effective_start_date;
2831   p_entries_changed_warning    := l_entries_changed_warning;
2832   p_object_version_number      := l_object_version_number;
2833   p_org_now_no_manager_warning := l_org_now_no_manager_warning;
2834   --
2835  if g_debug then
2836   hr_utility.set_location(' Leaving:'||l_proc, 300);
2837  end if;
2838 exception
2839   when hr_api.validate_enabled then
2840     --
2841     -- As the Validate_Enabled exception has been raised
2842     -- we must rollback to the savepoint
2843     --
2844     ROLLBACK TO final_process_cwk_asg;
2845     --
2846     -- Only set output warning arguments
2847     -- (Any key or derived arguments must be set to null
2848     -- when validation only mode is being used.)
2849     --
2850     p_asg_future_changes_warning := l_asg_future_changes_warning;
2851     p_effective_end_date         := null;
2852     p_effective_start_date       := null;
2853     p_entries_changed_warning    := l_entries_changed_warning;
2854     p_org_now_no_manager_warning := l_org_now_no_manager_warning;
2855     --
2856   when others then
2857     --
2858     -- A validation or unexpected error has occurred
2859     --
2860     -- Added as part of fix to bug 632479
2861     --
2862     p_object_version_number := lv_object_version_number;
2863 
2864     p_effective_start_date           := null;
2865     p_effective_end_date              := null;
2866     p_org_now_no_manager_warning      := null;
2867     p_asg_future_changes_warning      := null;
2868     p_entries_changed_warning         := null;
2869 
2870     ROLLBACK TO final_process_cwk_asg;
2871     raise;
2872     --
2873     -- End of fix.
2874     --
2875 end final_process_cwk_asg;
2876 --
2877 -- ----------------------------------------------------------------------------
2878 -- |---------------------------< suspend_cwk_asg >----------------------------|
2879 -- ----------------------------------------------------------------------------
2880 --
2881 procedure suspend_cwk_asg
2882   (p_validate                     in     boolean
2883   ,p_effective_date               in     date
2884   ,p_datetrack_update_mode        in     varchar2
2885   ,p_assignment_id                in     number
2886   ,p_change_reason                in     varchar2
2887   ,p_object_version_number        in out nocopy number
2888   ,p_assignment_status_type_id    in     number
2889   ,p_effective_start_date            out nocopy date
2890   ,p_effective_end_date              out nocopy date
2891   ) is
2892   --
2893   -- Declare cursors and local variables
2894   --
2895   l_effective_date             date;
2896   --
2897   -- Out variables
2898   --
2899   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
2900   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
2901   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
2902   --
2903   l_proc                       varchar2(72);
2904   --
2905 begin
2906  if g_debug then
2907   l_proc := g_package||'suspend_cwk_asg';
2908   hr_utility.set_location('Entering:'|| l_proc, 5);
2909  end if;
2910   --
2911   --
2912   l_object_version_number := p_object_version_number;
2913   --
2914   -- Issue a savepoint.
2915   --
2916   savepoint suspend_cwk_asg;
2917   --
2918  if g_debug then
2919   hr_utility.set_location(l_proc, 10);
2920  end if;
2921   --
2922   -- Initialise local variable - added 25-Aug-97. RMF.
2923   --
2924   l_effective_date := trunc(p_effective_date);
2925   --
2926   -- Validation in addition to Table Handlers
2927   --
2928   -- None required.
2929   --
2930   -- Process Logic
2931   --
2932   -- Start of API User Hook for the before hook of suspend_cwk_asg.
2933   --
2934   begin
2935      hr_assignment_bkl.suspend_cwk_asg_b
2936        (p_effective_date               => l_effective_date
2937        ,p_datetrack_update_mode        => p_datetrack_update_mode
2938        ,p_assignment_id                => p_assignment_id
2939        ,p_change_reason                => p_change_reason
2940        ,p_object_version_number        => p_object_version_number
2941        ,p_assignment_status_type_id    => p_assignment_status_type_id
2942        );
2943   exception
2944      when hr_api.cannot_find_prog_unit then
2945        hr_api.cannot_find_prog_unit_error
2946          (p_module_name       => 'SUSPEND_CWK_ASG',
2947           p_hook_type         => 'BP'
2948          );
2949   end;
2950   --
2951   --
2952   -- Update contingent worker assignment.
2953   --
2954   hr_assignment_internal.update_status_type_cwk_asg
2955     (p_effective_date               => l_effective_date
2956     ,p_datetrack_update_mode        => p_datetrack_update_mode
2957     ,p_assignment_id                => p_assignment_id
2958     ,p_change_reason                => p_change_reason
2959     ,p_object_version_number        => l_object_version_number
2960     ,p_expected_system_status       => 'SUSP_CWK_ASG'
2961     ,p_assignment_status_type_id    => p_assignment_status_type_id
2962     ,p_effective_start_date         => l_effective_start_date
2963     ,p_effective_end_date           => l_effective_end_date
2964     );
2965   --
2966  if g_debug then
2967   hr_utility.set_location(l_proc, 20);
2968  end if;
2969   --
2970   -- Start of API User Hook for the after hook of suspend_cwk_asg.
2971   --
2972   begin
2973      hr_assignment_bkl.suspend_cwk_asg_a
2974         (p_effective_date               => l_effective_date
2975         ,p_datetrack_update_mode        => p_datetrack_update_mode
2976         ,p_assignment_id                => p_assignment_id
2977         ,p_change_reason                => p_change_reason
2978         ,p_object_version_number        => l_object_version_number
2979         ,p_assignment_status_type_id    => p_assignment_status_type_id
2980         ,p_effective_start_date         => l_effective_start_date
2981         ,p_effective_end_date           => l_effective_end_date
2982         );
2983   exception
2984      when hr_api.cannot_find_prog_unit then
2985        hr_api.cannot_find_prog_unit_error
2986          (p_module_name       => 'SUSPEND_CWK_ASG',
2987           p_hook_type         => 'AP'
2988          );
2989   end;
2990   --
2991   -- End of API User Hook for the after hook of suspend_cwk_asg.
2992   --
2993   --
2994   -- When in validation only mode raise the Validate_Enabled exception
2995   --
2996   if p_validate then
2997     raise hr_api.validate_enabled;
2998   end if;
2999   --
3000   -- Set all output arguments
3001   --
3002   p_object_version_number := l_object_version_number;
3003   p_effective_start_date  := l_effective_start_date;
3004   p_effective_end_date    := l_effective_end_date;
3005   --
3006  if g_debug then
3007   hr_utility.set_location(' Leaving:'||l_proc, 100);
3008  end if;
3009 exception
3010   when hr_api.validate_enabled then
3011     --
3012     -- As the Validate_Enabled exception has been raised
3013     -- we must rollback to the savepoint
3014     --
3015     ROLLBACK TO suspend_cwk_asg;
3016     --
3017     -- Only set output warning arguments
3018     -- (Any key or derived arguments must be set to null
3019     -- when validation only mode is being used.)
3020     --
3021     p_object_version_number  := p_object_version_number;
3022     p_effective_start_date   := null;
3023     p_effective_end_date     := null;
3024     --
3025   when others then
3026     --
3027     -- A validation or unexpected error has occurred
3028     --
3029     -- Added as part of fix to bug 632479
3030     --
3031     ROLLBACK TO suspend_cwk_asg;
3032     raise;
3033     --
3034     -- End of fix.
3035     --
3036 end suspend_cwk_asg;
3037 --
3038 -- ----------------------------------------------------------------------------
3039 -- |---------------------< actual_termination_emp_asg >-----------------------|
3040 -- ----------------------------------------------------------------------------
3041 --
3042 procedure actual_termination_emp_asg
3043   (p_validate                     in     boolean
3044   ,p_assignment_id                in     number
3045   ,p_object_version_number        in out nocopy number
3046   ,p_actual_termination_date      in     date
3047   ,p_assignment_status_type_id    in     number
3048   ,p_effective_start_date            out nocopy date
3049   ,p_effective_end_date              out nocopy date
3050   ,p_asg_future_changes_warning      out nocopy boolean
3051   ,p_entries_changed_warning         out nocopy varchar2
3052   ,p_pay_proposal_warning            out nocopy boolean
3053   ) is
3054   --
3055   -- Declare cursors and local variables
3056   --
3057   -- Out variables
3058   --
3059   l_asg_future_changes_warning boolean := FALSE;
3060   l_pay_proposal_warning       boolean := FALSE;
3061   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
3062   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
3063   l_entries_changed_warning    varchar2(1) := 'N';
3064   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
3065   --
3066   l_assignment_status_type_id
3067                                per_all_assignments_f.assignment_status_type_id%TYPE;
3068   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
3069   l_asg_business_group_id      per_all_assignments_f.business_group_id%TYPE;
3070   l_exists                     varchar2(1);
3071   l_last_standard_process_date
3072                        per_periods_of_service.last_standard_process_date%TYPE;
3073   l_actual_termination_date
3074 		       per_periods_of_service.actual_termination_date%TYPE;
3075   l_legislation_code           per_business_groups.legislation_code%TYPE;
3076   l_payroll_id                 per_all_assignments_f.payroll_id%TYPE;
3077   l_per_system_status      per_assignment_status_types.per_system_status%TYPE;
3078   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
3079   l_proc                       varchar2(72)
3080                                := g_package || 'actual_termination_emp_asg';
3081   --
3082   lv_object_version_number     number := p_object_version_number ;
3083   --
3084   cursor csr_get_asg_details is
3085     select asg.assignment_type
3086          , asg.payroll_id
3087          , asg.primary_flag
3088          , bus.business_group_id
3089          , bus.legislation_code
3090       from per_all_assignments_f   asg
3091 	     , per_business_groups_perf bus
3092      where asg.assignment_id         = p_assignment_id
3093        and l_actual_termination_date between asg.effective_start_date
3094                                      and     asg.effective_end_date
3095        and bus.business_group_id+0     = asg.business_group_id;
3096   --
3097   cursor csr_invalid_term_assign is
3098     select null
3099       from per_all_assignments_f           asg
3100          , per_assignment_status_types ast
3101      where asg.assignment_id             =  p_assignment_id
3102        and asg.effective_end_date        >= l_actual_termination_date
3103        and ast.assignment_status_type_id =  asg.assignment_status_type_id
3104        and ast.per_system_status         =  'TERM_ASSIGN';
3105   --
3106   cursor csr_get_period_end_date is
3107     select tpe.end_date
3108       from per_time_periods tpe
3109      where tpe.payroll_id            = l_payroll_id
3110        and l_actual_termination_date between tpe.start_date
3111                                      and     tpe.end_date;
3112   --
3113 begin
3114  if g_debug then
3115   hr_utility.set_location('Entering:'|| l_proc, 1);
3116  end if;
3117   --
3118   l_assignment_status_type_id := p_assignment_status_type_id;
3119   l_object_version_number     := p_object_version_number;
3120   l_actual_termination_date   := trunc(p_actual_termination_date);
3121   --
3122   -- Issue a savepoint.
3123   --
3124   savepoint actual_termination_emp_asg;
3125   --
3126  if g_debug then
3127   hr_utility.set_location(l_proc, 10);
3128  end if;
3129   --
3130   -- Validation in addition to Table Handlers
3131   --
3132   -- Get assignment and business group details for validation.
3133   --
3134   hr_api.mandatory_arg_error
3135      (p_api_name       => l_proc
3136      ,p_argument       => 'assignment_id'
3137      ,p_argument_value => p_assignment_id
3138      );
3139   --
3140   hr_api.mandatory_arg_error
3141      (p_api_name       => l_proc
3142      ,p_argument       => 'actual_termination_date'
3143      ,p_argument_value => l_actual_termination_date
3144      );
3145   --
3146  if g_debug then
3147   hr_utility.set_location(l_proc, 20);
3148  end if;
3149   --
3150   open  csr_get_asg_details;
3151   fetch csr_get_asg_details
3152    into l_assignment_type
3153       , l_payroll_id
3154       , l_primary_flag
3155       , l_asg_business_group_id
3156       , l_legislation_code;
3157   --
3158   if csr_get_asg_details%NOTFOUND
3159   then
3160     --
3161  if g_debug then
3162     hr_utility.set_location(l_proc, 30);
3163  end if;
3164     --
3165     close csr_get_asg_details;
3166     --
3167     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
3168     hr_utility.raise_error;
3169   end if;
3170   --
3171   close csr_get_asg_details;
3172   --
3173   -- Start of API User Hook for the before hook of actual_termination_emp_asg.
3174   --
3175   begin
3176      hr_assignment_bk4.actual_termination_emp_asg_b
3177        (p_assignment_id                 =>  p_assignment_id
3178        ,p_object_version_number         =>  p_object_version_number
3179        ,p_actual_termination_date       =>  l_actual_termination_date
3180        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
3181        ,p_business_group_id             =>  l_asg_business_group_id
3182        );
3183   exception
3184      when hr_api.cannot_find_prog_unit then
3185        hr_api.cannot_find_prog_unit_error
3186          (p_module_name       => 'ACTUAL_TERMINATION_EMP_ASG',
3187           p_hook_type         => 'BP'
3188          );
3189   end;
3190   --
3191   -- End of API User Hook for the before hook of actual_termination_emp_asg.
3192   --
3193  if g_debug then
3194   hr_utility.set_location(l_proc, 40);
3195  end if;
3196   --
3197   -- The assignment must not be a primary assignment.
3198   --
3199   if l_primary_flag <> 'N'
3200   then
3201     --
3202  if g_debug then
3203     hr_utility.set_location(l_proc, 50);
3204  end if;
3205     --
3206     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
3207     hr_utility.raise_error;
3208   end if;
3209   --
3210  if g_debug then
3211   hr_utility.set_location(l_proc, 60);
3212  end if;
3213   --
3214   -- The assignment must be an employee assignment.
3215   --
3216   if l_assignment_type <> 'E'
3217   then
3218     --
3219  if g_debug then
3220     hr_utility.set_location(l_proc, 70);
3221  end if;
3222     --
3223     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
3224     hr_utility.raise_error;
3225   end if;
3226   --
3227  if g_debug then
3228   hr_utility.set_location(l_proc, 80);
3229  end if;
3230   --
3231   -- The assignment status type must not already be TERM_ASSIGN on or after
3232   -- the actual termination date.
3233   --
3234   open  csr_invalid_term_assign;
3235   fetch csr_invalid_term_assign
3236    into l_exists;
3237   --
3238   if csr_invalid_term_assign%FOUND
3239   then
3240     --
3241  if g_debug then
3242     hr_utility.set_location(l_proc, 90);
3243  end if;
3244     --
3245     close csr_invalid_term_assign;
3246     --
3247     hr_utility.set_message(800,'PER_52108_ASG_INV_TERM_ASSIGN');
3248     hr_utility.raise_error;
3249   end if;
3250   --
3251   close csr_invalid_term_assign;
3252   --
3253  if g_debug then
3254   hr_utility.set_location(l_proc, 100);
3255  end if;
3256   --
3257   -- Process Logic
3258   --
3259   -- If p_assignment_status_type_id is g_number then derive it's default value,
3260   -- otherwise validate it.
3261   --
3262   per_asg_bus1.chk_assignment_status_type
3263     (p_assignment_status_type_id => l_assignment_status_type_id
3264     ,p_business_group_id         => l_asg_business_group_id
3265     ,p_legislation_code          => l_legislation_code
3266     ,p_expected_system_status    => 'TERM_ASSIGN'
3267     );
3268   --
3269  if g_debug then
3270   hr_utility.set_location(l_proc, 110);
3271  end if;
3272   --
3273   -- Derive the last standard process date.
3274   --
3275   -- Bug 1711085. VS. 27-MAR-01. Commented out the code associated with
3276   -- disabling last_standard_process  for US legislature.
3277   --
3278   -- if l_legislation_code = 'US'
3279   -- then
3280     --
3281  if g_debug then
3282      hr_utility.set_location(l_proc, 120);
3283  end if;
3284     --
3285     -- l_last_standard_process_date := l_actual_termination_date;
3286   -- else
3287     --
3288  if g_debug then
3289     hr_utility.set_location(l_proc, 130);
3290  end if;
3291     --
3292     if l_payroll_id is not null
3293     then
3294       --
3295  if g_debug then
3296       hr_utility.set_location(l_proc, 140);
3297  end if;
3298       --
3299       -- Assignment is assigned to a payroll, so set the last standard process
3300       -- to date to the payroll's period end date as of the actual termination
3301       -- date.
3302       --
3303       open  csr_get_period_end_date;
3304       fetch csr_get_period_end_date
3305        into l_last_standard_process_date;
3306       --
3307       if csr_get_period_end_date%NOTFOUND then
3308         --
3309  if g_debug then
3310         hr_utility.set_location(l_proc, 150);
3311  end if;
3312         --
3313         -- No payroll period found for the actual termination date.
3314         --
3315         close csr_get_period_end_date;
3316         --
3317         hr_utility.set_message(801,'HR_51003_ASG_INV_NO_TERM_PRD');
3318         hr_utility.raise_error;
3319       end if;
3320       --
3321       close csr_get_period_end_date;
3322       --
3323  if g_debug then
3324       hr_utility.set_location(l_proc, 160);
3325  end if;
3326     else
3327       --
3328  if g_debug then
3329       hr_utility.set_location(l_proc, 170);
3330  end if;
3331       --
3332       -- Assignment is not assigned to a payroll, so set the last standard
3333       -- process date to the actual termination date.
3334       --
3335       l_last_standard_process_date := l_actual_termination_date;
3336     end if;
3337   -- end if;
3338   --
3339  if g_debug then
3340   hr_utility.set_location(l_proc, 180);
3341  end if;
3342   --
3343   -- Call the business support process to update assignment and maintain the
3344   -- element entries.
3345   --
3346   hr_assignment_internal.actual_term_emp_asg_sup
3347     (p_assignment_id              => p_assignment_id
3348     ,p_object_version_number      => l_object_version_number
3349     ,p_actual_termination_date    => l_actual_termination_date
3350     ,p_last_standard_process_date => l_last_standard_process_date
3351     ,p_assignment_status_type_id  => l_assignment_status_type_id
3352     ,p_effective_start_date       => l_effective_start_date
3353     ,p_effective_end_date         => l_effective_end_date
3354     ,p_asg_future_changes_warning => l_asg_future_changes_warning
3355     ,p_entries_changed_warning    => l_entries_changed_warning
3356     ,p_pay_proposal_warning       => l_pay_proposal_warning
3357     );
3358   --
3359  if g_debug then
3360   hr_utility.set_location(l_proc, 190);
3361  end if;
3362   --
3363   -- When in validation only mode raise the Validate_Enabled exception
3364   --
3365   --
3366   -- Start of API User Hook for the after hook of actual_termination_emp_asg.
3367   -- Local vars are passed in for all OUT parms because the hook needs to
3368   -- be placed before the validate check and therefore before the code that
3369   -- sets all out parms.
3370   --
3371   begin
3372      hr_assignment_bk4.actual_termination_emp_asg_a
3373        (p_assignment_id                 =>  p_assignment_id
3374        ,p_object_version_number         =>  l_object_version_number
3375        ,p_actual_termination_date       =>  l_actual_termination_date
3376        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
3377        ,p_effective_start_date          =>  l_effective_start_date
3378        ,p_effective_end_date            =>  l_effective_end_date
3379        ,p_asg_future_changes_warning    =>  l_asg_future_changes_warning
3380        ,p_entries_changed_warning       =>  l_entries_changed_warning
3381        ,p_pay_proposal_warning          =>  l_pay_proposal_warning
3382        ,p_business_group_id             =>  l_asg_business_group_id
3383        );
3384   exception
3385      when hr_api.cannot_find_prog_unit then
3386        hr_api.cannot_find_prog_unit_error
3387          (p_module_name       => 'ACTUAL_TERMINATION_EMP_ASG',
3388           p_hook_type         => 'AP'
3389          );
3390   end;
3391   --
3392   -- End of API User Hook for the after hook of actual_termination_emp_asg.
3393   --
3394   if p_validate then
3395     raise hr_api.validate_enabled;
3396   end if;
3397   --
3398   -- Set all output arguments
3399   --
3400   p_asg_future_changes_warning := l_asg_future_changes_warning;
3401   p_effective_end_date         := l_effective_end_date;
3402   p_effective_start_date       := l_effective_start_date;
3403   p_entries_changed_warning    := l_entries_changed_warning;
3404   p_pay_proposal_warning       := l_pay_proposal_warning;
3405   p_object_version_number      := l_object_version_number;
3406   --
3407  if g_debug then
3408   hr_utility.set_location(' Leaving:'||l_proc, 200);
3409  end if;
3410 exception
3411   when hr_api.validate_enabled then
3412     --
3413     -- As the Validate_Enabled exception has been raised
3414     -- we must rollback to the savepoint
3415     --
3416     ROLLBACK TO actual_termination_emp_asg;
3417     --
3418     -- Only set output warning arguments
3419     -- (Any key or derived arguments must be set to null
3420     -- when validation only mode is being used.)
3421     --
3422     p_asg_future_changes_warning := l_asg_future_changes_warning;
3423     p_effective_end_date         := null;
3424     p_effective_start_date       := null;
3425     p_entries_changed_warning    := l_entries_changed_warning;
3426     p_pay_proposal_warning       := l_pay_proposal_warning;
3427     p_object_version_number      := p_object_version_number;
3428     --
3429   when others then
3430     --
3431     -- A validation or unexpected error has occurred
3432     --
3433     -- Added as part of fix to bug 632479
3434     --
3435     p_object_version_number := lv_object_version_number;
3436     p_effective_start_date        := null;
3437     p_effective_end_date          := null;
3438     p_asg_future_changes_warning  := null;
3439     p_entries_changed_warning     := null;
3440     p_pay_proposal_warning        := null;
3441 
3442     ROLLBACK TO actual_termination_emp_asg;
3443     raise;
3444     --
3445     -- End of fix.
3446     --
3447 end actual_termination_emp_asg;
3448 --
3449 -- 70.2 change end.
3450 --
3451 -- ----------------------------------------------------------------------------
3452 -- |---------------------< create_secondary_emp_asg >--OLD---------------------|
3453 -- ----------------------------------------------------------------------------
3454 --
3455 -- This is the 'old' interface which now simply calls the
3456 -- 'new' interface and passes nulls for the new parms and
3457 -- assigns local variables to capture the new outs.
3458 --
3459 procedure create_secondary_emp_asg
3460   (p_validate                     in     boolean
3461   ,p_effective_date               in     date
3462   ,p_person_id                    in     number
3463   ,p_organization_id              in     number
3464   ,p_grade_id                     in     number
3465   ,p_position_id                  in     number
3466   ,p_job_id                       in     number
3467   ,p_assignment_status_type_id    in     number
3468   ,p_payroll_id                   in     number
3469   ,p_location_id                  in     number
3470   ,p_supervisor_id                in     number
3471   ,p_special_ceiling_step_id      in     number
3472   ,p_pay_basis_id                 in     number
3473   ,p_assignment_number            in out nocopy varchar2
3474   ,p_change_reason                in     varchar2
3475   ,p_comments                     in     varchar2
3476   ,p_date_probation_end           in     date
3477   ,p_default_code_comb_id         in     number
3478   ,p_employment_category          in     varchar2
3479   ,p_frequency                    in     varchar2
3480   ,p_internal_address_line        in     varchar2
3481   ,p_manager_flag                 in     varchar2
3482   ,p_normal_hours                 in     number
3483   ,p_perf_review_period           in     number
3484   ,p_perf_review_period_frequency in     varchar2
3485   ,p_probation_period             in     number
3486   ,p_probation_unit               in     varchar2
3487   ,p_sal_review_period            in     number
3488   ,p_sal_review_period_frequency  in     varchar2
3489   ,p_set_of_books_id              in     number
3490   ,p_source_type                  in     varchar2
3491   ,p_time_normal_finish           in     varchar2
3492   ,p_time_normal_start            in     varchar2
3493   ,p_bargaining_unit_code         in     varchar2
3494   ,p_labour_union_member_flag     in     varchar2
3495   ,p_hourly_salaried_code         in     varchar2
3496   ,p_ass_attribute_category       in     varchar2
3497   ,p_ass_attribute1               in     varchar2
3498   ,p_ass_attribute2               in     varchar2
3499   ,p_ass_attribute3               in     varchar2
3500   ,p_ass_attribute4               in     varchar2
3501   ,p_ass_attribute5               in     varchar2
3502   ,p_ass_attribute6               in     varchar2
3503   ,p_ass_attribute7               in     varchar2
3504   ,p_ass_attribute8               in     varchar2
3505   ,p_ass_attribute9               in     varchar2
3506   ,p_ass_attribute10              in     varchar2
3507   ,p_ass_attribute11              in     varchar2
3508   ,p_ass_attribute12              in     varchar2
3509   ,p_ass_attribute13              in     varchar2
3510   ,p_ass_attribute14              in     varchar2
3511   ,p_ass_attribute15              in     varchar2
3512   ,p_ass_attribute16              in     varchar2
3513   ,p_ass_attribute17              in     varchar2
3514   ,p_ass_attribute18              in     varchar2
3515   ,p_ass_attribute19              in     varchar2
3516   ,p_ass_attribute20              in     varchar2
3517   ,p_ass_attribute21              in     varchar2
3518   ,p_ass_attribute22              in     varchar2
3519   ,p_ass_attribute23              in     varchar2
3520   ,p_ass_attribute24              in     varchar2
3521   ,p_ass_attribute25              in     varchar2
3522   ,p_ass_attribute26              in     varchar2
3523   ,p_ass_attribute27              in     varchar2
3524   ,p_ass_attribute28              in     varchar2
3525   ,p_ass_attribute29              in     varchar2
3526   ,p_ass_attribute30              in     varchar2
3527   ,p_title                        in     varchar2
3528   ,p_scl_segment1                 in     varchar2
3529   ,p_scl_segment2                 in     varchar2
3530   ,p_scl_segment3                 in     varchar2
3531   ,p_scl_segment4                 in     varchar2
3532   ,p_scl_segment5                 in     varchar2
3533   ,p_scl_segment6                 in     varchar2
3534   ,p_scl_segment7                 in     varchar2
3535   ,p_scl_segment8                 in     varchar2
3536   ,p_scl_segment9                 in     varchar2
3537   ,p_scl_segment10                in     varchar2
3538   ,p_scl_segment11                in     varchar2
3539   ,p_scl_segment12                in     varchar2
3540   ,p_scl_segment13                in     varchar2
3541   ,p_scl_segment14                in     varchar2
3542   ,p_scl_segment15                in     varchar2
3543   ,p_scl_segment16                in     varchar2
3544   ,p_scl_segment17                in     varchar2
3545   ,p_scl_segment18                in     varchar2
3546   ,p_scl_segment19                in     varchar2
3547   ,p_scl_segment20                in     varchar2
3548   ,p_scl_segment21                in     varchar2
3549   ,p_scl_segment22                in     varchar2
3550   ,p_scl_segment23                in     varchar2
3551   ,p_scl_segment24                in     varchar2
3552   ,p_scl_segment25                in     varchar2
3553   ,p_scl_segment26                in     varchar2
3554   ,p_scl_segment27                in     varchar2
3555   ,p_scl_segment28                in     varchar2
3556   ,p_scl_segment29                in     varchar2
3557   ,p_scl_segment30                in     varchar2
3558    -- Bug 944911
3559    -- Added scl_concat_segments and amended scl_concatenated_segments
3560    -- to be an out instead of in out
3561   ,p_scl_concat_segments    	  in 	 varchar2
3562   ,p_pgp_segment1                 in     varchar2
3563   ,p_pgp_segment2                 in     varchar2
3564   ,p_pgp_segment3                 in     varchar2
3565   ,p_pgp_segment4                 in     varchar2
3566   ,p_pgp_segment5                 in     varchar2
3567   ,p_pgp_segment6                 in     varchar2
3568   ,p_pgp_segment7                 in     varchar2
3569   ,p_pgp_segment8                 in     varchar2
3570   ,p_pgp_segment9                 in     varchar2
3571   ,p_pgp_segment10                in     varchar2
3572   ,p_pgp_segment11                in     varchar2
3573   ,p_pgp_segment12                in     varchar2
3574   ,p_pgp_segment13                in     varchar2
3575   ,p_pgp_segment14                in     varchar2
3576   ,p_pgp_segment15                in     varchar2
3577   ,p_pgp_segment16                in     varchar2
3578   ,p_pgp_segment17                in     varchar2
3579   ,p_pgp_segment18                in     varchar2
3580   ,p_pgp_segment19                in     varchar2
3581   ,p_pgp_segment20                in     varchar2
3582   ,p_pgp_segment21                in     varchar2
3583   ,p_pgp_segment22                in     varchar2
3584   ,p_pgp_segment23                in     varchar2
3585   ,p_pgp_segment24                in     varchar2
3586   ,p_pgp_segment25                in     varchar2
3587   ,p_pgp_segment26                in     varchar2
3588   ,p_pgp_segment27                in     varchar2
3589   ,p_pgp_segment28                in     varchar2
3590   ,p_pgp_segment29                in     varchar2
3591   ,p_pgp_segment30                in     varchar2
3592 -- Bug 944911
3593 -- Made p_group_name to be out param
3594 -- and add p_concat_segment to be IN
3595 -- in case of sec_asg alone made p_pgp_concat_segments as in param
3596   ,p_pgp_concat_segments	  in     varchar2
3597   ,p_supervisor_assignment_id     in     number
3598   ,p_group_name                      out nocopy varchar2
3599 -- Bug 944911
3600 -- Added scl_concat_segments and amended scl_concatenated_segments
3601 -- to be an out instead of in out
3602 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
3603 -- This has been done through out the procedures
3604   ,p_concatenated_segments           out nocopy varchar2
3605   ,p_assignment_id                   out nocopy number
3606   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
3607   ,p_people_group_id              in out nocopy number  -- bug 2359997
3608   ,p_object_version_number           out nocopy number
3609   ,p_effective_start_date            out nocopy date
3610   ,p_effective_end_date              out nocopy date
3611   ,p_assignment_sequence             out nocopy number
3612   ,p_comment_id                      out nocopy number
3613   ,p_other_manager_warning           out nocopy boolean
3614   ) is
3615   --
3616   -- Declare cursors and local variables
3617   --
3618   -- Out variables
3619   --
3620   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
3621   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
3622   := p_soft_coding_keyflex_id;  -- bug 2359997
3623   l_people_group_id        per_all_assignments_f.people_group_id%TYPE
3624   := p_people_group_id; -- bug 2359997
3625   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
3626   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
3627   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
3628   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
3629   l_assignment_number      per_all_assignments_f.assignment_number%TYPE;
3630   l_comment_id             per_all_assignments_f.comment_id%TYPE;
3631   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3632   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3633   l_group_name             pay_people_groups.group_name%TYPE;
3634   l_old_group_name         pay_people_groups.group_name%TYPE;
3635   l_other_manager_warning  boolean;
3636   l_effective_date         date;
3637   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
3638   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
3639   l_scl_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3640   l_grp_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3641   --
3642   l_business_group_id    per_business_groups.business_group_id%TYPE;
3643   l_legislation_code     per_business_groups.legislation_code%TYPE;
3644   l_period_of_service_id per_all_assignments_f.period_of_service_id%TYPE;
3645   l_proc                 varchar2(72);
3646   l_session_id           number;
3647   l_cagr_grade_def_id    number;
3648   l_cagr_concatenated_segments number;
3649   --
3650 --
3651 begin
3652 --
3653  if g_debug then
3654   l_proc := g_package||'create_secondary_emp_asg';
3655   hr_utility.set_location('Entering:'|| l_proc, 5);
3656  end if;
3657   --
3658   l_assignment_number := p_assignment_number;
3659   --
3660   -- Call the new code
3661   --
3662   hr_assignment_api.create_secondary_emp_asg(
3663    p_validate                     => p_validate
3664   ,p_effective_date               => p_effective_date
3665   ,p_person_id                    => p_person_id
3666   ,p_organization_id              => p_organization_id
3667   ,p_grade_id                     => p_grade_id
3668   ,p_position_id                  => p_position_id
3669   ,p_job_id                       => p_job_id
3670   ,p_assignment_status_type_id    => p_assignment_status_type_id
3671   ,p_payroll_id                   => p_payroll_id
3672   ,p_location_id                  => p_location_id
3673   ,p_supervisor_id                => p_supervisor_id
3674   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
3675   ,p_pay_basis_id                 => p_pay_basis_id
3676   ,p_assignment_number            => l_assignment_number
3677   ,p_change_reason                => p_change_reason
3678   ,p_comments                     => p_comments
3679   ,p_date_probation_end           => p_date_probation_end
3680   ,p_default_code_comb_id         => p_default_code_comb_id
3681   ,p_employment_category          => p_employment_category
3682   ,p_frequency                    => p_frequency
3683   ,p_internal_address_line        => p_internal_address_line
3684   ,p_manager_flag                 => p_manager_flag
3685   ,p_normal_hours                 => p_normal_hours
3686   ,p_perf_review_period           => p_perf_review_period
3687   ,p_perf_review_period_frequency => p_perf_review_period_frequency
3688   ,p_probation_period             => p_probation_period
3689   ,p_probation_unit               => p_probation_unit
3690   ,p_sal_review_period            => p_sal_review_period
3691   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
3692   ,p_set_of_books_id              => p_set_of_books_id
3693   ,p_source_type                  => p_source_type
3694   ,p_time_normal_finish           => p_time_normal_finish
3695   ,p_time_normal_start            => p_time_normal_start
3696   ,p_bargaining_unit_code         => p_bargaining_unit_code
3697   ,p_labour_union_member_flag     => p_labour_union_member_flag
3698   ,p_hourly_salaried_code         => p_hourly_salaried_code
3699   ,p_ass_attribute_category       => p_ass_attribute_category
3700   ,p_ass_attribute1               => p_ass_attribute1
3701   ,p_ass_attribute2               => p_ass_attribute2
3702   ,p_ass_attribute3               => p_ass_attribute3
3703   ,p_ass_attribute4               => p_ass_attribute4
3704   ,p_ass_attribute5               => p_ass_attribute5
3705   ,p_ass_attribute6               => p_ass_attribute6
3706   ,p_ass_attribute7               => p_ass_attribute7
3707   ,p_ass_attribute8               => p_ass_attribute8
3708   ,p_ass_attribute9               => p_ass_attribute9
3709   ,p_ass_attribute10              => p_ass_attribute10
3710   ,p_ass_attribute11              => p_ass_attribute11
3711   ,p_ass_attribute12              => p_ass_attribute12
3712   ,p_ass_attribute13              => p_ass_attribute13
3713   ,p_ass_attribute14              => p_ass_attribute14
3714   ,p_ass_attribute15              => p_ass_attribute15
3715   ,p_ass_attribute16              => p_ass_attribute16
3716   ,p_ass_attribute17              => p_ass_attribute17
3717   ,p_ass_attribute18              => p_ass_attribute18
3718   ,p_ass_attribute19              => p_ass_attribute19
3719   ,p_ass_attribute20              => p_ass_attribute20
3720   ,p_ass_attribute21              => p_ass_attribute21
3721   ,p_ass_attribute22              => p_ass_attribute22
3722   ,p_ass_attribute23              => p_ass_attribute23
3723   ,p_ass_attribute24              => p_ass_attribute24
3724   ,p_ass_attribute25              => p_ass_attribute25
3725   ,p_ass_attribute26              => p_ass_attribute26
3726   ,p_ass_attribute27              => p_ass_attribute27
3727   ,p_ass_attribute28              => p_ass_attribute28
3728   ,p_ass_attribute29              => p_ass_attribute29
3729   ,p_ass_attribute30              => p_ass_attribute30
3730   ,p_title                        => p_title
3731   ,p_scl_segment1                 => p_scl_segment1
3732   ,p_scl_segment2                 => p_scl_segment2
3733   ,p_scl_segment3                 => p_scl_segment3
3734   ,p_scl_segment4                 => p_scl_segment4
3735   ,p_scl_segment5                 => p_scl_segment5
3736   ,p_scl_segment6                 => p_scl_segment6
3737   ,p_scl_segment7                 => p_scl_segment7
3738   ,p_scl_segment8                 => p_scl_segment8
3739   ,p_scl_segment9                 => p_scl_segment9
3740   ,p_scl_segment10                => p_scl_segment10
3741   ,p_scl_segment11                => p_scl_segment11
3742   ,p_scl_segment12                => p_scl_segment12
3743   ,p_scl_segment13                => p_scl_segment13
3744   ,p_scl_segment14                => p_scl_segment14
3745   ,p_scl_segment15                => p_scl_segment15
3746   ,p_scl_segment16                => p_scl_segment16
3747   ,p_scl_segment17                => p_scl_segment17
3748   ,p_scl_segment18                => p_scl_segment18
3749   ,p_scl_segment19                => p_scl_segment19
3750   ,p_scl_segment20                => p_scl_segment20
3751   ,p_scl_segment21                => p_scl_segment21
3752   ,p_scl_segment22                => p_scl_segment22
3753   ,p_scl_segment23                => p_scl_segment23
3754   ,p_scl_segment24                => p_scl_segment24
3755   ,p_scl_segment25                => p_scl_segment25
3756   ,p_scl_segment26                => p_scl_segment26
3757   ,p_scl_segment27                => p_scl_segment27
3758   ,p_scl_segment28                => p_scl_segment28
3759   ,p_scl_segment29                => p_scl_segment29
3760   ,p_scl_segment30                => p_scl_segment30
3761   ,p_scl_concat_segments          => p_scl_concat_segments
3762   ,p_pgp_segment1                 => p_pgp_segment1
3763   ,p_pgp_segment2                 => p_pgp_segment2
3764   ,p_pgp_segment3                 => p_pgp_segment3
3765   ,p_pgp_segment4                 => p_pgp_segment4
3766   ,p_pgp_segment5                 => p_pgp_segment5
3767   ,p_pgp_segment6                 => p_pgp_segment6
3768   ,p_pgp_segment7                 => p_pgp_segment7
3769   ,p_pgp_segment8                 => p_pgp_segment8
3770   ,p_pgp_segment9                 => p_pgp_segment9
3771   ,p_pgp_segment10                => p_pgp_segment10
3772   ,p_pgp_segment11                => p_pgp_segment11
3773   ,p_pgp_segment12                => p_pgp_segment12
3774   ,p_pgp_segment13                => p_pgp_segment13
3775   ,p_pgp_segment14                => p_pgp_segment14
3776   ,p_pgp_segment15                => p_pgp_segment15
3777   ,p_pgp_segment16                => p_pgp_segment16
3778   ,p_pgp_segment17                => p_pgp_segment17
3779   ,p_pgp_segment18                => p_pgp_segment18
3780   ,p_pgp_segment19                => p_pgp_segment19
3781   ,p_pgp_segment20                => p_pgp_segment20
3782   ,p_pgp_segment21                => p_pgp_segment21
3783   ,p_pgp_segment22                => p_pgp_segment22
3784   ,p_pgp_segment23                => p_pgp_segment23
3785   ,p_pgp_segment24                => p_pgp_segment24
3786   ,p_pgp_segment25                => p_pgp_segment25
3787   ,p_pgp_segment26                => p_pgp_segment26
3788   ,p_pgp_segment27                => p_pgp_segment27
3789   ,p_pgp_segment28                => p_pgp_segment28
3790   ,p_pgp_segment29                => p_pgp_segment29
3791   ,p_pgp_segment30                => p_pgp_segment30
3792   ,p_pgp_concat_segments          => p_pgp_concat_segments
3793   ,p_contract_id                  => null
3794   ,p_establishment_id             => null
3795   ,p_collective_agreement_id      => null
3796   ,p_cagr_id_flex_num             => null
3797   ,p_cag_segment1                 => null
3798   ,p_cag_segment2                 => null
3799   ,p_cag_segment3                 => null
3800   ,p_cag_segment4                 => null
3801   ,p_cag_segment5                 => null
3802   ,p_cag_segment6                 => null
3803   ,p_cag_segment7                 => null
3804   ,p_cag_segment8                 => null
3805   ,p_cag_segment9                 => null
3806   ,p_cag_segment10                => null
3807   ,p_cag_segment11                => null
3808   ,p_cag_segment12                => null
3809   ,p_cag_segment13                => null
3810   ,p_cag_segment14                => null
3811   ,p_cag_segment15                => null
3812   ,p_cag_segment16                => null
3813   ,p_cag_segment17                => null
3814   ,p_cag_segment18                => null
3815   ,p_cag_segment19                => null
3816   ,p_cag_segment20                => null
3817   ,p_grade_ladder_pgm_id          => null
3818   ,p_supervisor_assignment_id     => null
3819   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
3820   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
3821   ,p_assignment_id                => l_assignment_id
3822   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
3823   ,p_people_group_id              => l_people_group_id
3824   ,p_object_version_number        => l_object_version_number
3825   ,p_effective_start_date         => l_effective_start_date
3826   ,p_effective_end_date           => l_effective_end_date
3827   ,p_assignment_sequence          => l_assignment_sequence
3828   ,p_comment_id                   => l_comment_id
3829   ,p_concatenated_segments        => l_concatenated_segments
3830   ,p_group_name                   => l_group_name
3831   ,p_other_manager_warning        => l_other_manager_warning
3832    );
3833   --
3834   -- Set remaining output arguments
3835   --
3836   p_assignment_id          := l_assignment_id;
3837   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
3838   p_people_group_id        := l_people_group_id;
3839   p_object_version_number  := l_object_version_number;
3840   p_effective_start_date   := l_effective_start_date;
3841   p_effective_end_date     := l_effective_end_date;
3842   p_assignment_sequence    := l_assignment_sequence;
3843   p_comment_id             := l_comment_id;
3844   p_concatenated_segments  := l_concatenated_segments;
3845   p_group_name             := l_group_name;
3846   p_other_manager_warning  := l_other_manager_warning;
3847   --
3848  if g_debug then
3849   hr_utility.set_location(' Leaving:'||l_proc, 50);
3850  end if;
3851 end create_secondary_emp_asg;
3852 --
3853 -- ----------------------------------------------------------------------------
3854 -- |---------------------< create_secondary_emp_asg >-NEW----------------------|
3855 -- ----------------------------------------------------------------------------
3856 --
3857 -- This is the new interface that contains the extra parms
3858 -- for collective agreements and contracts.
3859 -- added new parameters notice_period, units, employee_category,
3860 -- work_at_home and job_source on 05-OCT-01
3861 --
3862 procedure create_secondary_emp_asg
3863   (p_validate                     in     boolean
3864   ,p_effective_date               in     date
3865   ,p_person_id                    in     number
3866   ,p_organization_id              in     number
3867   ,p_grade_id                     in     number
3868   ,p_position_id                  in     number
3869   ,p_job_id                       in     number
3870   ,p_assignment_status_type_id    in     number
3871   ,p_payroll_id                   in     number
3872   ,p_location_id                  in     number
3873   ,p_supervisor_id                in     number
3874   ,p_special_ceiling_step_id      in     number
3875   ,p_pay_basis_id                 in     number
3876   ,p_assignment_number            in out nocopy varchar2
3877   ,p_change_reason                in     varchar2
3878   ,p_comments                     in     varchar2
3879   ,p_date_probation_end           in     date
3880   ,p_default_code_comb_id         in     number
3881   ,p_employment_category          in     varchar2
3882   ,p_frequency                    in     varchar2
3883   ,p_internal_address_line        in     varchar2
3884   ,p_manager_flag                 in     varchar2
3885   ,p_normal_hours                 in     number
3886   ,p_perf_review_period           in     number
3887   ,p_perf_review_period_frequency in     varchar2
3888   ,p_probation_period             in     number
3889   ,p_probation_unit               in     varchar2
3890   ,p_sal_review_period            in     number
3891   ,p_sal_review_period_frequency  in     varchar2
3892   ,p_set_of_books_id              in     number
3893   ,p_source_type                  in     varchar2
3894   ,p_time_normal_finish           in     varchar2
3895   ,p_time_normal_start            in     varchar2
3896   ,p_bargaining_unit_code         in     varchar2
3897   ,p_labour_union_member_flag     in     varchar2
3898   ,p_hourly_salaried_code         in     varchar2
3899   ,p_ass_attribute_category       in     varchar2
3900   ,p_ass_attribute1               in     varchar2
3901   ,p_ass_attribute2               in     varchar2
3902   ,p_ass_attribute3               in     varchar2
3903   ,p_ass_attribute4               in     varchar2
3904   ,p_ass_attribute5               in     varchar2
3905   ,p_ass_attribute6               in     varchar2
3906   ,p_ass_attribute7               in     varchar2
3907   ,p_ass_attribute8               in     varchar2
3908   ,p_ass_attribute9               in     varchar2
3909   ,p_ass_attribute10              in     varchar2
3910   ,p_ass_attribute11              in     varchar2
3911   ,p_ass_attribute12              in     varchar2
3912   ,p_ass_attribute13              in     varchar2
3913   ,p_ass_attribute14              in     varchar2
3914   ,p_ass_attribute15              in     varchar2
3915   ,p_ass_attribute16              in     varchar2
3916   ,p_ass_attribute17              in     varchar2
3917   ,p_ass_attribute18              in     varchar2
3918   ,p_ass_attribute19              in     varchar2
3919   ,p_ass_attribute20              in     varchar2
3920   ,p_ass_attribute21              in     varchar2
3921   ,p_ass_attribute22              in     varchar2
3922   ,p_ass_attribute23              in     varchar2
3923   ,p_ass_attribute24              in     varchar2
3924   ,p_ass_attribute25              in     varchar2
3925   ,p_ass_attribute26              in     varchar2
3926   ,p_ass_attribute27              in     varchar2
3927   ,p_ass_attribute28              in     varchar2
3928   ,p_ass_attribute29              in     varchar2
3929   ,p_ass_attribute30              in     varchar2
3930   ,p_title                        in     varchar2
3931   ,p_scl_segment1                 in     varchar2
3932   ,p_scl_segment2                 in     varchar2
3933   ,p_scl_segment3                 in     varchar2
3934   ,p_scl_segment4                 in     varchar2
3935   ,p_scl_segment5                 in     varchar2
3936   ,p_scl_segment6                 in     varchar2
3937   ,p_scl_segment7                 in     varchar2
3938   ,p_scl_segment8                 in     varchar2
3939   ,p_scl_segment9                 in     varchar2
3940   ,p_scl_segment10                in     varchar2
3941   ,p_scl_segment11                in     varchar2
3942   ,p_scl_segment12                in     varchar2
3943   ,p_scl_segment13                in     varchar2
3944   ,p_scl_segment14                in     varchar2
3945   ,p_scl_segment15                in     varchar2
3946   ,p_scl_segment16                in     varchar2
3947   ,p_scl_segment17                in     varchar2
3948   ,p_scl_segment18                in     varchar2
3949   ,p_scl_segment19                in     varchar2
3950   ,p_scl_segment20                in     varchar2
3951   ,p_scl_segment21                in     varchar2
3952   ,p_scl_segment22                in     varchar2
3953   ,p_scl_segment23                in     varchar2
3954   ,p_scl_segment24                in     varchar2
3955   ,p_scl_segment25                in     varchar2
3956   ,p_scl_segment26                in     varchar2
3957   ,p_scl_segment27                in     varchar2
3958   ,p_scl_segment28                in     varchar2
3959   ,p_scl_segment29                in     varchar2
3960   ,p_scl_segment30                in     varchar2
3961 -- Bug 944911
3962 -- Added scl_concat_segments and amended scl_concatenated_segments
3963 -- to be an out instead of in out
3964   ,p_scl_concat_segments    	  in 	 varchar2
3965   ,p_pgp_segment1                 in     varchar2
3966   ,p_pgp_segment2                 in     varchar2
3967   ,p_pgp_segment3                 in     varchar2
3968   ,p_pgp_segment4                 in     varchar2
3969   ,p_pgp_segment5                 in     varchar2
3970   ,p_pgp_segment6                 in     varchar2
3971   ,p_pgp_segment7                 in     varchar2
3972   ,p_pgp_segment8                 in     varchar2
3973   ,p_pgp_segment9                 in     varchar2
3974   ,p_pgp_segment10                in     varchar2
3975   ,p_pgp_segment11                in     varchar2
3976   ,p_pgp_segment12                in     varchar2
3977   ,p_pgp_segment13                in     varchar2
3978   ,p_pgp_segment14                in     varchar2
3979   ,p_pgp_segment15                in     varchar2
3980   ,p_pgp_segment16                in     varchar2
3981   ,p_pgp_segment17                in     varchar2
3982   ,p_pgp_segment18                in     varchar2
3983   ,p_pgp_segment19                in     varchar2
3984   ,p_pgp_segment20                in     varchar2
3985   ,p_pgp_segment21                in     varchar2
3986   ,p_pgp_segment22                in     varchar2
3987   ,p_pgp_segment23                in     varchar2
3988   ,p_pgp_segment24                in     varchar2
3989   ,p_pgp_segment25                in     varchar2
3990   ,p_pgp_segment26                in     varchar2
3991   ,p_pgp_segment27                in     varchar2
3992   ,p_pgp_segment28                in     varchar2
3993   ,p_pgp_segment29                in     varchar2
3994   ,p_pgp_segment30                in     varchar2
3995 -- Bug 944911
3996 -- Made p_group_name to be out param
3997 -- and add p_concat_segment to be IN
3998 -- in case of sec_asg alone made p_pgp_concat_segments as in param
3999   ,p_pgp_concat_segments	  in     varchar2
4000   ,p_contract_id                  in     number
4001   ,p_establishment_id             in     number
4002   ,p_collective_agreement_id      in     number
4003   ,p_cagr_id_flex_num             in     number
4004   ,p_cag_segment1                 in     varchar2
4005   ,p_cag_segment2                 in     varchar2
4006   ,p_cag_segment3                 in     varchar2
4007   ,p_cag_segment4                 in     varchar2
4008   ,p_cag_segment5                 in     varchar2
4009   ,p_cag_segment6                 in     varchar2
4010   ,p_cag_segment7                 in     varchar2
4011   ,p_cag_segment8                 in     varchar2
4012   ,p_cag_segment9                 in     varchar2
4013   ,p_cag_segment10                in     varchar2
4014   ,p_cag_segment11                in     varchar2
4015   ,p_cag_segment12                in     varchar2
4016   ,p_cag_segment13                in     varchar2
4017   ,p_cag_segment14                in     varchar2
4018   ,p_cag_segment15                in     varchar2
4019   ,p_cag_segment16                in     varchar2
4020   ,p_cag_segment17                in     varchar2
4021   ,p_cag_segment18                in     varchar2
4022   ,p_cag_segment19                in     varchar2
4023   ,p_cag_segment20                in     varchar2
4024   ,p_notice_period		  in	 number
4025   ,p_notice_period_uom		  in     varchar2
4026   ,p_employee_category		  in     varchar2
4027   ,p_work_at_home		  in	 varchar2
4028   ,p_job_post_source_name         in     varchar2
4029   ,p_grade_ladder_pgm_id          in     number
4030   ,p_supervisor_assignment_id     in     number
4031   ,p_group_name                      out nocopy varchar2
4032 -- Bug 944911
4033 -- Added scl_concat_segments and amended scl_concatenated_segments
4034 -- to be an out instead of in out
4035 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
4036 -- This has been done through out the procedures
4037   ,p_concatenated_segments           out nocopy varchar2
4038   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
4039   ,p_cagr_concatenated_segments      out nocopy varchar2
4040   ,p_assignment_id                   out nocopy number
4041   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
4042   ,p_people_group_id              in out nocopy number  -- bug 2359997
4043   ,p_object_version_number           out nocopy number
4044   ,p_effective_start_date            out nocopy date
4045   ,p_effective_end_date              out nocopy date
4046   ,p_assignment_sequence             out nocopy number
4047   ,p_comment_id                      out nocopy number
4048   ,p_other_manager_warning           out nocopy boolean
4049   ) is
4050   --
4051   -- Declare cursors and local variables
4052   --
4053   -- Out variables
4054   --
4055   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
4056   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
4057   := p_soft_coding_keyflex_id;  -- bug 2359997 added initialization
4058   l_people_group_id        per_all_assignments_f.people_group_id%TYPE
4059   := p_people_group_id;    -- bug 2359997 added initialization
4060   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
4061   := p_cagr_grade_def_id;   -- bug 2359997, added this local variable
4062   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
4063   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
4064   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
4065   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
4066   l_assignment_number      per_all_assignments_f.assignment_number%TYPE;
4067   l_comment_id             per_all_assignments_f.comment_id%TYPE;
4068   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
4069   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
4070   l_group_name             pay_people_groups.group_name%TYPE;
4071   l_old_group_name         pay_people_groups.group_name%TYPE;
4072   l_other_manager_warning  boolean;
4073   l_effective_date         date;
4074   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
4075   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
4076   l_scl_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
4077   l_grp_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
4078   l_hourly_salaried_warning boolean;
4079   l_proc                 varchar2(72);
4080 --
4081 begin
4082 --
4083  if g_debug then
4084   l_proc := g_package||'create_secondary_emp_asg';
4085   hr_utility.set_location('Entering:'|| l_proc, 5);
4086  end if;
4087   --
4088   l_assignment_number := p_assignment_number;
4089   --
4090   -- Call the new code
4091   --
4092   hr_assignment_api.create_secondary_emp_asg(
4093    p_validate                     => p_validate
4094   ,p_effective_date               => p_effective_date
4095   ,p_person_id                    => p_person_id
4096   ,p_organization_id              => p_organization_id
4097   ,p_grade_id                     => p_grade_id
4098   ,p_position_id                  => p_position_id
4099   ,p_job_id                       => p_job_id
4100   ,p_assignment_status_type_id    => p_assignment_status_type_id
4101   ,p_payroll_id                   => p_payroll_id
4102   ,p_location_id                  => p_location_id
4103   ,p_supervisor_id                => p_supervisor_id
4104   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
4105   ,p_pay_basis_id                 => p_pay_basis_id
4106   ,p_assignment_number            => l_assignment_number
4107   ,p_change_reason                => p_change_reason
4108   ,p_comments                     => p_comments
4109   ,p_date_probation_end           => p_date_probation_end
4110   ,p_default_code_comb_id         => p_default_code_comb_id
4111   ,p_employment_category          => p_employment_category
4112   ,p_frequency                    => p_frequency
4113   ,p_internal_address_line        => p_internal_address_line
4114   ,p_manager_flag                 => p_manager_flag
4115   ,p_normal_hours                 => p_normal_hours
4116   ,p_perf_review_period           => p_perf_review_period
4117   ,p_perf_review_period_frequency => p_perf_review_period_frequency
4118   ,p_probation_period             => p_probation_period
4119   ,p_probation_unit               => p_probation_unit
4120   ,p_sal_review_period            => p_sal_review_period
4121   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
4122   ,p_set_of_books_id              => p_set_of_books_id
4123   ,p_source_type                  => p_source_type
4124   ,p_time_normal_finish           => p_time_normal_finish
4125   ,p_time_normal_start            => p_time_normal_start
4126   ,p_bargaining_unit_code         => p_bargaining_unit_code
4127   ,p_labour_union_member_flag     => p_labour_union_member_flag
4128   ,p_hourly_salaried_code         => p_hourly_salaried_code
4129   ,p_notice_period                => p_notice_period
4130   ,p_notice_period_uom            => p_notice_period_uom
4131   ,p_employee_category            => p_employee_category
4132   ,p_work_at_home                 => p_work_at_home
4133   ,p_job_post_source_name         => p_job_post_source_name
4134   ,p_ass_attribute_category       => p_ass_attribute_category
4135   ,p_ass_attribute1               => p_ass_attribute1
4136   ,p_ass_attribute2               => p_ass_attribute2
4137   ,p_ass_attribute3               => p_ass_attribute3
4138   ,p_ass_attribute4               => p_ass_attribute4
4139   ,p_ass_attribute5               => p_ass_attribute5
4140   ,p_ass_attribute6               => p_ass_attribute6
4141   ,p_ass_attribute7               => p_ass_attribute7
4142   ,p_ass_attribute8               => p_ass_attribute8
4143   ,p_ass_attribute9               => p_ass_attribute9
4144   ,p_ass_attribute10              => p_ass_attribute10
4145   ,p_ass_attribute11              => p_ass_attribute11
4146   ,p_ass_attribute12              => p_ass_attribute12
4147   ,p_ass_attribute13              => p_ass_attribute13
4148   ,p_ass_attribute14              => p_ass_attribute14
4149   ,p_ass_attribute15              => p_ass_attribute15
4150   ,p_ass_attribute16              => p_ass_attribute16
4151   ,p_ass_attribute17              => p_ass_attribute17
4152   ,p_ass_attribute18              => p_ass_attribute18
4153   ,p_ass_attribute19              => p_ass_attribute19
4154   ,p_ass_attribute20              => p_ass_attribute20
4155   ,p_ass_attribute21              => p_ass_attribute21
4156   ,p_ass_attribute22              => p_ass_attribute22
4157   ,p_ass_attribute23              => p_ass_attribute23
4158   ,p_ass_attribute24              => p_ass_attribute24
4159   ,p_ass_attribute25              => p_ass_attribute25
4160   ,p_ass_attribute26              => p_ass_attribute26
4161   ,p_ass_attribute27              => p_ass_attribute27
4162   ,p_ass_attribute28              => p_ass_attribute28
4163   ,p_ass_attribute29              => p_ass_attribute29
4164   ,p_ass_attribute30              => p_ass_attribute30
4165   ,p_title                        => p_title
4166   ,p_scl_segment1                 => p_scl_segment1
4167   ,p_scl_segment2                 => p_scl_segment2
4168   ,p_scl_segment3                 => p_scl_segment3
4169   ,p_scl_segment4                 => p_scl_segment4
4170   ,p_scl_segment5                 => p_scl_segment5
4171   ,p_scl_segment6                 => p_scl_segment6
4172   ,p_scl_segment7                 => p_scl_segment7
4173   ,p_scl_segment8                 => p_scl_segment8
4174   ,p_scl_segment9                 => p_scl_segment9
4175   ,p_scl_segment10                => p_scl_segment10
4176   ,p_scl_segment11                => p_scl_segment11
4177   ,p_scl_segment12                => p_scl_segment12
4178   ,p_scl_segment13                => p_scl_segment13
4179   ,p_scl_segment14                => p_scl_segment14
4180   ,p_scl_segment15                => p_scl_segment15
4181   ,p_scl_segment16                => p_scl_segment16
4182   ,p_scl_segment17                => p_scl_segment17
4183   ,p_scl_segment18                => p_scl_segment18
4184   ,p_scl_segment19                => p_scl_segment19
4185   ,p_scl_segment20                => p_scl_segment20
4186   ,p_scl_segment21                => p_scl_segment21
4187   ,p_scl_segment22                => p_scl_segment22
4188   ,p_scl_segment23                => p_scl_segment23
4189   ,p_scl_segment24                => p_scl_segment24
4190   ,p_scl_segment25                => p_scl_segment25
4191   ,p_scl_segment26                => p_scl_segment26
4192   ,p_scl_segment27                => p_scl_segment27
4193   ,p_scl_segment28                => p_scl_segment28
4194   ,p_scl_segment29                => p_scl_segment29
4195   ,p_scl_segment30                => p_scl_segment30
4196   ,p_scl_concat_segments          => p_scl_concat_segments
4197   ,p_pgp_segment1                 => p_pgp_segment1
4198   ,p_pgp_segment2                 => p_pgp_segment2
4199   ,p_pgp_segment3                 => p_pgp_segment3
4200   ,p_pgp_segment4                 => p_pgp_segment4
4201   ,p_pgp_segment5                 => p_pgp_segment5
4202   ,p_pgp_segment6                 => p_pgp_segment6
4203   ,p_pgp_segment7                 => p_pgp_segment7
4204   ,p_pgp_segment8                 => p_pgp_segment8
4205   ,p_pgp_segment9                 => p_pgp_segment9
4206   ,p_pgp_segment10                => p_pgp_segment10
4207   ,p_pgp_segment11                => p_pgp_segment11
4208   ,p_pgp_segment12                => p_pgp_segment12
4209   ,p_pgp_segment13                => p_pgp_segment13
4210   ,p_pgp_segment14                => p_pgp_segment14
4211   ,p_pgp_segment15                => p_pgp_segment15
4212   ,p_pgp_segment16                => p_pgp_segment16
4213   ,p_pgp_segment17                => p_pgp_segment17
4214   ,p_pgp_segment18                => p_pgp_segment18
4215   ,p_pgp_segment19                => p_pgp_segment19
4216   ,p_pgp_segment20                => p_pgp_segment20
4217   ,p_pgp_segment21                => p_pgp_segment21
4218   ,p_pgp_segment22                => p_pgp_segment22
4219   ,p_pgp_segment23                => p_pgp_segment23
4220   ,p_pgp_segment24                => p_pgp_segment24
4221   ,p_pgp_segment25                => p_pgp_segment25
4222   ,p_pgp_segment26                => p_pgp_segment26
4223   ,p_pgp_segment27                => p_pgp_segment27
4224   ,p_pgp_segment28                => p_pgp_segment28
4225   ,p_pgp_segment29                => p_pgp_segment29
4226   ,p_pgp_segment30                => p_pgp_segment30
4227   ,p_pgp_concat_segments          => p_pgp_concat_segments
4228   ,p_contract_id                  => p_contract_id
4229   ,p_establishment_id             => p_establishment_id
4230   ,p_collective_agreement_id      => p_collective_agreement_id
4231   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
4232   ,p_cag_segment1                 => p_cag_segment1
4233   ,p_cag_segment2                 => p_cag_segment2
4234   ,p_cag_segment3                 => p_cag_segment3
4235   ,p_cag_segment4                 => p_cag_segment4
4236   ,p_cag_segment5                 => p_cag_segment5
4237   ,p_cag_segment6                 => p_cag_segment6
4238   ,p_cag_segment7                 => p_cag_segment7
4239   ,p_cag_segment8                 => p_cag_segment8
4240   ,p_cag_segment9                 => p_cag_segment9
4241   ,p_cag_segment10                => p_cag_segment10
4242   ,p_cag_segment11                => p_cag_segment11
4243   ,p_cag_segment12                => p_cag_segment12
4244   ,p_cag_segment13                => p_cag_segment13
4245   ,p_cag_segment14                => p_cag_segment14
4246   ,p_cag_segment15                => p_cag_segment15
4247   ,p_cag_segment16                => p_cag_segment16
4248   ,p_cag_segment17                => p_cag_segment17
4249   ,p_cag_segment18                => p_cag_segment18
4250   ,p_cag_segment19                => p_cag_segment19
4251   ,p_cag_segment20                => p_cag_segment20
4252   ,p_cagr_grade_def_id            => l_cagr_grade_def_id -- bug 2359997
4253   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
4254   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
4255   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
4256   ,p_assignment_id                => l_assignment_id
4257   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
4258   ,p_people_group_id              => l_people_group_id
4259   ,p_object_version_number        => l_object_version_number
4260   ,p_effective_start_date         => l_effective_start_date
4261   ,p_effective_end_date           => l_effective_end_date
4262   ,p_assignment_sequence          => l_assignment_sequence
4263   ,p_comment_id                   => l_comment_id
4264   ,p_concatenated_segments        => l_concatenated_segments
4265   ,p_group_name                   => l_group_name
4266   ,p_other_manager_warning        => l_other_manager_warning
4267   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
4268    );
4269   --
4270   -- Set remaining output arguments
4271   --
4272   p_assignment_id           := l_assignment_id;
4273   p_soft_coding_keyflex_id  := l_soft_coding_keyflex_id;
4274   p_people_group_id         := l_people_group_id;
4275   p_cagr_grade_def_id       := l_cagr_grade_def_id;  -- bug 2359997 added
4276   p_object_version_number   := l_object_version_number;
4277   p_effective_start_date    := l_effective_start_date;
4278   p_effective_end_date      := l_effective_end_date;
4279   p_assignment_sequence     := l_assignment_sequence;
4280   p_comment_id              := l_comment_id;
4281   p_concatenated_segments   := l_concatenated_segments;
4282   p_group_name              := l_group_name;
4283   p_other_manager_warning   := l_other_manager_warning;
4284   --
4285  if g_debug then
4286   hr_utility.set_location(' Leaving:'||l_proc, 50);
4287  end if;
4288 end create_secondary_emp_asg;
4289 --
4290 -- ----------------------------------------------------------------------------
4291 -- |---------------------< create_secondary_emp_asg >-NEW2---------------------|
4292 -- ----------------------------------------------------------------------------
4293 --
4294 --   This is the new Overloded procedure to include p_hourly_salaried_warning
4295 --   parameter
4296 --
4297 procedure create_secondary_emp_asg
4298   (p_validate                     in     boolean
4299   ,p_effective_date               in     date
4300   ,p_person_id                    in     number
4301   ,p_organization_id              in     number
4302   ,p_grade_id                     in     number
4303   ,p_position_id                  in     number
4304   ,p_job_id                       in     number
4305   ,p_assignment_status_type_id    in     number
4306   ,p_payroll_id                   in     number
4307   ,p_location_id                  in     number
4308   ,p_supervisor_id                in     number
4309   ,p_special_ceiling_step_id      in     number
4310   ,p_pay_basis_id                 in     number
4311   ,p_assignment_number            in out nocopy varchar2
4312   ,p_change_reason                in     varchar2
4313   ,p_comments                     in     varchar2
4314   ,p_date_probation_end           in     date
4315   ,p_default_code_comb_id         in     number
4316   ,p_employment_category          in     varchar2
4317   ,p_frequency                    in     varchar2
4318   ,p_internal_address_line        in     varchar2
4319   ,p_manager_flag                 in     varchar2
4320   ,p_normal_hours                 in     number
4321   ,p_perf_review_period           in     number
4322   ,p_perf_review_period_frequency in     varchar2
4323   ,p_probation_period             in     number
4324   ,p_probation_unit               in     varchar2
4325   ,p_sal_review_period            in     number
4326   ,p_sal_review_period_frequency  in     varchar2
4327   ,p_set_of_books_id              in     number
4328   ,p_source_type                  in     varchar2
4329   ,p_time_normal_finish           in     varchar2
4330   ,p_time_normal_start            in     varchar2
4331   ,p_bargaining_unit_code         in     varchar2
4332   ,p_labour_union_member_flag     in     varchar2
4333   ,p_hourly_salaried_code         in     varchar2
4334   ,p_ass_attribute_category       in     varchar2
4335   ,p_ass_attribute1               in     varchar2
4336   ,p_ass_attribute2               in     varchar2
4337   ,p_ass_attribute3               in     varchar2
4338   ,p_ass_attribute4               in     varchar2
4339   ,p_ass_attribute5               in     varchar2
4340   ,p_ass_attribute6               in     varchar2
4341   ,p_ass_attribute7               in     varchar2
4342   ,p_ass_attribute8               in     varchar2
4343   ,p_ass_attribute9               in     varchar2
4344   ,p_ass_attribute10              in     varchar2
4345   ,p_ass_attribute11              in     varchar2
4346   ,p_ass_attribute12              in     varchar2
4347   ,p_ass_attribute13              in     varchar2
4348   ,p_ass_attribute14              in     varchar2
4349   ,p_ass_attribute15              in     varchar2
4350   ,p_ass_attribute16              in     varchar2
4351   ,p_ass_attribute17              in     varchar2
4352   ,p_ass_attribute18              in     varchar2
4353   ,p_ass_attribute19              in     varchar2
4354   ,p_ass_attribute20              in     varchar2
4355   ,p_ass_attribute21              in     varchar2
4356   ,p_ass_attribute22              in     varchar2
4357   ,p_ass_attribute23              in     varchar2
4358   ,p_ass_attribute24              in     varchar2
4359   ,p_ass_attribute25              in     varchar2
4360   ,p_ass_attribute26              in     varchar2
4361   ,p_ass_attribute27              in     varchar2
4362   ,p_ass_attribute28              in     varchar2
4363   ,p_ass_attribute29              in     varchar2
4364   ,p_ass_attribute30              in     varchar2
4365   ,p_title                        in     varchar2
4366   ,p_scl_segment1                 in     varchar2
4367   ,p_scl_segment2                 in     varchar2
4368   ,p_scl_segment3                 in     varchar2
4369   ,p_scl_segment4                 in     varchar2
4370   ,p_scl_segment5                 in     varchar2
4371   ,p_scl_segment6                 in     varchar2
4372   ,p_scl_segment7                 in     varchar2
4373   ,p_scl_segment8                 in     varchar2
4374   ,p_scl_segment9                 in     varchar2
4375   ,p_scl_segment10                in     varchar2
4376   ,p_scl_segment11                in     varchar2
4377   ,p_scl_segment12                in     varchar2
4378   ,p_scl_segment13                in     varchar2
4379   ,p_scl_segment14                in     varchar2
4380   ,p_scl_segment15                in     varchar2
4381   ,p_scl_segment16                in     varchar2
4382   ,p_scl_segment17                in     varchar2
4383   ,p_scl_segment18                in     varchar2
4384   ,p_scl_segment19                in     varchar2
4385   ,p_scl_segment20                in     varchar2
4386   ,p_scl_segment21                in     varchar2
4387   ,p_scl_segment22                in     varchar2
4388   ,p_scl_segment23                in     varchar2
4389   ,p_scl_segment24                in     varchar2
4390   ,p_scl_segment25                in     varchar2
4391   ,p_scl_segment26                in     varchar2
4392   ,p_scl_segment27                in     varchar2
4393   ,p_scl_segment28                in     varchar2
4394   ,p_scl_segment29                in     varchar2
4395   ,p_scl_segment30                in     varchar2
4396 -- Bug 944911
4397 -- Added scl_concat_segments and amended scl_concatenated_segments
4398 -- to be an out instead of in out
4399   ,p_scl_concat_segments    	  in 	 varchar2
4400   ,p_pgp_segment1                 in     varchar2
4401   ,p_pgp_segment2                 in     varchar2
4402   ,p_pgp_segment3                 in     varchar2
4403   ,p_pgp_segment4                 in     varchar2
4404   ,p_pgp_segment5                 in     varchar2
4405   ,p_pgp_segment6                 in     varchar2
4406   ,p_pgp_segment7                 in     varchar2
4407   ,p_pgp_segment8                 in     varchar2
4408   ,p_pgp_segment9                 in     varchar2
4409   ,p_pgp_segment10                in     varchar2
4410   ,p_pgp_segment11                in     varchar2
4411   ,p_pgp_segment12                in     varchar2
4412   ,p_pgp_segment13                in     varchar2
4413   ,p_pgp_segment14                in     varchar2
4414   ,p_pgp_segment15                in     varchar2
4415   ,p_pgp_segment16                in     varchar2
4416   ,p_pgp_segment17                in     varchar2
4417   ,p_pgp_segment18                in     varchar2
4418   ,p_pgp_segment19                in     varchar2
4419   ,p_pgp_segment20                in     varchar2
4420   ,p_pgp_segment21                in     varchar2
4421   ,p_pgp_segment22                in     varchar2
4422   ,p_pgp_segment23                in     varchar2
4423   ,p_pgp_segment24                in     varchar2
4424   ,p_pgp_segment25                in     varchar2
4425   ,p_pgp_segment26                in     varchar2
4426   ,p_pgp_segment27                in     varchar2
4427   ,p_pgp_segment28                in     varchar2
4428   ,p_pgp_segment29                in     varchar2
4429   ,p_pgp_segment30                in     varchar2
4430 -- Bug 944911
4431 -- Made p_group_name to be out param
4432 -- and add p_concat_segment to be IN
4433 -- in case of sec_asg alone made p_pgp_concat_segments as in param
4434   ,p_pgp_concat_segments	  in     varchar2
4435   ,p_contract_id                  in     number
4436   ,p_establishment_id             in     number
4437   ,p_collective_agreement_id      in     number
4438   ,p_cagr_id_flex_num             in     number
4439   ,p_cag_segment1                 in     varchar2
4440   ,p_cag_segment2                 in     varchar2
4441   ,p_cag_segment3                 in     varchar2
4442   ,p_cag_segment4                 in     varchar2
4443   ,p_cag_segment5                 in     varchar2
4444   ,p_cag_segment6                 in     varchar2
4445   ,p_cag_segment7                 in     varchar2
4446   ,p_cag_segment8                 in     varchar2
4447   ,p_cag_segment9                 in     varchar2
4448   ,p_cag_segment10                in     varchar2
4449   ,p_cag_segment11                in     varchar2
4450   ,p_cag_segment12                in     varchar2
4451   ,p_cag_segment13                in     varchar2
4452   ,p_cag_segment14                in     varchar2
4453   ,p_cag_segment15                in     varchar2
4454   ,p_cag_segment16                in     varchar2
4455   ,p_cag_segment17                in     varchar2
4456   ,p_cag_segment18                in     varchar2
4457   ,p_cag_segment19                in     varchar2
4458   ,p_cag_segment20                in     varchar2
4459   ,p_notice_period		  in	 number
4460   ,p_notice_period_uom		  in     varchar2
4461   ,p_employee_category		  in     varchar2
4462   ,p_work_at_home		  in	 varchar2
4463   ,p_job_post_source_name         in     varchar2
4464   ,p_grade_ladder_pgm_id          in     number
4465   ,p_supervisor_assignment_id     in     number
4466   ,p_group_name                      out nocopy varchar2
4467 -- Bug 944911
4468 -- Added scl_concat_segments and amended scl_concatenated_segments
4469 -- to be an out instead of in out
4470 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
4471 -- This has been done through out the procedures
4472   ,p_concatenated_segments           out nocopy varchar2
4473   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
4474   ,p_cagr_concatenated_segments      out nocopy varchar2
4475   ,p_assignment_id                   out nocopy number
4476   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
4477   ,p_people_group_id              in out nocopy number  -- bug 2359997
4478   ,p_object_version_number           out nocopy number
4479   ,p_effective_start_date            out nocopy date
4480   ,p_effective_end_date              out nocopy date
4481   ,p_assignment_sequence             out nocopy number
4482   ,p_comment_id                      out nocopy number
4483   ,p_other_manager_warning           out nocopy boolean
4484   ,p_hourly_salaried_warning         out nocopy boolean
4485   ) is
4486   --
4487   -- Declare cursors and local variables
4488   --
4489   -- Out variables
4490   --
4491   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
4492   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
4493   := p_soft_coding_keyflex_id;
4494   l_people_group_id         per_all_assignments_f.people_group_id%TYPE
4495   := p_people_group_id;
4496   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
4497   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
4498   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
4499   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
4500   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
4501   l_comment_id              per_all_assignments_f.comment_id%TYPE;
4502   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4503   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4504   l_group_name              pay_people_groups.group_name%TYPE;
4505   l_old_group_name          pay_people_groups.group_name%TYPE;
4506   l_other_manager_warning   boolean;
4507   l_hourly_salaried_warning boolean;
4508   l_effective_date          date;
4509   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
4510   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
4511   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4512   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4513   --
4514   l_business_group_id       per_business_groups.business_group_id%TYPE;
4515   l_legislation_code        per_business_groups.legislation_code%TYPE;
4516   l_period_of_service_id    per_all_assignments_f.period_of_service_id%TYPE;
4517   l_proc                    varchar2(72) := g_package||
4518   'create_secondary_emp_asg';
4519   l_session_id              number;
4520   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
4521   := p_cagr_grade_def_id;
4522   l_cagr_concatenated_segments varchar2(2000);
4523 
4524   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
4525 --
4526 begin
4527 --
4528  if g_debug then
4529   hr_utility.set_location('Entering:'|| l_proc, 5);
4530  end if;
4531   --
4532   l_assignment_number := p_assignment_number;
4533   --
4534   -- Call the new code
4535   --
4536   hr_assignment_api.create_secondary_emp_asg(
4537    p_validate                     => p_validate
4538   ,p_effective_date               => p_effective_date
4539   ,p_person_id                    => p_person_id
4540   ,p_organization_id              => p_organization_id
4541   ,p_grade_id                     => p_grade_id
4542   ,p_position_id                  => p_position_id
4543   ,p_job_id                       => p_job_id
4544   ,p_assignment_status_type_id    => p_assignment_status_type_id
4545   ,p_payroll_id                   => p_payroll_id
4546   ,p_location_id                  => p_location_id
4547   ,p_supervisor_id                => p_supervisor_id
4548   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
4549   ,p_pay_basis_id                 => p_pay_basis_id
4550   ,p_assignment_number            => l_assignment_number
4551   ,p_change_reason                => p_change_reason
4552   ,p_comments                     => p_comments
4553   ,p_date_probation_end           => p_date_probation_end
4554   ,p_default_code_comb_id         => p_default_code_comb_id
4555   ,p_employment_category          => p_employment_category
4556   ,p_frequency                    => p_frequency
4557   ,p_internal_address_line        => p_internal_address_line
4558   ,p_manager_flag                 => p_manager_flag
4559   ,p_normal_hours                 => p_normal_hours
4560   ,p_perf_review_period           => p_perf_review_period
4561   ,p_perf_review_period_frequency => p_perf_review_period_frequency
4562   ,p_probation_period             => p_probation_period
4563   ,p_probation_unit               => p_probation_unit
4564   ,p_sal_review_period            => p_sal_review_period
4565   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
4566   ,p_set_of_books_id              => p_set_of_books_id
4567   ,p_source_type                  => p_source_type
4568   ,p_time_normal_finish           => p_time_normal_finish
4569   ,p_time_normal_start            => p_time_normal_start
4570   ,p_bargaining_unit_code         => p_bargaining_unit_code
4571   ,p_labour_union_member_flag     => p_labour_union_member_flag
4572   ,p_hourly_salaried_code         => p_hourly_salaried_code
4573   ,p_notice_period                => p_notice_period
4574   ,p_notice_period_uom            => p_notice_period_uom
4575   ,p_employee_category            => p_employee_category
4576   ,p_work_at_home                 => p_work_at_home
4577   ,p_job_post_source_name         => p_job_post_source_name
4578   ,p_ass_attribute_category       => p_ass_attribute_category
4579   ,p_ass_attribute1               => p_ass_attribute1
4580   ,p_ass_attribute2               => p_ass_attribute2
4581   ,p_ass_attribute3               => p_ass_attribute3
4582   ,p_ass_attribute4               => p_ass_attribute4
4583   ,p_ass_attribute5               => p_ass_attribute5
4584   ,p_ass_attribute6               => p_ass_attribute6
4585   ,p_ass_attribute7               => p_ass_attribute7
4586   ,p_ass_attribute8               => p_ass_attribute8
4587   ,p_ass_attribute9               => p_ass_attribute9
4588   ,p_ass_attribute10              => p_ass_attribute10
4589   ,p_ass_attribute11              => p_ass_attribute11
4590   ,p_ass_attribute12              => p_ass_attribute12
4591   ,p_ass_attribute13              => p_ass_attribute13
4592   ,p_ass_attribute14              => p_ass_attribute14
4593   ,p_ass_attribute15              => p_ass_attribute15
4594   ,p_ass_attribute16              => p_ass_attribute16
4595   ,p_ass_attribute17              => p_ass_attribute17
4596   ,p_ass_attribute18              => p_ass_attribute18
4597   ,p_ass_attribute19              => p_ass_attribute19
4598   ,p_ass_attribute20              => p_ass_attribute20
4599   ,p_ass_attribute21              => p_ass_attribute21
4600   ,p_ass_attribute22              => p_ass_attribute22
4601   ,p_ass_attribute23              => p_ass_attribute23
4602   ,p_ass_attribute24              => p_ass_attribute24
4603   ,p_ass_attribute25              => p_ass_attribute25
4604   ,p_ass_attribute26              => p_ass_attribute26
4605   ,p_ass_attribute27              => p_ass_attribute27
4606   ,p_ass_attribute28              => p_ass_attribute28
4607   ,p_ass_attribute29              => p_ass_attribute29
4608   ,p_ass_attribute30              => p_ass_attribute30
4609   ,p_title                        => p_title
4610   ,p_scl_segment1                 => p_scl_segment1
4611   ,p_scl_segment2                 => p_scl_segment2
4612   ,p_scl_segment3                 => p_scl_segment3
4613   ,p_scl_segment4                 => p_scl_segment4
4614   ,p_scl_segment5                 => p_scl_segment5
4615   ,p_scl_segment6                 => p_scl_segment6
4616   ,p_scl_segment7                 => p_scl_segment7
4617   ,p_scl_segment8                 => p_scl_segment8
4618   ,p_scl_segment9                 => p_scl_segment9
4619   ,p_scl_segment10                => p_scl_segment10
4620   ,p_scl_segment11                => p_scl_segment11
4621   ,p_scl_segment12                => p_scl_segment12
4622   ,p_scl_segment13                => p_scl_segment13
4623   ,p_scl_segment14                => p_scl_segment14
4624   ,p_scl_segment15                => p_scl_segment15
4625   ,p_scl_segment16                => p_scl_segment16
4626   ,p_scl_segment17                => p_scl_segment17
4627   ,p_scl_segment18                => p_scl_segment18
4628   ,p_scl_segment19                => p_scl_segment19
4629   ,p_scl_segment20                => p_scl_segment20
4630   ,p_scl_segment21                => p_scl_segment21
4631   ,p_scl_segment22                => p_scl_segment22
4632   ,p_scl_segment23                => p_scl_segment23
4633   ,p_scl_segment24                => p_scl_segment24
4634   ,p_scl_segment25                => p_scl_segment25
4635   ,p_scl_segment26                => p_scl_segment26
4636   ,p_scl_segment27                => p_scl_segment27
4637   ,p_scl_segment28                => p_scl_segment28
4638   ,p_scl_segment29                => p_scl_segment29
4639   ,p_scl_segment30                => p_scl_segment30
4640   ,p_scl_concat_segments          => p_scl_concat_segments
4641   ,p_pgp_segment1                 => p_pgp_segment1
4642   ,p_pgp_segment2                 => p_pgp_segment2
4643   ,p_pgp_segment3                 => p_pgp_segment3
4644   ,p_pgp_segment4                 => p_pgp_segment4
4645   ,p_pgp_segment5                 => p_pgp_segment5
4646   ,p_pgp_segment6                 => p_pgp_segment6
4647   ,p_pgp_segment7                 => p_pgp_segment7
4648   ,p_pgp_segment8                 => p_pgp_segment8
4649   ,p_pgp_segment9                 => p_pgp_segment9
4650   ,p_pgp_segment10                => p_pgp_segment10
4651   ,p_pgp_segment11                => p_pgp_segment11
4652   ,p_pgp_segment12                => p_pgp_segment12
4653   ,p_pgp_segment13                => p_pgp_segment13
4654   ,p_pgp_segment14                => p_pgp_segment14
4655   ,p_pgp_segment15                => p_pgp_segment15
4656   ,p_pgp_segment16                => p_pgp_segment16
4657   ,p_pgp_segment17                => p_pgp_segment17
4658   ,p_pgp_segment18                => p_pgp_segment18
4659   ,p_pgp_segment19                => p_pgp_segment19
4660   ,p_pgp_segment20                => p_pgp_segment20
4661   ,p_pgp_segment21                => p_pgp_segment21
4662   ,p_pgp_segment22                => p_pgp_segment22
4663   ,p_pgp_segment23                => p_pgp_segment23
4664   ,p_pgp_segment24                => p_pgp_segment24
4665   ,p_pgp_segment25                => p_pgp_segment25
4666   ,p_pgp_segment26                => p_pgp_segment26
4667   ,p_pgp_segment27                => p_pgp_segment27
4668   ,p_pgp_segment28                => p_pgp_segment28
4669   ,p_pgp_segment29                => p_pgp_segment29
4670   ,p_pgp_segment30                => p_pgp_segment30
4671   ,p_pgp_concat_segments          => p_pgp_concat_segments
4672   ,p_contract_id                  => p_contract_id
4673   ,p_establishment_id             => p_establishment_id
4674   ,p_collective_agreement_id      => p_collective_agreement_id
4675   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
4676   ,p_cag_segment1                 => p_cag_segment1
4677   ,p_cag_segment2                 => p_cag_segment2
4678   ,p_cag_segment3                 => p_cag_segment3
4679   ,p_cag_segment4                 => p_cag_segment4
4680   ,p_cag_segment5                 => p_cag_segment5
4681   ,p_cag_segment6                 => p_cag_segment6
4682   ,p_cag_segment7                 => p_cag_segment7
4683   ,p_cag_segment8                 => p_cag_segment8
4684   ,p_cag_segment9                 => p_cag_segment9
4685   ,p_cag_segment10                => p_cag_segment10
4686   ,p_cag_segment11                => p_cag_segment11
4687   ,p_cag_segment12                => p_cag_segment12
4688   ,p_cag_segment13                => p_cag_segment13
4689   ,p_cag_segment14                => p_cag_segment14
4690   ,p_cag_segment15                => p_cag_segment15
4691   ,p_cag_segment16                => p_cag_segment16
4692   ,p_cag_segment17                => p_cag_segment17
4693   ,p_cag_segment18                => p_cag_segment18
4694   ,p_cag_segment19                => p_cag_segment19
4695   ,p_cag_segment20                => p_cag_segment20
4696   ,p_cagr_grade_def_id            => l_cagr_grade_def_id -- bug 2359997
4697   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
4698   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
4699   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
4700   ,p_assignment_id                => l_assignment_id
4701   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
4702   ,p_people_group_id              => l_people_group_id
4703   ,p_object_version_number        => l_object_version_number
4704   ,p_effective_start_date         => l_effective_start_date
4705   ,p_effective_end_date           => l_effective_end_date
4706   ,p_assignment_sequence          => l_assignment_sequence
4707   ,p_comment_id                   => l_comment_id
4708   ,p_concatenated_segments        => l_concatenated_segments
4709   ,p_group_name                   => l_group_name
4710   ,p_other_manager_warning        => l_other_manager_warning
4711   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
4712   ,p_gsp_post_process_warning     => l_gsp_post_process_warning -- bug 2999562
4713    );
4714   --
4715   -- Set remaining output arguments
4716   --
4717   p_assignment_id               := l_assignment_id;
4718   p_soft_coding_keyflex_id      := l_soft_coding_keyflex_id;
4719   p_people_group_id             := l_people_group_id;
4720   p_object_version_number       := l_object_version_number;
4721   p_effective_start_date        := l_effective_start_date;
4722   p_effective_end_date          := l_effective_end_date;
4723   p_assignment_sequence         := l_assignment_sequence;
4724   p_comment_id                  := l_comment_id;
4725   p_concatenated_segments       := l_concatenated_segments;
4726   p_group_name                  := l_group_name;
4727   p_other_manager_warning       := l_other_manager_warning;
4728   p_cagr_grade_def_id           := l_cagr_grade_def_id;
4729   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
4730   p_hourly_salaried_warning     := l_hourly_salaried_warning;
4731   --
4732   --
4733  if g_debug then
4734   hr_utility.set_location(' Leaving:'||l_proc, 50);
4735  end if;
4736 end create_secondary_emp_asg;
4737 --
4738 -- ----------------------------------------------------------------------------
4739 -- |---------------------< create_secondary_emp_asg >-NEW3---------------------|
4740 -- ----------------------------------------------------------------------------
4741 --
4742 --   This is the new Overloded procedure to include p_post_process_warning_msg
4743 --   out parameter
4744 --
4745 procedure create_secondary_emp_asg
4746   (p_validate                     in     boolean
4747   ,p_effective_date               in     date
4748   ,p_person_id                    in     number
4749   ,p_organization_id              in     number
4750   ,p_grade_id                     in     number
4751   ,p_position_id                  in     number
4752   ,p_job_id                       in     number
4753   ,p_assignment_status_type_id    in     number
4754   ,p_payroll_id                   in     number
4755   ,p_location_id                  in     number
4756   ,p_supervisor_id                in     number
4757   ,p_special_ceiling_step_id      in     number
4758   ,p_pay_basis_id                 in     number
4759   ,p_assignment_number            in out nocopy varchar2
4760   ,p_change_reason                in     varchar2
4761   ,p_comments                     in     varchar2
4762   ,p_date_probation_end           in     date
4763   ,p_default_code_comb_id         in     number
4764   ,p_employment_category          in     varchar2
4765   ,p_frequency                    in     varchar2
4766   ,p_internal_address_line        in     varchar2
4767   ,p_manager_flag                 in     varchar2
4768   ,p_normal_hours                 in     number
4769   ,p_perf_review_period           in     number
4770   ,p_perf_review_period_frequency in     varchar2
4771   ,p_probation_period             in     number
4772   ,p_probation_unit               in     varchar2
4773   ,p_sal_review_period            in     number
4774   ,p_sal_review_period_frequency  in     varchar2
4775   ,p_set_of_books_id              in     number
4776   ,p_source_type                  in     varchar2
4777   ,p_time_normal_finish           in     varchar2
4778   ,p_time_normal_start            in     varchar2
4779   ,p_bargaining_unit_code         in     varchar2
4780   ,p_labour_union_member_flag     in     varchar2
4781   ,p_hourly_salaried_code         in     varchar2
4782   ,p_ass_attribute_category       in     varchar2
4783   ,p_ass_attribute1               in     varchar2
4784   ,p_ass_attribute2               in     varchar2
4785   ,p_ass_attribute3               in     varchar2
4786   ,p_ass_attribute4               in     varchar2
4787   ,p_ass_attribute5               in     varchar2
4788   ,p_ass_attribute6               in     varchar2
4789   ,p_ass_attribute7               in     varchar2
4790   ,p_ass_attribute8               in     varchar2
4791   ,p_ass_attribute9               in     varchar2
4792   ,p_ass_attribute10              in     varchar2
4793   ,p_ass_attribute11              in     varchar2
4794   ,p_ass_attribute12              in     varchar2
4795   ,p_ass_attribute13              in     varchar2
4796   ,p_ass_attribute14              in     varchar2
4797   ,p_ass_attribute15              in     varchar2
4798   ,p_ass_attribute16              in     varchar2
4799   ,p_ass_attribute17              in     varchar2
4800   ,p_ass_attribute18              in     varchar2
4801   ,p_ass_attribute19              in     varchar2
4802   ,p_ass_attribute20              in     varchar2
4803   ,p_ass_attribute21              in     varchar2
4804   ,p_ass_attribute22              in     varchar2
4805   ,p_ass_attribute23              in     varchar2
4806   ,p_ass_attribute24              in     varchar2
4807   ,p_ass_attribute25              in     varchar2
4808   ,p_ass_attribute26              in     varchar2
4809   ,p_ass_attribute27              in     varchar2
4810   ,p_ass_attribute28              in     varchar2
4811   ,p_ass_attribute29              in     varchar2
4812   ,p_ass_attribute30              in     varchar2
4813   ,p_title                        in     varchar2
4814   ,p_scl_segment1                 in     varchar2
4815   ,p_scl_segment2                 in     varchar2
4816   ,p_scl_segment3                 in     varchar2
4817   ,p_scl_segment4                 in     varchar2
4818   ,p_scl_segment5                 in     varchar2
4819   ,p_scl_segment6                 in     varchar2
4820   ,p_scl_segment7                 in     varchar2
4821   ,p_scl_segment8                 in     varchar2
4822   ,p_scl_segment9                 in     varchar2
4823   ,p_scl_segment10                in     varchar2
4824   ,p_scl_segment11                in     varchar2
4825   ,p_scl_segment12                in     varchar2
4826   ,p_scl_segment13                in     varchar2
4827   ,p_scl_segment14                in     varchar2
4828   ,p_scl_segment15                in     varchar2
4829   ,p_scl_segment16                in     varchar2
4830   ,p_scl_segment17                in     varchar2
4831   ,p_scl_segment18                in     varchar2
4832   ,p_scl_segment19                in     varchar2
4833   ,p_scl_segment20                in     varchar2
4834   ,p_scl_segment21                in     varchar2
4835   ,p_scl_segment22                in     varchar2
4836   ,p_scl_segment23                in     varchar2
4837   ,p_scl_segment24                in     varchar2
4838   ,p_scl_segment25                in     varchar2
4839   ,p_scl_segment26                in     varchar2
4840   ,p_scl_segment27                in     varchar2
4841   ,p_scl_segment28                in     varchar2
4842   ,p_scl_segment29                in     varchar2
4843   ,p_scl_segment30                in     varchar2
4844 -- Bug 944911
4845 -- Added scl_concat_segments and amended scl_concatenated_segments
4846 -- to be an out instead of in out
4847   ,p_scl_concat_segments    	  in 	 varchar2
4848   ,p_pgp_segment1                 in     varchar2
4849   ,p_pgp_segment2                 in     varchar2
4850   ,p_pgp_segment3                 in     varchar2
4851   ,p_pgp_segment4                 in     varchar2
4852   ,p_pgp_segment5                 in     varchar2
4853   ,p_pgp_segment6                 in     varchar2
4854   ,p_pgp_segment7                 in     varchar2
4855   ,p_pgp_segment8                 in     varchar2
4856   ,p_pgp_segment9                 in     varchar2
4857   ,p_pgp_segment10                in     varchar2
4858   ,p_pgp_segment11                in     varchar2
4859   ,p_pgp_segment12                in     varchar2
4860   ,p_pgp_segment13                in     varchar2
4861   ,p_pgp_segment14                in     varchar2
4862   ,p_pgp_segment15                in     varchar2
4863   ,p_pgp_segment16                in     varchar2
4864   ,p_pgp_segment17                in     varchar2
4865   ,p_pgp_segment18                in     varchar2
4866   ,p_pgp_segment19                in     varchar2
4867   ,p_pgp_segment20                in     varchar2
4868   ,p_pgp_segment21                in     varchar2
4869   ,p_pgp_segment22                in     varchar2
4870   ,p_pgp_segment23                in     varchar2
4871   ,p_pgp_segment24                in     varchar2
4872   ,p_pgp_segment25                in     varchar2
4873   ,p_pgp_segment26                in     varchar2
4874   ,p_pgp_segment27                in     varchar2
4875   ,p_pgp_segment28                in     varchar2
4876   ,p_pgp_segment29                in     varchar2
4877   ,p_pgp_segment30                in     varchar2
4878 -- Bug 944911
4879 -- Made p_group_name to be out param
4880 -- and add p_concat_segment to be IN
4881 -- in case of sec_asg alone made p_pgp_concat_segments as in param
4882   ,p_pgp_concat_segments	  in     varchar2
4883   ,p_contract_id                  in     number
4884   ,p_establishment_id             in     number
4885   ,p_collective_agreement_id      in     number
4886   ,p_cagr_id_flex_num             in     number
4887   ,p_cag_segment1                 in     varchar2
4888   ,p_cag_segment2                 in     varchar2
4889   ,p_cag_segment3                 in     varchar2
4890   ,p_cag_segment4                 in     varchar2
4891   ,p_cag_segment5                 in     varchar2
4892   ,p_cag_segment6                 in     varchar2
4893   ,p_cag_segment7                 in     varchar2
4894   ,p_cag_segment8                 in     varchar2
4895   ,p_cag_segment9                 in     varchar2
4896   ,p_cag_segment10                in     varchar2
4897   ,p_cag_segment11                in     varchar2
4898   ,p_cag_segment12                in     varchar2
4899   ,p_cag_segment13                in     varchar2
4900   ,p_cag_segment14                in     varchar2
4901   ,p_cag_segment15                in     varchar2
4902   ,p_cag_segment16                in     varchar2
4903   ,p_cag_segment17                in     varchar2
4904   ,p_cag_segment18                in     varchar2
4905   ,p_cag_segment19                in     varchar2
4906   ,p_cag_segment20                in     varchar2
4907   ,p_notice_period		  in	 number
4908   ,p_notice_period_uom		  in     varchar2
4909   ,p_employee_category		  in     varchar2
4910   ,p_work_at_home		  in	 varchar2
4911   ,p_job_post_source_name         in     varchar2
4912   ,p_grade_ladder_pgm_id          in     number
4913   ,p_supervisor_assignment_id     in     number
4914   ,p_group_name                      out nocopy varchar2
4915 -- Bug 944911
4916 -- Added scl_concat_segments and amended scl_concatenated_segments
4917 -- to be an out instead of in out
4918 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
4919 -- This has been done through out the procedures
4920   ,p_concatenated_segments           out nocopy varchar2
4921   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
4922   ,p_cagr_concatenated_segments      out nocopy varchar2
4923   ,p_assignment_id                   out nocopy number
4924   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
4925   ,p_people_group_id              in out nocopy number  -- bug 2359997
4926   ,p_object_version_number           out nocopy number
4927   ,p_effective_start_date            out nocopy date
4928   ,p_effective_end_date              out nocopy date
4929   ,p_assignment_sequence             out nocopy number
4930   ,p_comment_id                      out nocopy number
4931   ,p_other_manager_warning           out nocopy boolean
4932   ,p_hourly_salaried_warning         out nocopy boolean
4933   ,p_gsp_post_process_warning        out nocopy varchar2
4934   ) is
4935   --
4936   -- Declare cursors and local variables
4937   --
4938   -- Out variables
4939   --
4940   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
4941   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
4942   := p_soft_coding_keyflex_id;
4943   l_people_group_id         per_all_assignments_f.people_group_id%TYPE
4944   := p_people_group_id;
4945   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
4946   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
4947   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
4948   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
4949   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
4950   l_comment_id              per_all_assignments_f.comment_id%TYPE;
4951   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4952   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4953   l_group_name              pay_people_groups.group_name%TYPE;
4954   l_old_group_name          pay_people_groups.group_name%TYPE;
4955   l_other_manager_warning   boolean;
4956   l_hourly_salaried_warning boolean;
4957   l_effective_date          date;
4958   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
4959   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
4960   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4961   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4962   --
4963   l_business_group_id       per_business_groups.business_group_id%TYPE;
4964   l_legislation_code        per_business_groups.legislation_code%TYPE;
4965   l_period_of_service_id    per_all_assignments_f.period_of_service_id%TYPE;
4966   l_proc                    varchar2(72) := g_package||
4967   'create_secondary_emp_asg';
4968   l_session_id              number;
4969   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
4970   := p_cagr_grade_def_id;
4971   l_cagr_concatenated_segments varchar2(2000);
4972 
4973   l_gsp_post_process_warning   varchar2(2000); -- bug 2999562
4974   --
4975   -- bug 2359997 new variables to indicate whether key flex id parameters
4976   -- enter the program with a value.
4977   --
4978   l_pgp_null_ind               number(1) := 0;
4979   l_scl_null_ind               number(1) := 0;
4980   l_cag_null_ind               number(1) := 0;
4981   --
4982   -- Bug 2359997 new variables for derived values where key flex id is known.
4983   --
4984   l_scl_segment1               varchar2(60) := p_scl_segment1;
4985   l_scl_segment2               varchar2(60) := p_scl_segment2;
4986   l_scl_segment3               varchar2(60) := p_scl_segment3;
4987   l_scl_segment4               varchar2(60) := p_scl_segment4;
4988   l_scl_segment5               varchar2(60) := p_scl_segment5;
4989   l_scl_segment6               varchar2(60) := p_scl_segment6;
4990   l_scl_segment7               varchar2(60) := p_scl_segment7;
4991   l_scl_segment8               varchar2(60) := p_scl_segment8;
4992   l_scl_segment9               varchar2(60) := p_scl_segment9;
4993   l_scl_segment10              varchar2(60) := p_scl_segment10;
4994   l_scl_segment11              varchar2(60) := p_scl_segment11;
4995   l_scl_segment12              varchar2(60) := p_scl_segment12;
4996   l_scl_segment13              varchar2(60) := p_scl_segment13;
4997   l_scl_segment14              varchar2(60) := p_scl_segment14;
4998   l_scl_segment15              varchar2(60) := p_scl_segment15;
4999   l_scl_segment16              varchar2(60) := p_scl_segment16;
5000   l_scl_segment17              varchar2(60) := p_scl_segment17;
5001   l_scl_segment18              varchar2(60) := p_scl_segment18;
5002   l_scl_segment19              varchar2(60) := p_scl_segment19;
5003   l_scl_segment20              varchar2(60) := p_scl_segment20;
5004   l_scl_segment21              varchar2(60) := p_scl_segment21;
5005   l_scl_segment22              varchar2(60) := p_scl_segment22;
5006   l_scl_segment23              varchar2(60) := p_scl_segment23;
5007   l_scl_segment24              varchar2(60) := p_scl_segment24;
5008   l_scl_segment25              varchar2(60) := p_scl_segment25;
5009   l_scl_segment26              varchar2(60) := p_scl_segment26;
5010   l_scl_segment27              varchar2(60) := p_scl_segment27;
5011   l_scl_segment28              varchar2(60) := p_scl_segment28;
5012   l_scl_segment29              varchar2(60) := p_scl_segment29;
5013   l_scl_segment30              varchar2(60) := p_scl_segment30;
5014   --
5015   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
5016   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
5017   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
5018   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
5019   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
5020   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
5021   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
5022   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
5023   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
5024   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
5025   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
5026   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
5027   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
5028   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
5029   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
5030   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
5031   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
5032   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
5033   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
5034   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
5035   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
5036   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
5037   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
5038   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
5039   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
5040   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
5041   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
5042   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
5043   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
5044   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
5045   --
5046   l_cag_segment1               varchar2(60) := p_cag_segment1;
5047   l_cag_segment2               varchar2(60) := p_cag_segment2;
5048   l_cag_segment3               varchar2(60) := p_cag_segment3;
5049   l_cag_segment4               varchar2(60) := p_cag_segment4;
5050   l_cag_segment5               varchar2(60) := p_cag_segment5;
5051   l_cag_segment6               varchar2(60) := p_cag_segment6;
5052   l_cag_segment7               varchar2(60) := p_cag_segment7;
5053   l_cag_segment8               varchar2(60) := p_cag_segment8;
5054   l_cag_segment9               varchar2(60) := p_cag_segment9;
5055   l_cag_segment10              varchar2(60) := p_cag_segment10;
5056   l_cag_segment11              varchar2(60) := p_cag_segment11;
5057   l_cag_segment12              varchar2(60) := p_cag_segment12;
5058   l_cag_segment13              varchar2(60) := p_cag_segment13;
5059   l_cag_segment14              varchar2(60) := p_cag_segment14;
5060   l_cag_segment15              varchar2(60) := p_cag_segment15;
5061   l_cag_segment16              varchar2(60) := p_cag_segment16;
5062   l_cag_segment17              varchar2(60) := p_cag_segment17;
5063   l_cag_segment18              varchar2(60) := p_cag_segment18;
5064   l_cag_segment19              varchar2(60) := p_cag_segment19;
5065   l_cag_segment20              varchar2(60) := p_cag_segment20;
5066   --
5067   lv_assignment_number         varchar2(2000) := p_assignment_number ;
5068   lv_cagr_grade_def_id         number         := p_cagr_grade_def_id ;
5069   lv_soft_coding_keyflex_id    number         := p_soft_coding_keyflex_id ;
5070   lv_people_group_id           number         := p_people_group_id ;
5071 
5072   --
5073   cursor csr_get_derived_details is
5074     select bus.business_group_id
5075          , bus.legislation_code
5076       from per_all_people_f    per
5077          , per_business_groups_perf bus
5078      where per.person_id         = p_person_id
5079      and   l_effective_date      between per.effective_start_date
5080                                  and     per.effective_end_date
5081      and   bus.business_group_id = per.business_group_id;
5082   --
5083   cursor csr_get_period_of_service is
5084     select asg.period_of_service_id
5085       from per_all_assignments_f asg
5086      where asg.person_id    = p_person_id
5087      and   l_effective_date between asg.effective_start_date
5088                             and     asg.effective_end_date
5089      and   asg.primary_flag = 'Y'
5090   --
5091   -- Start of Bug: 2288629.
5092      and   asg.assignment_type = 'E';
5093   -- End  of  Bug: 2288629.
5094   --
5095   --
5096   -- the cursor csr_grp_idsel selects the valid id_flex_num
5097   -- (grp keyflex) for the specified business group
5098   --
5099   cursor csr_grp_idsel is
5100     select people_group_structure
5101       from per_business_groups_perf
5102       where business_group_id = l_business_group_id;
5103   --
5104   --
5105   -- the cursor csr_scl_idsel selects the valid id_flex_num
5106   -- (scl keyflex) for the specified business group
5107   --
5108   cursor csr_scl_idsel is
5109     select plr.rule_mode                       id_flex_num
5110     from   pay_legislation_rules               plr
5111     where  plr.legislation_code                = l_legislation_code
5112     and    plr.rule_type                       = 'S'
5113     and    exists
5114           (select 1
5115            from   fnd_segment_attribute_values fsav
5116            where  to_char(fsav.id_flex_num)    = plr.rule_mode   -- Fix For Bug 12813119
5117            and    fsav.application_id          = 800
5118            and    fsav.id_flex_code            = 'SCL'
5119            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
5120            and    fsav.attribute_value         = 'Y')
5121     and    exists
5122           (select 1
5123            from   pay_legislation_rules        plr2
5124            where  plr2.legislation_code        = l_legislation_code
5125            and    plr2.rule_type               = 'SDL'
5126            and    plr2.rule_mode               = 'A') ;
5127   --
5128   --
5129   -- bug 2359997 get pay_people_group segment values where
5130   -- people_group_id is known
5131   --
5132   cursor c_pgp_segments is
5133      select segment1,
5134             segment2,
5135             segment3,
5136             segment4,
5137             segment5,
5138             segment6,
5139             segment7,
5140             segment8,
5141             segment9,
5142             segment10,
5143             segment11,
5144             segment12,
5145             segment13,
5146             segment14,
5147             segment15,
5148             segment16,
5149             segment17,
5150             segment18,
5151             segment19,
5152             segment20,
5153             segment21,
5154             segment22,
5155             segment23,
5156             segment24,
5157             segment25,
5158             segment26,
5159             segment27,
5160             segment28,
5161             segment29,
5162             segment30
5163      from   pay_people_groups
5164      where  people_group_id = l_people_group_id;
5165   --
5166   -- bug 2359997 get hr_soft_coding_keyflex segment values where
5167   -- soft_coding_keyflex_id is known
5168   --
5169   cursor c_scl_segments is
5170      select segment1,
5171             segment2,
5172             segment3,
5173             segment4,
5174             segment5,
5175             segment6,
5176             segment7,
5177             segment8,
5178             segment9,
5179             segment10,
5180             segment11,
5181             segment12,
5182             segment13,
5183             segment14,
5184             segment15,
5185             segment16,
5186             segment17,
5187             segment18,
5188             segment19,
5189             segment20,
5190             segment21,
5191             segment22,
5192             segment23,
5193             segment24,
5194             segment25,
5195             segment26,
5196             segment27,
5197             segment28,
5198             segment29,
5199             segment30
5200      from   hr_soft_coding_keyflex
5201      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
5202   --
5203   -- bug 2359997 get per_cagr_grades_def segment values where
5204   -- cagr_grade_def_id is known
5205   --
5206   cursor c_cag_segments is
5207      select segment1,
5208             segment2,
5209             segment3,
5210             segment4,
5211             segment5,
5212             segment6,
5213             segment7,
5214             segment8,
5215             segment9,
5216             segment10,
5217             segment11,
5218             segment12,
5219             segment13,
5220             segment14,
5221             segment15,
5222             segment16,
5223             segment17,
5224             segment18,
5225             segment19,
5226             segment20
5227      from   per_cagr_grades_def
5228      where  cagr_grade_def_id = l_cagr_grade_def_id;
5229 --
5230 begin
5231 --
5232  if g_debug then
5233   hr_utility.set_location('Entering:'|| l_proc, 5);
5234  end if;
5235   --
5236   -- Issue a savepoint.
5237   --
5238   -- Truncate the parameter p_effective_date and p_date_probation_end
5239   -- into local variables
5240   --
5241   l_effective_date := trunc(p_effective_date);
5242   l_date_probation_end := trunc(p_date_probation_end);
5243   --
5244   -- Bug 944911
5245   -- Amended p_scl_concatenated_segments to p_scl_concat_segments
5246   -- to be an out instead of in out
5247   l_old_scl_conc_segments:=p_scl_concat_segments;
5248   -- Bug 944911
5249   -- Made p_group_name to be out param
5250   -- and add p_concat_segment to be IN
5251   -- in case of sec_asg alone made p_pgp_concat_segments as in param
5252   -- Replaced p_group_name by p_pgp_concat_segments
5253   l_old_group_name:=p_pgp_concat_segments;
5254   --
5255   -- Bug 2359997 - if p_people_group_id enters with
5256   -- a value then get segment values from pay_people_groups.
5257   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
5258   -- per_cagr_grades_def
5259   --
5260   --
5261  if g_debug then
5262   hr_utility.set_location(l_proc, 20);
5263  end if;
5264   --
5265   if l_people_group_id is not null
5266   then
5267      l_pgp_null_ind := 1;
5268      --
5269      open c_pgp_segments;
5270        fetch c_pgp_segments into l_pgp_segment1,
5271                                  l_pgp_segment2,
5272                                  l_pgp_segment3,
5273                                  l_pgp_segment4,
5274                                  l_pgp_segment5,
5275                                  l_pgp_segment6,
5276                                  l_pgp_segment7,
5277                                  l_pgp_segment8,
5278                                  l_pgp_segment9,
5279                                  l_pgp_segment10,
5280                                  l_pgp_segment11,
5281                                  l_pgp_segment12,
5282                                  l_pgp_segment13,
5283                                  l_pgp_segment14,
5284                                  l_pgp_segment15,
5285                                  l_pgp_segment16,
5286                                  l_pgp_segment17,
5287                                  l_pgp_segment18,
5288                                  l_pgp_segment19,
5289                                  l_pgp_segment20,
5290                                  l_pgp_segment21,
5291                                  l_pgp_segment22,
5292                                  l_pgp_segment23,
5293                                  l_pgp_segment24,
5294                                  l_pgp_segment25,
5295                                  l_pgp_segment26,
5296                                  l_pgp_segment27,
5297                                  l_pgp_segment28,
5298                                  l_pgp_segment29,
5299                                  l_pgp_segment30;
5300      close c_pgp_segments;
5301   else
5302      l_pgp_null_ind := 0;
5303   end if;
5304   --
5305   --  use cursor c_scl_segments to bring back segment values if
5306   --  l_soft_coding_keyflex has a value.
5307   if l_soft_coding_keyflex_id is not null
5308   then
5309      l_scl_null_ind := 1;
5310      open c_scl_segments;
5311        fetch c_scl_segments into l_scl_segment1,
5312                                  l_scl_segment2,
5313                                  l_scl_segment3,
5314                                  l_scl_segment4,
5315                                  l_scl_segment5,
5316                                  l_scl_segment6,
5317                                  l_scl_segment7,
5318                                  l_scl_segment8,
5319                                  l_scl_segment9,
5320                                  l_scl_segment10,
5321                                  l_scl_segment11,
5322                                  l_scl_segment12,
5323                                  l_scl_segment13,
5324                                  l_scl_segment14,
5325                                  l_scl_segment15,
5326                                  l_scl_segment16,
5327                                  l_scl_segment17,
5328                                  l_scl_segment18,
5329                                  l_scl_segment19,
5330                                  l_scl_segment20,
5331                                  l_scl_segment21,
5332                                  l_scl_segment22,
5333                                  l_scl_segment23,
5334                                  l_scl_segment24,
5335                                  l_scl_segment25,
5336                                  l_scl_segment26,
5337                                  l_scl_segment27,
5338                                  l_scl_segment28,
5339                                  l_scl_segment29,
5340                                  l_scl_segment30;
5341      close c_scl_segments;
5342   else
5343      l_scl_null_ind := 0;
5344   end if;
5345   --
5346   -- if cagr_grade_def_id has a value then use it to get segment values using
5347   -- cursor cag_segments
5348   --
5349   if l_cagr_grade_def_id is not null
5350   then
5351      l_cag_null_ind := 1;
5352      open c_cag_segments;
5353        fetch c_cag_segments into l_cag_segment1,
5354                                  l_cag_segment2,
5355                                  l_cag_segment3,
5356                                  l_cag_segment4,
5357                                  l_cag_segment5,
5358                                  l_cag_segment6,
5359                                  l_cag_segment7,
5360                                  l_cag_segment8,
5361                                  l_cag_segment9,
5362                                  l_cag_segment10,
5363                                  l_cag_segment11,
5364                                  l_cag_segment12,
5365                                  l_cag_segment13,
5366                                  l_cag_segment14,
5367                                  l_cag_segment15,
5368                                  l_cag_segment16,
5369                                  l_cag_segment17,
5370                                  l_cag_segment18,
5371                                  l_cag_segment19,
5372                                  l_cag_segment20;
5373      close c_cag_segments;
5374   else
5375      l_cag_null_ind := 0;
5376   end if;
5377   --
5378   savepoint create_secondary_emp_asg;
5379   --
5380   begin
5381   --
5382     --
5383     -- Start of API User Hook for the before hook of create_secondary_emp_asg
5384     --
5385     hr_assignment_bk1.create_secondary_emp_asg_b
5386       (p_effective_date               => l_effective_date
5387       ,p_person_id                    => p_person_id
5388       ,p_organization_id              => p_organization_id
5389       ,p_grade_id                     => p_grade_id
5390       ,p_position_id                  => p_position_id
5391       ,p_job_id                       => p_job_id
5392       ,p_assignment_status_type_id    => p_assignment_status_type_id
5393       ,p_payroll_id                   => p_payroll_id
5394       ,p_location_id                  => p_location_id
5395       ,p_supervisor_id                => p_supervisor_id
5396       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
5397       ,p_pay_basis_id                 => p_pay_basis_id
5398       ,p_assignment_number            => p_assignment_number
5399       ,p_change_reason                => p_change_reason
5400       ,p_comments                     => p_comments
5401       ,p_date_probation_end           => l_date_probation_end
5402       ,p_default_code_comb_id         => p_default_code_comb_id
5403       ,p_employment_category          => p_employment_category
5404       ,p_frequency                    => p_frequency
5405       ,p_internal_address_line        => p_internal_address_line
5406       ,p_manager_flag                 => p_manager_flag
5407       ,p_normal_hours                 => p_normal_hours
5408       ,p_perf_review_period           => p_perf_review_period
5409       ,p_perf_review_period_frequency => p_perf_review_period_frequency
5410       ,p_probation_period             => p_probation_period
5411       ,p_probation_unit               => p_probation_unit
5412       ,p_sal_review_period            => p_sal_review_period
5413       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
5414       ,p_set_of_books_id              => p_set_of_books_id
5415       ,p_source_type                  => p_source_type
5416       ,p_time_normal_finish           => p_time_normal_finish
5417       ,p_time_normal_start            => p_time_normal_start
5418       ,p_bargaining_unit_code         => p_bargaining_unit_code
5419       ,p_labour_union_member_flag     => p_labour_union_member_flag
5420       ,p_hourly_salaried_code         => p_hourly_salaried_code
5421       ,p_ass_attribute_category       => p_ass_attribute_category
5422       ,p_ass_attribute1               => p_ass_attribute1
5423       ,p_ass_attribute2               => p_ass_attribute2
5424       ,p_ass_attribute3               => p_ass_attribute3
5425       ,p_ass_attribute4               => p_ass_attribute4
5426       ,p_ass_attribute5               => p_ass_attribute5
5427       ,p_ass_attribute6               => p_ass_attribute6
5428       ,p_ass_attribute7               => p_ass_attribute7
5429       ,p_ass_attribute8               => p_ass_attribute8
5430       ,p_ass_attribute9               => p_ass_attribute9
5431       ,p_ass_attribute10              => p_ass_attribute10
5432       ,p_ass_attribute11              => p_ass_attribute11
5433       ,p_ass_attribute12              => p_ass_attribute12
5434       ,p_ass_attribute13              => p_ass_attribute13
5435       ,p_ass_attribute14              => p_ass_attribute14
5436       ,p_ass_attribute15              => p_ass_attribute15
5437       ,p_ass_attribute16              => p_ass_attribute16
5438       ,p_ass_attribute17              => p_ass_attribute17
5439       ,p_ass_attribute18              => p_ass_attribute18
5440       ,p_ass_attribute19              => p_ass_attribute19
5441       ,p_ass_attribute20              => p_ass_attribute20
5442       ,p_ass_attribute21              => p_ass_attribute21
5443       ,p_ass_attribute22              => p_ass_attribute22
5444       ,p_ass_attribute23              => p_ass_attribute23
5445       ,p_ass_attribute24              => p_ass_attribute24
5446       ,p_ass_attribute25              => p_ass_attribute25
5447       ,p_ass_attribute26              => p_ass_attribute26
5448       ,p_ass_attribute27              => p_ass_attribute27
5449       ,p_ass_attribute28              => p_ass_attribute28
5450       ,p_ass_attribute29              => p_ass_attribute29
5451       ,p_ass_attribute30              => p_ass_attribute30
5452       ,p_title                        => p_title
5453        --
5454        -- Bug 2359997
5455        -- Amended p_scl/pgp/cag_segments to be l_scl/pgp/cag_segments
5456        --
5457       ,p_scl_segment1                 => l_scl_segment1
5458       ,p_scl_segment2                 => l_scl_segment2
5459       ,p_scl_segment3                 => l_scl_segment3
5460       ,p_scl_segment4                 => l_scl_segment4
5461       ,p_scl_segment5                 => l_scl_segment5
5462       ,p_scl_segment6                 => l_scl_segment6
5463       ,p_scl_segment7                 => l_scl_segment7
5464       ,p_scl_segment8                 => l_scl_segment8
5465       ,p_scl_segment9                 => l_scl_segment9
5466       ,p_scl_segment10                => l_scl_segment10
5467       ,p_scl_segment11                => l_scl_segment11
5468       ,p_scl_segment12                => l_scl_segment12
5469       ,p_scl_segment13                => l_scl_segment13
5470       ,p_scl_segment14                => l_scl_segment14
5471       ,p_scl_segment15                => l_scl_segment15
5472       ,p_scl_segment16                => l_scl_segment16
5473       ,p_scl_segment17                => l_scl_segment17
5474       ,p_scl_segment18                => l_scl_segment18
5475       ,p_scl_segment19                => l_scl_segment19
5476       ,p_scl_segment20                => l_scl_segment20
5477       ,p_scl_segment21                => l_scl_segment21
5478       ,p_scl_segment22                => l_scl_segment22
5479       ,p_scl_segment23                => l_scl_segment23
5480       ,p_scl_segment24                => l_scl_segment24
5481       ,p_scl_segment25                => l_scl_segment25
5482       ,p_scl_segment26                => l_scl_segment26
5483       ,p_scl_segment27                => l_scl_segment27
5484       ,p_scl_segment28                => l_scl_segment28
5485       ,p_scl_segment29                => l_scl_segment29
5486       ,p_scl_segment30                => l_scl_segment30
5487       --
5488       -- Bug 944911
5489       -- Amended p_scl_concatenated_Segments by p_scl_concat_segments
5490       --
5491       ,p_scl_concat_segments          => l_old_scl_conc_segments
5492       ,p_pgp_segment1                 => l_pgp_segment1
5493       ,p_pgp_segment2                 => l_pgp_segment2
5494       ,p_pgp_segment3                 => l_pgp_segment3
5495       ,p_pgp_segment4                 => l_pgp_segment4
5496       ,p_pgp_segment5                 => l_pgp_segment5
5497       ,p_pgp_segment6                 => l_pgp_segment6
5498       ,p_pgp_segment7                 => l_pgp_segment7
5499       ,p_pgp_segment8                 => l_pgp_segment8
5500       ,p_pgp_segment9                 => l_pgp_segment9
5501       ,p_pgp_segment10                => l_pgp_segment10
5502       ,p_pgp_segment11                => l_pgp_segment11
5503       ,p_pgp_segment12                => l_pgp_segment12
5504       ,p_pgp_segment13                => l_pgp_segment13
5505       ,p_pgp_segment14                => l_pgp_segment14
5506       ,p_pgp_segment15                => l_pgp_segment15
5507       ,p_pgp_segment16                => l_pgp_segment16
5508       ,p_pgp_segment17                => l_pgp_segment17
5509       ,p_pgp_segment18                => l_pgp_segment18
5510       ,p_pgp_segment19                => l_pgp_segment19
5511       ,p_pgp_segment20                => l_pgp_segment20
5512       ,p_pgp_segment21                => l_pgp_segment21
5513       ,p_pgp_segment22                => l_pgp_segment22
5514       ,p_pgp_segment23                => l_pgp_segment23
5515       ,p_pgp_segment24                => l_pgp_segment24
5516       ,p_pgp_segment25                => l_pgp_segment25
5517       ,p_pgp_segment26                => l_pgp_segment26
5518       ,p_pgp_segment27                => l_pgp_segment27
5519       ,p_pgp_segment28                => l_pgp_segment28
5520       ,p_pgp_segment29                => l_pgp_segment29
5521       ,p_pgp_segment30                => l_pgp_segment30
5522       --
5523       -- Bug 944911
5524       -- Replaced p_group_name with p_pgp_concat_segments
5525       --
5526       ,p_pgp_concat_segments          => l_old_group_name
5527       ,p_contract_id                  => p_contract_id
5528       ,p_establishment_id             => p_establishment_id
5529       ,p_collective_agreement_id      => p_collective_agreement_id
5530       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
5531       ,p_cag_segment1                 => l_cag_segment1
5532       ,p_cag_segment2                 => l_cag_segment2
5533       ,p_cag_segment3                 => l_cag_segment3
5534       ,p_cag_segment4                 => l_cag_segment4
5535       ,p_cag_segment5                 => l_cag_segment5
5536       ,p_cag_segment6                 => l_cag_segment6
5537       ,p_cag_segment7                 => l_cag_segment7
5538       ,p_cag_segment8                 => l_cag_segment8
5539       ,p_cag_segment9                 => l_cag_segment9
5540       ,p_cag_segment10                => l_cag_segment10
5541       ,p_cag_segment11                => l_cag_segment11
5542       ,p_cag_segment12                => l_cag_segment12
5543       ,p_cag_segment13                => l_cag_segment13
5544       ,p_cag_segment14                => l_cag_segment14
5545       ,p_cag_segment15                => l_cag_segment15
5546       ,p_cag_segment16                => l_cag_segment16
5547       ,p_cag_segment17                => l_cag_segment17
5548       ,p_cag_segment18                => l_cag_segment18
5549       ,p_cag_segment19                => l_cag_segment19
5550       ,p_cag_segment20                => l_cag_segment20
5551       ,p_notice_period		      => p_notice_period
5552       ,p_notice_period_uom	      => p_notice_period_uom
5553       ,p_employee_category	      => p_employee_category
5554       ,p_work_at_home		      => p_work_at_home
5555       ,p_job_post_source_name	      => p_job_post_source_name
5556       ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
5557       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
5558       );
5559   exception
5560     when hr_api.cannot_find_prog_unit then
5561       hr_api.cannot_find_prog_unit_error
5562         (p_module_name => 'CREATE_SECONDARY_EMP_ASG'
5563         ,p_hook_type   => 'BP'
5564         );
5565     --
5566     -- End of API User Hook for the before hook of create_secondary_emp_asg
5567   --
5568   end;
5569   --
5570  if g_debug then
5571   hr_utility.set_location(l_proc, 10);
5572  end if;
5573   --
5574   -- Validation in addition to Table Handlers
5575   --
5576   -- Get person details.
5577   --
5578   hr_api.mandatory_arg_error
5579      (p_api_name       => l_proc
5580      ,p_argument       => 'person_id'
5581      ,p_argument_value => p_person_id
5582      );
5583   --
5584   hr_api.mandatory_arg_error
5585      (p_api_name       => l_proc
5586      ,p_argument       => 'effective_date'
5587      ,p_argument_value => l_effective_date
5588      );
5589   --
5590   -- Record the value of in out parameters
5591   --
5592   l_assignment_number := p_assignment_number;
5593   --
5594   open  csr_get_derived_details;
5595   fetch csr_get_derived_details
5596    into l_business_group_id
5597       , l_legislation_code;
5598   --
5599   if csr_get_derived_details%NOTFOUND then
5600     --
5601     close csr_get_derived_details;
5602     --
5603  if g_debug then
5604     hr_utility.set_location(l_proc, 15);
5605  end if;
5606     --
5607     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
5608     hr_utility.raise_error;
5609   end if;
5610   --
5611   close csr_get_derived_details;
5612   --
5613  if g_debug then
5614   hr_utility.set_location(l_proc, 20);
5615  end if;
5616   --
5617   -- Process Logic
5618   --
5619   -- Get period of service from primary assignment.
5620   --
5621   open  csr_get_period_of_service;
5622   fetch csr_get_period_of_service
5623    into l_period_of_service_id;
5624   --
5625   if csr_get_period_of_service%NOTFOUND then
5626     --
5627     close csr_get_period_of_service;
5628     --
5629  if g_debug then
5630     hr_utility.set_location(l_proc, 25);
5631  end if;
5632     --
5633     hr_utility.set_message(801,'HR_7436_ASG_NO_PRIM_ASS');
5634     hr_utility.raise_error;
5635   end if;
5636   --
5637   close csr_get_period_of_service;
5638  if g_debug then
5639   hr_utility.set_location(l_proc, 26);
5640  end if;
5641   --
5642   -- insert the profile options and effective date for the flexfield
5643   -- validation to work
5644   --
5645   hr_kflex_utility.set_profiles
5646   (p_business_group_id => l_business_group_id
5647   ,p_assignment_id     => l_assignment_id
5648   ,p_organization_id   => p_organization_id
5649   ,p_location_id       => p_location_id);
5650   --
5651   hr_kflex_utility.set_session_date
5652   (p_effective_date => l_effective_date
5653   ,p_session_id     => l_session_id);
5654   --
5655   open csr_grp_idsel;
5656   fetch csr_grp_idsel into l_grp_flex_num;
5657     if csr_grp_idsel%NOTFOUND then
5658        close csr_grp_idsel;
5659           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
5660           hr_utility.set_message_token('PROCEDURE', l_proc);
5661           hr_utility.set_message_token('STEP','5');
5662           hr_utility.raise_error;
5663     else
5664       close csr_grp_idsel;
5665     end if;
5666  if g_debug then
5667   hr_utility.set_location(l_proc, 27);
5668  end if;
5669   --
5670   --
5671   -- Bug 2359997 - if key flex parameters have a value then derive segment
5672   -- values from them
5673   --
5674   if l_scl_null_ind = 0
5675   then
5676     if l_scl_segment1 is not null
5677     or l_scl_segment2 is not null
5678     or l_scl_segment3 is not null
5679     or l_scl_segment4 is not null
5680     or l_scl_segment5 is not null
5681     or l_scl_segment6 is not null
5682     or l_scl_segment7 is not null
5683     or l_scl_segment8 is not null
5684     or l_scl_segment9 is not null
5685     or l_scl_segment10 is not null
5686     or l_scl_segment11 is not null
5687     or l_scl_segment12 is not null
5688     or l_scl_segment13 is not null
5689     or l_scl_segment14 is not null
5690     or l_scl_segment15 is not null
5691     or l_scl_segment16 is not null
5692     or l_scl_segment17 is not null
5693     or l_scl_segment18 is not null
5694     or l_scl_segment19 is not null
5695     or l_scl_segment20 is not null
5696     or l_scl_segment21 is not null
5697     or l_scl_segment22 is not null
5698     or l_scl_segment23 is not null
5699     or l_scl_segment24 is not null
5700     or l_scl_segment25 is not null
5701     or l_scl_segment26 is not null
5702     or l_scl_segment27 is not null
5703     or l_scl_segment28 is not null
5704     or l_scl_segment29 is not null
5705     or l_scl_segment30 is not null
5706     --
5707     -- Bug 944911
5708     -- Added this clause
5709     --
5710     --
5711     or p_scl_concat_segments is not null
5712     then
5713       open csr_scl_idsel;
5714       fetch csr_scl_idsel into l_scl_flex_num;
5715       if csr_scl_idsel%NOTFOUND
5716       then
5717         close csr_scl_idsel;
5718  if g_debug then
5719         hr_utility.set_location(l_proc, 28);
5720  end if;
5721         --
5722         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
5723         hr_utility.set_message_token('PROCEDURE', l_proc);
5724         hr_utility.set_message_token('STEP','10');
5725         hr_utility.raise_error;
5726       else
5727         close csr_scl_idsel;
5728         --
5729         --
5730  if g_debug then
5731         hr_utility.set_location(l_proc, 30);
5732  end if;
5733         --
5734         -- Insert or select the soft_coding_keyflex_id
5735         --
5736         hr_kflex_utility.ins_or_sel_keyflex_comb
5737         (p_appl_short_name        => 'PER'
5738         ,p_flex_code              => 'SCL'
5739         ,p_flex_num               => l_scl_flex_num
5740         ,p_segment1               => l_scl_segment1
5741         ,p_segment2               => l_scl_segment2
5742         ,p_segment3               => l_scl_segment3
5743         ,p_segment4               => l_scl_segment4
5744         ,p_segment5               => l_scl_segment5
5745         ,p_segment6               => l_scl_segment6
5746         ,p_segment7               => l_scl_segment7
5747         ,p_segment8               => l_scl_segment8
5748         ,p_segment9               => l_scl_segment9
5749         ,p_segment10              => l_scl_segment10
5750         ,p_segment11              => l_scl_segment11
5751         ,p_segment12              => l_scl_segment12
5752         ,p_segment13              => l_scl_segment13
5753         ,p_segment14              => l_scl_segment14
5754         ,p_segment15              => l_scl_segment15
5755         ,p_segment16              => l_scl_segment16
5756         ,p_segment17              => l_scl_segment17
5757         ,p_segment18              => l_scl_segment18
5758         ,p_segment19              => l_scl_segment19
5759         ,p_segment20              => l_scl_segment20
5760         ,p_segment21              => l_scl_segment21
5761         ,p_segment22              => l_scl_segment22
5762         ,p_segment23              => l_scl_segment23
5763         ,p_segment24              => l_scl_segment24
5764         ,p_segment25              => l_scl_segment25
5765         ,p_segment26              => l_scl_segment26
5766         ,p_segment27              => l_scl_segment27
5767         ,p_segment28              => l_scl_segment28
5768         ,p_segment29              => l_scl_segment29
5769         ,p_segment30              => l_scl_segment30
5770         ,p_concat_segments_in     => l_old_scl_conc_segments
5771         ,p_ccid                   => l_soft_coding_keyflex_id
5772         ,p_concat_segments_out    => l_concatenated_segments
5773         );
5774         --
5775         -- update the combinations column
5776         --
5777         update_scl_concat_segs  -- shd this be available for when id known.
5778         (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
5779         ,p_concatenated_segments   => l_concatenated_segments
5780         );
5781       --
5782       end if; --  if csr_scl_idsel%NOTFOUND
5783     --
5784     end if; -- l_scl_segment1 is not null
5785   --
5786   end if; -- bug 2359997 if soft coding key flex id came in null
5787   --
5788   --
5789   if l_pgp_null_ind = 0
5790   then
5791     --
5792     -- Insert or select the people_group_id.
5793     --
5794     hr_kflex_utility.ins_or_sel_keyflex_comb
5795     (p_appl_short_name        => 'PAY'
5796     ,p_flex_code              => 'GRP'
5797     ,p_flex_num               => l_grp_flex_num
5798     ,p_segment1               => l_pgp_segment1
5799     ,p_segment2               => l_pgp_segment2
5800     ,p_segment3               => l_pgp_segment3
5801     ,p_segment4               => l_pgp_segment4
5802     ,p_segment5               => l_pgp_segment5
5803     ,p_segment6               => l_pgp_segment6
5804     ,p_segment7               => l_pgp_segment7
5805     ,p_segment8               => l_pgp_segment8
5806     ,p_segment9               => l_pgp_segment9
5807     ,p_segment10              => l_pgp_segment10
5808     ,p_segment11              => l_pgp_segment11
5809     ,p_segment12              => l_pgp_segment12
5810     ,p_segment13              => l_pgp_segment13
5811     ,p_segment14              => l_pgp_segment14
5812     ,p_segment15              => l_pgp_segment15
5813     ,p_segment16              => l_pgp_segment16
5814     ,p_segment17              => l_pgp_segment17
5815     ,p_segment18              => l_pgp_segment18
5816     ,p_segment19              => l_pgp_segment19
5817     ,p_segment20              => l_pgp_segment20
5818     ,p_segment21              => l_pgp_segment21
5819     ,p_segment22              => l_pgp_segment22
5820     ,p_segment23              => l_pgp_segment23
5821     ,p_segment24              => l_pgp_segment24
5822     ,p_segment25              => l_pgp_segment25
5823     ,p_segment26              => l_pgp_segment26
5824     ,p_segment27              => l_pgp_segment27
5825     ,p_segment28              => l_pgp_segment28
5826     ,p_segment29              => l_pgp_segment29
5827     ,p_segment30              => l_pgp_segment30
5828     ,p_concat_segments_in     => l_old_group_name
5829     ,p_ccid                   => l_people_group_id
5830     ,p_concat_segments_out    => l_group_name
5831     );
5832     --
5833  if g_debug then
5834     hr_utility.set_location(l_proc, 35);
5835  end if;
5836   --
5837   end if;  -- bug 2359997 end if people group id null
5838   --
5839   -- update the combinations column
5840   --
5841   update_pgp_concat_segs
5842   (p_people_group_id        => l_people_group_id
5843   ,p_group_name             => l_group_name
5844   );
5845   --
5846   --
5847   if l_cag_null_ind = 0
5848   then
5849     --
5850     -- select or insert the Collective Agreement grade
5851     --
5852     hr_cgd_ins.ins_or_sel
5853     (p_segment1               => l_cag_segment1
5854     ,p_segment2               => l_cag_segment2
5855     ,p_segment3               => l_cag_segment3
5856     ,p_segment4               => l_cag_segment4
5857     ,p_segment5               => l_cag_segment5
5858     ,p_segment6               => l_cag_segment6
5859     ,p_segment7               => l_cag_segment7
5860     ,p_segment8               => l_cag_segment8
5861     ,p_segment9               => l_cag_segment9
5862     ,p_segment10              => l_cag_segment10
5863     ,p_segment11              => l_cag_segment11
5864     ,p_segment12              => l_cag_segment12
5865     ,p_segment13              => l_cag_segment13
5866     ,p_segment14              => l_cag_segment14
5867     ,p_segment15              => l_cag_segment15
5868     ,p_segment16              => l_cag_segment16
5869     ,p_segment17              => l_cag_segment17
5870     ,p_segment18              => l_cag_segment18
5871     ,p_segment19              => l_cag_segment19
5872     ,p_segment20              => l_cag_segment20
5873     ,p_id_flex_num            => p_cagr_id_flex_num
5874     ,p_business_group_id      => l_business_group_id
5875     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
5876     ,p_concatenated_segments  => l_cagr_concatenated_segments
5877      );
5878   --
5879   end if; -- l_cag_null_ind = 0 bug 2359997
5880   --
5881  if g_debug then
5882   hr_utility.set_location(l_proc, 35);
5883  end if;
5884   --
5885   --
5886   -- Insert secondary assignment
5887   --
5888   hr_assignment_internal.create_emp_asg
5889     (p_effective_date               => l_effective_date
5890     ,p_legislation_code             => l_legislation_code
5891     ,p_business_group_id            => l_business_group_id
5892     ,p_person_id                    => p_person_id
5893     ,p_organization_id              => p_organization_id
5894     ,p_primary_flag                 => 'N'
5895     ,p_period_of_service_id         => l_period_of_service_id
5896     ,p_grade_id                     => p_grade_id
5897     ,p_position_id                  => p_position_id
5898     ,p_job_id                       => p_job_id
5899     ,p_assignment_status_type_id    => p_assignment_status_type_id
5900     ,p_payroll_id                   => p_payroll_id
5901     ,p_location_id                  => p_location_id
5902     ,p_supervisor_id                => p_supervisor_id
5903     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
5904     ,p_people_group_id              => l_people_group_id
5905     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
5906     ,p_pay_basis_id                 => p_pay_basis_id
5907     ,p_assignment_number            => p_assignment_number
5908     ,p_change_reason                => p_change_reason
5909     ,p_comments                     => p_comments
5910     ,p_date_probation_end           => l_date_probation_end
5911     ,p_default_code_comb_id         => p_default_code_comb_id
5912     ,p_employment_category          => p_employment_category
5913     ,p_frequency                    => p_frequency
5914     ,p_internal_address_line        => p_internal_address_line
5915     ,p_manager_flag                 => p_manager_flag
5916     ,p_normal_hours                 => p_normal_hours
5917     ,p_perf_review_period           => p_perf_review_period
5918     ,p_perf_review_period_frequency => p_perf_review_period_frequency
5919     ,p_probation_period             => p_probation_period
5920     ,p_probation_unit               => p_probation_unit
5921     ,p_sal_review_period            => p_sal_review_period
5922     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
5923     ,p_set_of_books_id              => p_set_of_books_id
5924     ,p_source_type                  => p_source_type
5925     ,p_time_normal_finish           => p_time_normal_finish
5926     ,p_time_normal_start            => p_time_normal_start
5927     ,p_bargaining_unit_code         => p_bargaining_unit_code
5928     ,p_labour_union_member_flag     => p_labour_union_member_flag
5929     ,p_hourly_salaried_code         => p_hourly_salaried_code
5930     ,p_ass_attribute_category       => p_ass_attribute_category
5931     ,p_ass_attribute1               => p_ass_attribute1
5932     ,p_ass_attribute2               => p_ass_attribute2
5933     ,p_ass_attribute3               => p_ass_attribute3
5934     ,p_ass_attribute4               => p_ass_attribute4
5935     ,p_ass_attribute5               => p_ass_attribute5
5936     ,p_ass_attribute6               => p_ass_attribute6
5937     ,p_ass_attribute7               => p_ass_attribute7
5938     ,p_ass_attribute8               => p_ass_attribute8
5939     ,p_ass_attribute9               => p_ass_attribute9
5940     ,p_ass_attribute10              => p_ass_attribute10
5941     ,p_ass_attribute11              => p_ass_attribute11
5942     ,p_ass_attribute12              => p_ass_attribute12
5943     ,p_ass_attribute13              => p_ass_attribute13
5944     ,p_ass_attribute14              => p_ass_attribute14
5945     ,p_ass_attribute15              => p_ass_attribute15
5946     ,p_ass_attribute16              => p_ass_attribute16
5947     ,p_ass_attribute17              => p_ass_attribute17
5948     ,p_ass_attribute18              => p_ass_attribute18
5949     ,p_ass_attribute19              => p_ass_attribute19
5950     ,p_ass_attribute20              => p_ass_attribute20
5951     ,p_ass_attribute21              => p_ass_attribute21
5952     ,p_ass_attribute22              => p_ass_attribute22
5953     ,p_ass_attribute23              => p_ass_attribute23
5954     ,p_ass_attribute24              => p_ass_attribute24
5955     ,p_ass_attribute25              => p_ass_attribute25
5956     ,p_ass_attribute26              => p_ass_attribute26
5957     ,p_ass_attribute27              => p_ass_attribute27
5958     ,p_ass_attribute28              => p_ass_attribute28
5959     ,p_ass_attribute29              => p_ass_attribute29
5960     ,p_ass_attribute30              => p_ass_attribute30
5961     ,p_notice_period		    => p_notice_period
5962     ,p_notice_period_uom	    => p_notice_period_uom
5963     ,p_employee_category	    => p_employee_category
5964     ,p_work_at_home		    => p_work_at_home
5965     ,p_job_post_source_name	    => p_job_post_source_name
5966     ,p_title                        => p_title
5967     ,p_contract_id                  => p_contract_id
5968     ,p_establishment_id             => p_establishment_id
5969     ,p_collective_agreement_id      => p_collective_agreement_id
5970     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
5971     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
5972     ,p_assignment_id                => l_assignment_id
5973     ,p_object_version_number        => l_object_version_number
5974     ,p_effective_start_date         => l_effective_start_date
5975     ,p_effective_end_date           => l_effective_end_date
5976     ,p_assignment_sequence          => l_assignment_sequence
5977     ,p_comment_id                   => l_comment_id
5978     ,p_other_manager_warning        => l_other_manager_warning
5979     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
5980     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
5981     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
5982     );
5983   --
5984   -- add rows to the security table if it is a current assignment.
5985   --
5986   if(l_effective_date <= sysdate) then
5987     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
5988   end if;
5989   --
5990  if g_debug then
5991   hr_utility.set_location(l_proc, 40);
5992  end if;
5993   --
5994   begin
5995     --
5996     -- Start of API User Hook for the after hook of create_secondary_emp_asg
5997     --
5998     -- Bug 944911
5999     -- No amendments required for outs as the values carried forward
6000     -- Adding the 2 additional ins - p_concat_segments and p_pgp_concat_segments
6001     -- Both with the same value as passed to _b proc
6002     hr_assignment_bk1.create_secondary_emp_asg_a
6003       (p_effective_date               => l_effective_date
6004       ,p_person_id                    => p_person_id
6005       ,p_organization_id              => p_organization_id
6006       ,p_grade_id                     => p_grade_id
6007       ,p_position_id                  => p_position_id
6008       ,p_job_id                       => p_job_id
6009       ,p_assignment_status_type_id    => p_assignment_status_type_id
6010       ,p_payroll_id                   => p_payroll_id
6011       ,p_location_id                  => p_location_id
6012       ,p_supervisor_id                => p_supervisor_id
6013       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
6014       ,p_pay_basis_id                 => p_pay_basis_id
6015       ,p_assignment_number            => p_assignment_number
6016       ,p_change_reason                => p_change_reason
6017       ,p_comments                     => p_comments
6018       ,p_date_probation_end           => l_date_probation_end
6019       ,p_default_code_comb_id         => p_default_code_comb_id
6020       ,p_employment_category          => p_employment_category
6021       ,p_frequency                    => p_frequency
6022       ,p_internal_address_line        => p_internal_address_line
6023       ,p_manager_flag                 => p_manager_flag
6024       ,p_normal_hours                 => p_normal_hours
6025       ,p_perf_review_period           => p_perf_review_period
6026       ,p_perf_review_period_frequency => p_perf_review_period_frequency
6027       ,p_probation_period             => p_probation_period
6028       ,p_probation_unit               => p_probation_unit
6029       ,p_sal_review_period            => p_sal_review_period
6030       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
6031       ,p_set_of_books_id              => p_set_of_books_id
6032       ,p_source_type                  => p_source_type
6033       ,p_time_normal_finish           => p_time_normal_finish
6034       ,p_time_normal_start            => p_time_normal_start
6035       ,p_bargaining_unit_code         => p_bargaining_unit_code
6036       ,p_labour_union_member_flag     => p_labour_union_member_flag
6037       ,p_hourly_salaried_code         => p_hourly_salaried_code
6038       ,p_ass_attribute_category       => p_ass_attribute_category
6039       ,p_ass_attribute1               => p_ass_attribute1
6040       ,p_ass_attribute2               => p_ass_attribute2
6041       ,p_ass_attribute3               => p_ass_attribute3
6042       ,p_ass_attribute4               => p_ass_attribute4
6043       ,p_ass_attribute5               => p_ass_attribute5
6044       ,p_ass_attribute6               => p_ass_attribute6
6045       ,p_ass_attribute7               => p_ass_attribute7
6046       ,p_ass_attribute8               => p_ass_attribute8
6047       ,p_ass_attribute9               => p_ass_attribute9
6048       ,p_ass_attribute10              => p_ass_attribute10
6049       ,p_ass_attribute11              => p_ass_attribute11
6050       ,p_ass_attribute12              => p_ass_attribute12
6051       ,p_ass_attribute13              => p_ass_attribute13
6052       ,p_ass_attribute14              => p_ass_attribute14
6053       ,p_ass_attribute15              => p_ass_attribute15
6054       ,p_ass_attribute16              => p_ass_attribute16
6055       ,p_ass_attribute17              => p_ass_attribute17
6056       ,p_ass_attribute18              => p_ass_attribute18
6057       ,p_ass_attribute19              => p_ass_attribute19
6058       ,p_ass_attribute20              => p_ass_attribute20
6059       ,p_ass_attribute21              => p_ass_attribute21
6060       ,p_ass_attribute22              => p_ass_attribute22
6061       ,p_ass_attribute23              => p_ass_attribute23
6062       ,p_ass_attribute24              => p_ass_attribute24
6063       ,p_ass_attribute25              => p_ass_attribute25
6064       ,p_ass_attribute26              => p_ass_attribute26
6065       ,p_ass_attribute27              => p_ass_attribute27
6066       ,p_ass_attribute28              => p_ass_attribute28
6067       ,p_ass_attribute29              => p_ass_attribute29
6068       ,p_ass_attribute30              => p_ass_attribute30
6069       ,p_title                        => p_title
6070       ,p_scl_segment1                 => l_scl_segment1
6071       ,p_scl_segment2                 => l_scl_segment2
6072       ,p_scl_segment3                 => l_scl_segment3
6073       ,p_scl_segment4                 => l_scl_segment4
6074       ,p_scl_segment5                 => l_scl_segment5
6075       ,p_scl_segment6                 => l_scl_segment6
6076       ,p_scl_segment7                 => l_scl_segment7
6077       ,p_scl_segment8                 => l_scl_segment8
6078       ,p_scl_segment9                 => l_scl_segment9
6079       ,p_scl_segment10                => l_scl_segment10
6080       ,p_scl_segment11                => l_scl_segment11
6081       ,p_scl_segment12                => l_scl_segment12
6082       ,p_scl_segment13                => l_scl_segment13
6083       ,p_scl_segment14                => l_scl_segment14
6084       ,p_scl_segment15                => l_scl_segment15
6085       ,p_scl_segment16                => l_scl_segment16
6086       ,p_scl_segment17                => l_scl_segment17
6087       ,p_scl_segment18                => l_scl_segment18
6088       ,p_scl_segment19                => l_scl_segment19
6089       ,p_scl_segment20                => l_scl_segment20
6090       ,p_scl_segment21                => l_scl_segment21
6091       ,p_scl_segment22                => l_scl_segment22
6092       ,p_scl_segment23                => l_scl_segment23
6093       ,p_scl_segment24                => l_scl_segment24
6094       ,p_scl_segment25                => l_scl_segment25
6095       ,p_scl_segment26                => l_scl_segment26
6096       ,p_scl_segment27                => l_scl_segment27
6097       ,p_scl_segment28                => l_scl_segment28
6098       ,p_scl_segment29                => l_scl_segment29
6099       ,p_scl_segment30                => l_scl_segment30
6100       --
6101       -- Bug 944911
6102       -- Amended p_scl_concatenated_segments to p_concatenated_segments
6103       --
6104       ,p_concatenated_segments        => l_concatenated_segments
6105       ,p_pgp_segment1                 => l_pgp_segment1
6106       ,p_pgp_segment2                 => l_pgp_segment2
6107       ,p_pgp_segment3                 => l_pgp_segment3
6108       ,p_pgp_segment4                 => l_pgp_segment4
6109       ,p_pgp_segment5                 => l_pgp_segment5
6110       ,p_pgp_segment6                 => l_pgp_segment6
6111       ,p_pgp_segment7                 => l_pgp_segment7
6112       ,p_pgp_segment8                 => l_pgp_segment8
6113       ,p_pgp_segment9                 => l_pgp_segment9
6114       ,p_pgp_segment10                => l_pgp_segment10
6115       ,p_pgp_segment11                => l_pgp_segment11
6116       ,p_pgp_segment12                => l_pgp_segment12
6117       ,p_pgp_segment13                => l_pgp_segment13
6118       ,p_pgp_segment14                => l_pgp_segment14
6119       ,p_pgp_segment15                => l_pgp_segment15
6120       ,p_pgp_segment16                => l_pgp_segment16
6121       ,p_pgp_segment17                => l_pgp_segment17
6122       ,p_pgp_segment18                => l_pgp_segment18
6123       ,p_pgp_segment19                => l_pgp_segment19
6124       ,p_pgp_segment20                => l_pgp_segment20
6125       ,p_pgp_segment21                => l_pgp_segment21
6126       ,p_pgp_segment22                => l_pgp_segment22
6127       ,p_pgp_segment23                => l_pgp_segment23
6128       ,p_pgp_segment24                => l_pgp_segment24
6129       ,p_pgp_segment25                => l_pgp_segment25
6130       ,p_pgp_segment26                => l_pgp_segment26
6131       ,p_pgp_segment27                => l_pgp_segment27
6132       ,p_pgp_segment28                => l_pgp_segment28
6133       ,p_pgp_segment29                => l_pgp_segment29
6134       ,p_pgp_segment30                => l_pgp_segment30
6135       ,p_contract_id                  => p_contract_id
6136       ,p_establishment_id             => p_establishment_id
6137       ,p_collective_agreement_id      => p_collective_agreement_id
6138       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
6139       ,p_cag_segment1                 => l_cag_segment1
6140       ,p_cag_segment2                 => l_cag_segment2
6141       ,p_cag_segment3                 => l_cag_segment3
6142       ,p_cag_segment4                 => l_cag_segment4
6143       ,p_cag_segment5                 => l_cag_segment5
6144       ,p_cag_segment6                 => l_cag_segment6
6145       ,p_cag_segment7                 => l_cag_segment7
6146       ,p_cag_segment8                 => l_cag_segment8
6147       ,p_cag_segment9                 => l_cag_segment9
6148       ,p_cag_segment10                => l_cag_segment10
6149       ,p_cag_segment11                => l_cag_segment11
6150       ,p_cag_segment12                => l_cag_segment12
6151       ,p_cag_segment13                => l_cag_segment13
6152       ,p_cag_segment14                => l_cag_segment14
6153       ,p_cag_segment15                => l_cag_segment15
6154       ,p_cag_segment16                => l_cag_segment16
6155       ,p_cag_segment17                => l_cag_segment17
6156       ,p_cag_segment18                => l_cag_segment18
6157       ,p_cag_segment19                => l_cag_segment19
6158       ,p_cag_segment20                => l_cag_segment20
6159       ,p_notice_period		      => p_notice_period
6160       ,p_notice_period_uom	      => p_notice_period_uom
6161       ,p_employee_category	      => p_employee_category
6162       ,p_work_at_home		      => p_work_at_home
6163       ,p_job_post_source_name	      => p_job_post_source_name
6164       ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
6165       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
6166       ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
6167       ,p_cagr_grade_def_id            => l_cagr_grade_def_id
6168       ,p_group_name                   => l_group_name
6169       ,p_assignment_id                => l_assignment_id
6170       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
6171       ,p_people_group_id              => l_people_group_id
6172       ,p_object_version_number        => l_object_version_number
6173       ,p_effective_start_date         => l_effective_start_date
6174       ,p_effective_end_date           => l_effective_end_date
6175       ,p_assignment_sequence          => l_assignment_sequence
6176       ,p_comment_id                   => l_comment_id
6177       ,p_other_manager_warning        => l_other_manager_warning
6178       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
6179       --
6180       -- Bug 944911
6181       -- Replaced p_group_name with p_pgp_concat_segments
6182       --
6183       ,p_pgp_concat_segments          => l_old_group_name
6184       --
6185       -- Bug 944911
6186       -- Amended p_scl_concatenated_Segments by p_scl_concat_segments
6187       --
6188       ,p_scl_concat_segments          => l_old_scl_conc_segments
6189       );
6190   exception
6191     when hr_api.cannot_find_prog_unit then
6192       hr_api.cannot_find_prog_unit_error
6193         (p_module_name => 'CREATE_SECONDARY_EMP_ASG'
6194         ,p_hook_type   => 'AP'
6195         );
6196     --
6197     -- End of API User Hook for the after hook of create_secondary_emp_asg
6198     --
6199   end;
6200 
6201   --
6202   -- call pqh post process procedure -- bug 2999562
6203   --
6204   pqh_gsp_post_process.call_pp_from_assignments(
6205       p_effective_date    => p_effective_date
6206      ,p_assignment_id     => l_assignment_id    -- BUG 3336246
6207      ,p_date_track_mode   => NULL
6208      ,p_warning_mesg      => l_gsp_post_process_warning
6209   );
6210 
6211   --
6212   -- When in validation only mode raise the Validate_Enabled exception
6213   --
6214   if p_validate then
6215     raise hr_api.validate_enabled;
6216   end if;
6217   --
6218   -- Set remaining output arguments
6219   --
6220   p_assignment_id          := l_assignment_id;
6221   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
6222   p_people_group_id        := l_people_group_id;
6223   p_object_version_number  := l_object_version_number;
6224   p_effective_start_date   := l_effective_start_date;
6225   p_effective_end_date     := l_effective_end_date;
6226   p_assignment_sequence    := l_assignment_sequence;
6227   p_comment_id             := l_comment_id;
6228   p_concatenated_segments  := l_concatenated_segments;
6229   p_group_name             := l_group_name;
6230   p_other_manager_warning  := l_other_manager_warning;
6231   p_cagr_grade_def_id           := l_cagr_grade_def_id;
6232   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
6233   p_hourly_salaried_warning     := l_hourly_salaried_warning;
6234   p_gsp_post_process_warning    := l_gsp_post_process_warning; -- bug 2999562
6235   --
6236   -- remove data from the session table
6237   hr_kflex_utility.unset_session_date
6238   (p_session_id     => l_session_id);
6239   --
6240  if g_debug then
6241   hr_utility.set_location(' Leaving:'||l_proc, 50);
6242  end if;
6243 exception
6244   when hr_api.validate_enabled then
6245     --
6246     -- As the Validate_Enabled exception has been raised
6247     -- we must rollback to the savepoint
6248     --
6249     ROLLBACK TO create_secondary_emp_asg;
6250     --
6251     -- Only set output warning arguments
6252     -- (Any key or derived arguments must be set to null
6253     -- when validation only mode is being used.)
6254     --
6255     p_assignment_number      := l_assignment_number;
6256     p_assignment_id          := null;
6257     p_object_version_number  := null;
6258     p_effective_start_date   := null;
6259     p_effective_end_date     := null;
6260     p_assignment_sequence    := null;
6261     p_comment_id             := null;
6262     p_concatenated_segments  := l_old_scl_conc_segments;  -- Bug 944911
6263     p_group_name             := l_old_group_name;
6264     p_other_manager_warning  := l_other_manager_warning;
6265     p_hourly_salaried_warning     := l_hourly_salaried_warning;
6266     --
6267     p_cagr_concatenated_segments  := null;
6268     --
6269     -- bug 2359997 only re-set to null if key flex ids came in as null.
6270     --
6271     if l_pgp_null_ind = 0
6272     then
6273        p_people_group_id           := null;
6274     end if;
6275     if l_scl_null_ind = 0
6276     then
6277        p_soft_coding_keyflex_id    := null;
6278     end if;
6279     if l_cag_null_ind = 0
6280     then
6281        p_cagr_grade_def_id         := null;
6282     end if;
6283     --
6284     --
6285   when others then
6286     --
6287     -- A validation or unexpected error has occurred
6288     --
6289     -- Added as part of fix to bug 632479
6290     --
6291     p_assignment_number      := lv_assignment_number ;
6292     p_cagr_grade_def_id      := lv_cagr_grade_def_id ;
6293     p_soft_coding_keyflex_id := lv_soft_coding_keyflex_id ;
6294     p_people_group_id        := lv_people_group_id ;
6295 
6296     p_object_version_number      := null;
6297     p_effective_start_date       := null;
6298     p_effective_end_date         := null;
6299     p_assignment_sequence        := null;
6300     p_comment_id                 := null;
6301     p_other_manager_warning      := null;
6302     p_hourly_salaried_warning    := null;
6303     p_cagr_concatenated_segments := null;
6304     p_assignment_id              := null;
6305     p_concatenated_segments      := null;
6306     p_group_name                 := null;
6307     p_gsp_post_process_warning   := null;
6308 
6309     ROLLBACK TO create_secondary_emp_asg;
6310     raise;
6311     --
6312     -- End of fix.
6313     --
6314 end create_secondary_emp_asg;
6315 --
6316 -- ----------------------------------------------------------------------------
6317 -- |---------------------< create_secondary_cwk_asg >-------------------------|
6318 -- ----------------------------------------------------------------------------
6319 --
6320 procedure create_secondary_cwk_asg
6321   (p_validate                     in     boolean
6322   ,p_effective_date               in     date
6323   ,p_business_group_id            in     number
6324   ,p_person_id                    in     number
6325   ,p_organization_id              in     number
6326   ,p_assignment_number            in out nocopy varchar2
6327   ,p_assignment_category          in     varchar2
6328   ,p_assignment_status_type_id    in     number
6329   ,p_change_reason                in     varchar2
6330   ,p_comments                     in     varchar2
6331   ,p_default_code_comb_id         in     number
6332   ,p_establishment_id             in     number
6333   ,p_frequency                    in     varchar2
6334   ,p_internal_address_line        in     varchar2
6335   ,p_job_id                       in     number
6336   ,p_labour_union_member_flag     in     varchar2
6337   ,p_location_id                  in     number
6338   ,p_manager_flag                 in     varchar2
6339   ,p_normal_hours                 in     number
6340   ,p_position_id                  in     number
6341   ,p_grade_id                     in     number
6342   ,p_project_title                in     varchar2
6343   ,p_set_of_books_id              in     number
6344   ,p_source_type                  in     varchar2
6345   ,p_supervisor_id                in     number
6346   ,p_time_normal_finish           in     varchar2
6347   ,p_time_normal_start            in     varchar2
6348   ,p_title                        in     varchar2
6349   ,p_vendor_assignment_number     in     varchar2
6350   ,p_vendor_employee_number       in     varchar2
6351   ,p_vendor_id                    in     number
6352   ,p_vendor_site_id               in     number
6353   ,p_po_header_id                 in     number
6354   ,p_po_line_id                   in     number
6355   ,p_projected_assignment_end     in     date
6356   ,p_attribute_category           in     varchar2
6357   ,p_attribute1                   in     varchar2
6358   ,p_attribute2                   in     varchar2
6359   ,p_attribute3                   in     varchar2
6360   ,p_attribute4                   in     varchar2
6361   ,p_attribute5                   in     varchar2
6362   ,p_attribute6                   in     varchar2
6363   ,p_attribute7                   in     varchar2
6364   ,p_attribute8                   in     varchar2
6365   ,p_attribute9                   in     varchar2
6366   ,p_attribute10                  in     varchar2
6367   ,p_attribute11                  in     varchar2
6368   ,p_attribute12                  in     varchar2
6369   ,p_attribute13                  in     varchar2
6370   ,p_attribute14                  in     varchar2
6371   ,p_attribute15                  in     varchar2
6372   ,p_attribute16                  in     varchar2
6373   ,p_attribute17                  in     varchar2
6374   ,p_attribute18                  in     varchar2
6375   ,p_attribute19                  in     varchar2
6376   ,p_attribute20                  in     varchar2
6377   ,p_attribute21                  in     varchar2
6378   ,p_attribute22                  in     varchar2
6379   ,p_attribute23                  in     varchar2
6380   ,p_attribute24                  in     varchar2
6381   ,p_attribute25                  in     varchar2
6382   ,p_attribute26                  in     varchar2
6383   ,p_attribute27                  in     varchar2
6384   ,p_attribute28                  in     varchar2
6385   ,p_attribute29                  in     varchar2
6386   ,p_attribute30                  in     varchar2
6387   ,p_pgp_segment1                 in     varchar2
6388   ,p_pgp_segment2                 in     varchar2
6389   ,p_pgp_segment3                 in     varchar2
6390   ,p_pgp_segment4                 in     varchar2
6391   ,p_pgp_segment5                 in     varchar2
6392   ,p_pgp_segment6                 in     varchar2
6393   ,p_pgp_segment7                 in     varchar2
6394   ,p_pgp_segment8                 in     varchar2
6395   ,p_pgp_segment9                 in     varchar2
6396   ,p_pgp_segment10                in     varchar2
6397   ,p_pgp_segment11                in     varchar2
6398   ,p_pgp_segment12                in     varchar2
6399   ,p_pgp_segment13                in     varchar2
6400   ,p_pgp_segment14                in     varchar2
6401   ,p_pgp_segment15                in     varchar2
6402   ,p_pgp_segment16                in     varchar2
6403   ,p_pgp_segment17                in     varchar2
6404   ,p_pgp_segment18                in     varchar2
6405   ,p_pgp_segment19                in     varchar2
6406   ,p_pgp_segment20                in     varchar2
6407   ,p_pgp_segment21                in     varchar2
6408   ,p_pgp_segment22                in     varchar2
6409   ,p_pgp_segment23                in     varchar2
6410   ,p_pgp_segment24                in     varchar2
6411   ,p_pgp_segment25                in     varchar2
6412   ,p_pgp_segment26                in     varchar2
6413   ,p_pgp_segment27                in     varchar2
6414   ,p_pgp_segment28                in     varchar2
6415   ,p_pgp_segment29                in     varchar2
6416   ,p_pgp_segment30                in     varchar2
6417   ,p_scl_segment1                 in     varchar2
6418   ,p_scl_segment2                 in     varchar2
6419   ,p_scl_segment3                 in     varchar2
6420   ,p_scl_segment4                 in     varchar2
6421   ,p_scl_segment5                 in     varchar2
6422   ,p_scl_segment6                 in     varchar2
6423   ,p_scl_segment7                 in     varchar2
6424   ,p_scl_segment8                 in     varchar2
6425   ,p_scl_segment9                 in     varchar2
6426   ,p_scl_segment10                in     varchar2
6427   ,p_scl_segment11                in     varchar2
6428   ,p_scl_segment12                in     varchar2
6429   ,p_scl_segment13                in     varchar2
6430   ,p_scl_segment14                in     varchar2
6431   ,p_scl_segment15                in     varchar2
6432   ,p_scl_segment16                in     varchar2
6433   ,p_scl_segment17                in     varchar2
6434   ,p_scl_segment18                in     varchar2
6435   ,p_scl_segment19                in     varchar2
6436   ,p_scl_segment20                in     varchar2
6437   ,p_scl_segment21                in     varchar2
6438   ,p_scl_segment22                in     varchar2
6439   ,p_scl_segment23                in     varchar2
6440   ,p_scl_segment24                in     varchar2
6441   ,p_scl_segment25                in     varchar2
6442   ,p_scl_segment26                in     varchar2
6443   ,p_scl_segment27                in     varchar2
6444   ,p_scl_segment28                in     varchar2
6445   ,p_scl_segment29                in     varchar2
6446   ,p_scl_segment30                in     varchar2
6447   ,p_scl_concat_segments          in     varchar2
6448   ,p_pgp_concat_segments	  in     varchar2
6449   ,p_supervisor_assignment_id     in     number
6450   ,p_assignment_id                   out nocopy number
6451   ,p_object_version_number           out nocopy number
6452   ,p_effective_start_date            out nocopy date
6453   ,p_effective_end_date              out nocopy date
6454   ,p_assignment_sequence             out nocopy number
6455   ,p_comment_id                      out nocopy number
6456   ,p_people_group_id                 out nocopy number
6457   ,p_people_group_name               out nocopy varchar2
6458   ,p_other_manager_warning           out nocopy boolean
6459   ,p_hourly_salaried_warning         out nocopy boolean
6460   ,p_soft_coding_keyflex_id          out nocopy number) IS
6461   --
6462   -- Declare LOCAL Variables
6463   --
6464   l_proc                    VARCHAR2(72) := g_package||'create_secondary_cwk_asg';
6465   l_effective_date          DATE;
6466   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
6467   l_old_group_name          pay_people_groups.group_name%TYPE;
6468   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
6469   l_other_manager_warning   BOOLEAN;
6470   l_hourly_salaried_warning BOOLEAN;
6471   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
6472   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE;
6473   l_people_group_id         per_all_assignments_f.people_group_id%TYPE;
6474   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
6475   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
6476   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
6477   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
6478   l_comment_id              per_all_assignments_f.comment_id%TYPE;
6479   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
6480   l_group_name              pay_people_groups.group_name%TYPE;
6481   l_session_id              NUMBER;
6482   l_business_group_id       per_business_groups.business_group_id%TYPE;
6483   l_legislation_code        per_business_groups.legislation_code%TYPE;
6484   l_pop_date_start          DATE;
6485   --l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
6486   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
6487   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
6488   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
6489   l_vendor_id               NUMBER := p_vendor_id;
6490   l_vendor_site_id          NUMBER := p_vendor_site_id;
6491   l_po_header_id            NUMBER := p_po_header_id;
6492   l_vendor_id_temp          NUMBER;
6493   l_vendor_site_id_temp     NUMBER;
6494   l_grade_id                NUMBER := Null; -- Bug 3545065
6495   --
6496   lv_assignment_number      varchar2(2000) :=   p_assignment_number ;
6497   --
6498   -- Declare Cursors
6499   --
6500   cursor csr_get_derived_details is
6501     select bus.business_group_id
6502          , bus.legislation_code
6503       from per_all_people_f    per
6504          , per_business_groups_perf bus
6505      where per.person_id         = p_person_id
6506      and   l_effective_date      between per.effective_start_date
6507                                  and     per.effective_end_date
6508      and   bus.business_group_id = per.business_group_id;
6509   --
6510   cursor csr_get_period_of_placement is
6511     select asg.period_of_placement_date_start
6512       from per_all_assignments_f asg
6513      where asg.person_id    = p_person_id
6514      and   l_effective_date between asg.effective_start_date
6515                             and     asg.effective_end_date
6516      and   asg.primary_flag = 'Y'
6517      and asg.assignment_type = 'C'; -- Bug fix 3266813
6518   --
6519   -- the cursor csr_grp_idsel selects the valid id_flex_num
6520   -- (grp keyflex) for the specified business group
6521   --
6522   cursor csr_grp_idsel is
6523     select people_group_structure
6524       from per_business_groups_perf
6525       where business_group_id = l_business_group_id;
6526   --
6527   --
6528   -- the cursor csr_scl_idsel selects the valid id_flex_num
6529   -- (scl keyflex) for the specified business group
6530   --
6531   cursor csr_scl_idsel is
6532     select plr.rule_mode                       id_flex_num
6533     from   pay_legislation_rules               plr
6534     where  plr.legislation_code                = l_legislation_code
6535     and    plr.rule_type                       = 'S'
6536     and    exists
6537           (select 1
6538            from   fnd_segment_attribute_values fsav
6539            where  to_char(fsav.id_flex_num)    = plr.rule_mode   --Fix For Bug 12813119
6540            and    fsav.application_id          = 800
6541            and    fsav.id_flex_code            = 'SCL'
6542            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
6543            and    fsav.attribute_value         = 'Y')
6544     and    exists
6545           (select 1
6546            from   pay_legislation_rules        plr2
6547            where  plr2.legislation_code        = l_legislation_code
6548            and    plr2.rule_type               = 'SDL'
6549            and    plr2.rule_mode               = 'A') ;
6550   --
6551 
6552 BEGIN
6553   --
6554  if g_debug then
6555   hr_utility.set_location('Entering:'|| l_proc, 5);
6556  end if;
6557   --
6558   -- Issue a savepoint.
6559   --
6560   -- Truncate the parameter p_effective_date and p_date_probation_end
6561   -- into local variables
6562   --
6563   l_effective_date := trunc(p_effective_date);
6564   --
6565   -- Bug 944911
6566   -- Amended p_scl_concatenated_segments to p_scl_concat_segments
6567   -- to be an out instead of in out
6568   --
6569   l_old_scl_conc_segments := p_scl_concat_segments;
6570   --
6571   -- Bug 944911
6572   -- Made p_group_name to be out param
6573   -- and add p_concat_segment to be IN
6574   -- in case of sec_asg alone made p_pgp_concat_segments as in param
6575   -- Replaced p_group_name by p_pgp_concat_segments
6576   --
6577   l_old_group_name := p_pgp_concat_segments;
6578   --
6579   SAVEPOINT create_secondary_cwk_asg;
6580   --
6581   BEGIN
6582     --
6583     -- Start of API User Hook for the before hook of create_secondary_emp_asg
6584     --
6585     hr_assignment_bkn.create_secondary_cwk_asg_b
6586       (p_effective_date               => l_effective_date
6587       ,p_business_group_id            => p_business_group_id
6588       ,p_person_id                    => p_person_id
6589       ,p_organization_id              => p_organization_id
6590       ,p_assignment_number            => p_assignment_number
6591       ,p_assignment_category          => p_assignment_category
6592       ,p_assignment_status_type_id    => p_assignment_status_type_id
6593       ,p_change_reason                => p_change_reason
6594       ,p_comments                     => p_comments
6595       ,p_default_code_comb_id         => p_default_code_comb_id
6596       ,p_establishment_id             => p_establishment_id
6597       ,p_frequency                    => p_frequency
6598       ,p_internal_address_line        => p_internal_address_line
6599       ,p_job_id                       => p_job_id
6600       ,p_labour_union_member_flag     => p_labour_union_member_flag
6601       ,p_location_id                  => p_location_id
6602       ,p_manager_flag                 => p_manager_flag
6603       ,p_normal_hours                 => p_normal_hours
6604       ,p_position_id                  => p_position_id
6605       ,p_grade_id                     => l_grade_id -- Bug 3545065
6606       ,p_project_title                => p_project_title
6607       ,p_set_of_books_id              => p_set_of_books_id
6608       ,p_source_type                  => p_source_type
6609       ,p_supervisor_id                => p_supervisor_id
6610       ,p_time_normal_finish           => p_time_normal_finish
6611       ,p_time_normal_start            => p_time_normal_start
6612       ,p_title                        => p_title
6613       ,p_vendor_assignment_number     => p_vendor_assignment_number
6614       ,p_vendor_employee_number       => p_vendor_employee_number
6615       ,p_vendor_id                    => p_vendor_id
6616       ,p_vendor_site_id               => p_vendor_site_id
6617       ,p_po_header_id                 => p_po_header_id
6618       ,p_po_line_id                   => p_po_line_id
6619       ,p_projected_assignment_end     => p_projected_assignment_end
6620       ,p_attribute_category           => p_attribute_category
6621       ,p_attribute1                   => p_attribute1
6622       ,p_attribute2                   => p_attribute2
6623       ,p_attribute3                   => p_attribute3
6624       ,p_attribute4                   => p_attribute4
6625       ,p_attribute5                   => p_attribute5
6626       ,p_attribute6                   => p_attribute6
6627       ,p_attribute7                   => p_attribute7
6628       ,p_attribute8                   => p_attribute8
6629       ,p_attribute9                   => p_attribute9
6630       ,p_attribute10                  => p_attribute10
6631       ,p_attribute11                  => p_attribute11
6632       ,p_attribute12                  => p_attribute12
6633       ,p_attribute13                  => p_attribute13
6634       ,p_attribute14                  => p_attribute14
6635       ,p_attribute15                  => p_attribute15
6636       ,p_attribute16                  => p_attribute16
6637       ,p_attribute17                  => p_attribute17
6638       ,p_attribute18                  => p_attribute18
6639       ,p_attribute19                  => p_attribute19
6640       ,p_attribute20                  => p_attribute20
6641       ,p_attribute21                  => p_attribute21
6642       ,p_attribute22                  => p_attribute22
6643       ,p_attribute23                  => p_attribute23
6644       ,p_attribute24                  => p_attribute24
6645       ,p_attribute25                  => p_attribute25
6646       ,p_attribute26                  => p_attribute26
6647       ,p_attribute27                  => p_attribute27
6648       ,p_attribute28                  => p_attribute28
6649       ,p_attribute29                  => p_attribute29
6650       ,p_attribute30                  => p_attribute30
6651    	  ,p_scl_concat_segments          => l_old_scl_conc_segments
6652       ,p_pgp_segment1                 => p_pgp_segment1
6653       ,p_pgp_segment2                 => p_pgp_segment2
6654       ,p_pgp_segment3                 => p_pgp_segment3
6655       ,p_pgp_segment4                 => p_pgp_segment4
6656       ,p_pgp_segment5                 => p_pgp_segment5
6657       ,p_pgp_segment6                 => p_pgp_segment6
6658       ,p_pgp_segment7                 => p_pgp_segment7
6659       ,p_pgp_segment8                 => p_pgp_segment8
6660       ,p_pgp_segment9                 => p_pgp_segment9
6661       ,p_pgp_segment10                => p_pgp_segment10
6662       ,p_pgp_segment11                => p_pgp_segment11
6663       ,p_pgp_segment12                => p_pgp_segment12
6664       ,p_pgp_segment13                => p_pgp_segment13
6665       ,p_pgp_segment14                => p_pgp_segment14
6666       ,p_pgp_segment15                => p_pgp_segment15
6667       ,p_pgp_segment16                => p_pgp_segment16
6668       ,p_pgp_segment17                => p_pgp_segment17
6669       ,p_pgp_segment18                => p_pgp_segment18
6670       ,p_pgp_segment19                => p_pgp_segment19
6671       ,p_pgp_segment20                => p_pgp_segment20
6672       ,p_pgp_segment21                => p_pgp_segment21
6673       ,p_pgp_segment22                => p_pgp_segment22
6674       ,p_pgp_segment23                => p_pgp_segment23
6675       ,p_pgp_segment24                => p_pgp_segment24
6676       ,p_pgp_segment25                => p_pgp_segment25
6677       ,p_pgp_segment26                => p_pgp_segment26
6678       ,p_pgp_segment27                => p_pgp_segment27
6679       ,p_pgp_segment28                => p_pgp_segment28
6680       ,p_pgp_segment29                => p_pgp_segment29
6681       ,p_pgp_segment30                => p_pgp_segment30
6682       ,p_scl_segment1                 => p_scl_segment1
6683       ,p_scl_segment2                 => p_scl_segment2
6684       ,p_scl_segment3                 => p_scl_segment3
6685       ,p_scl_segment4                 => p_scl_segment4
6686       ,p_scl_segment5                 => p_scl_segment5
6687       ,p_scl_segment6                 => p_scl_segment6
6688       ,p_scl_segment7                 => p_scl_segment7
6689       ,p_scl_segment8                 => p_scl_segment8
6690       ,p_scl_segment9                 => p_scl_segment9
6691       ,p_scl_segment10                => p_scl_segment10
6692       ,p_scl_segment11                => p_scl_segment11
6693       ,p_scl_segment12                => p_scl_segment12
6694       ,p_scl_segment13                => p_scl_segment13
6695       ,p_scl_segment14                => p_scl_segment14
6696       ,p_scl_segment15                => p_scl_segment15
6697       ,p_scl_segment16                => p_scl_segment16
6698       ,p_scl_segment17                => p_scl_segment17
6699       ,p_scl_segment18                => p_scl_segment18
6700       ,p_scl_segment19                => p_scl_segment19
6701       ,p_scl_segment20                => p_scl_segment20
6702       ,p_scl_segment21                => p_scl_segment21
6703       ,p_scl_segment22                => p_scl_segment22
6704       ,p_scl_segment23                => p_scl_segment23
6705       ,p_scl_segment24                => p_scl_segment24
6706       ,p_scl_segment25                => p_scl_segment25
6707       ,p_scl_segment26                => p_scl_segment26
6708       ,p_scl_segment27                => p_scl_segment27
6709       ,p_scl_segment28                => p_scl_segment28
6710       ,p_scl_segment29                => p_scl_segment29
6711       ,p_scl_segment30                => p_scl_segment30
6712       ,p_pgp_concat_segments          => l_old_group_name
6713       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
6714       );
6715     --
6716   EXCEPTION
6717     WHEN hr_api.cannot_find_prog_unit THEN
6718       hr_api.cannot_find_prog_unit_error
6719         (p_module_name => 'CREATE_SECONDARY_CWK_ASG'
6720         ,p_hook_type   => 'BP');
6721     --
6722     -- End of API User Hook for the before hook of create_secondary_emp_asg
6723     --
6724   END;
6725   --
6726  if g_debug then
6727   hr_utility.set_location(l_proc, 10);
6728  end if;
6729   --
6730   -- Validation in addition to Table Handlers
6731   --
6732   -- Get person details.
6733   --
6734   hr_api.mandatory_arg_error
6735      (p_api_name       => l_proc
6736      ,p_argument       => 'person_id'
6737      ,p_argument_value => p_person_id
6738      );
6739   --
6740   hr_api.mandatory_arg_error
6741      (p_api_name       => l_proc
6742      ,p_argument       => 'effective_date'
6743      ,p_argument_value => l_effective_date
6744      );
6745   --
6746   -- Record the value of in out parameters
6747   --
6748   l_assignment_number := p_assignment_number;
6749   --
6750   OPEN  csr_get_derived_details;
6751   FETCH csr_get_derived_details
6752    INTO l_business_group_id
6753       , l_legislation_code;
6754   --
6755   if csr_get_derived_details%NOTFOUND then
6756     --
6757     close csr_get_derived_details;
6758     --
6759  if g_debug then
6760     hr_utility.set_location(l_proc, 15);
6761  end if;
6762     --
6763     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
6764     hr_utility.raise_error;
6765 	--
6766   end if;
6767   --
6768   close csr_get_derived_details;
6769   --
6770  if g_debug then
6771   hr_utility.set_location(l_proc, 20);
6772  end if;
6773   --
6774   -- Process Logic
6775   --
6776   -- Get period of service from primary assignment.
6777   --
6778   OPEN  csr_get_period_of_placement;
6779   FETCH csr_get_period_of_placement INTO l_pop_date_start;
6780   --
6781   IF csr_get_period_of_placement%NOTFOUND THEN
6782     --
6783     CLOSE csr_get_period_of_placement;
6784     --
6785  if g_debug then
6786     hr_utility.set_location(l_proc, 25);
6787  end if;
6788     --
6789 	hr_utility.set_message(801,'HR_7436_ASG_NO_PRIM_ASS');
6790     hr_utility.raise_error;
6791 	--
6792   END IF;
6793   --
6794   CLOSE csr_get_period_of_placement;
6795   --
6796  if g_debug then
6797   hr_utility.set_location(l_proc, 26);
6798  end if;
6799   --
6800   -- insert the profile options and effective date for the flexfield
6801   -- validation to work
6802   --
6803   hr_kflex_utility.set_profiles
6804     (p_business_group_id => l_business_group_id
6805     ,p_assignment_id     => l_assignment_id
6806     ,p_organization_id   => p_organization_id
6807     ,p_location_id       => p_location_id);
6808   --
6809   hr_kflex_utility.set_session_date
6810     (p_effective_date => l_effective_date
6811     ,p_session_id     => l_session_id);
6812   --
6813   open csr_grp_idsel;
6814   fetch csr_grp_idsel into l_grp_flex_num;
6815   --
6816   if csr_grp_idsel%NOTFOUND then
6817     --
6818     close csr_grp_idsel;
6819 	--
6820     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
6821     hr_utility.set_message_token('PROCEDURE', l_proc);
6822     hr_utility.set_message_token('STEP','5');
6823     hr_utility.raise_error;
6824 	--
6825   else
6826     --
6827     close csr_grp_idsel;
6828 	--
6829   end if;
6830   --
6831  if g_debug then
6832   hr_utility.set_location(l_proc, 27);
6833  end if;
6834   --
6835   if   p_scl_segment1 is not null
6836     or p_scl_segment2 is not null
6837     or p_scl_segment3 is not null
6838     or p_scl_segment4 is not null
6839     or p_scl_segment5 is not null
6840     or p_scl_segment6 is not null
6841     or p_scl_segment7 is not null
6842     or p_scl_segment8 is not null
6843     or p_scl_segment9 is not null
6844     or p_scl_segment10 is not null
6845     or p_scl_segment11 is not null
6846     or p_scl_segment12 is not null
6847     or p_scl_segment13 is not null
6848     or p_scl_segment14 is not null
6849     or p_scl_segment15 is not null
6850     or p_scl_segment16 is not null
6851     or p_scl_segment17 is not null
6852     or p_scl_segment18 is not null
6853     or p_scl_segment19 is not null
6854     or p_scl_segment20 is not null
6855     or p_scl_segment21 is not null
6856     or p_scl_segment22 is not null
6857     or p_scl_segment23 is not null
6858     or p_scl_segment24 is not null
6859     or p_scl_segment25 is not null
6860     or p_scl_segment26 is not null
6861     or p_scl_segment27 is not null
6862     or p_scl_segment28 is not null
6863     or p_scl_segment29 is not null
6864     or p_scl_segment30 is not null
6865     or p_scl_concat_segments is not null then
6866 	--
6867     open csr_scl_idsel;
6868     fetch csr_scl_idsel into l_scl_flex_num;
6869 	--
6870     if csr_scl_idsel%NOTFOUND then
6871 	  --
6872       close csr_scl_idsel;
6873 	  --
6874  if g_debug then
6875       hr_utility.set_location(l_proc, 28);
6876  end if;
6877       hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
6878       hr_utility.set_message_token('PROCEDURE', l_proc);
6879       hr_utility.set_message_token('STEP','10');
6880       hr_utility.raise_error;
6881 	  --
6882     else
6883 	  --
6884       close csr_scl_idsel;
6885       --
6886  if g_debug then
6887       hr_utility.set_location(l_proc, 30);
6888  end if;
6889       --
6890       -- Insert or select the soft_coding_keyflex_id
6891       --
6892       hr_kflex_utility.ins_or_sel_keyflex_comb
6893         (p_appl_short_name        => 'PER'
6894         ,p_flex_code              => 'SCL'
6895         ,p_flex_num               => l_scl_flex_num
6896         ,p_segment1               => p_scl_segment1
6897         ,p_segment2               => p_scl_segment2
6898         ,p_segment3               => p_scl_segment3
6899         ,p_segment4               => p_scl_segment4
6900         ,p_segment5               => p_scl_segment5
6901         ,p_segment6               => p_scl_segment6
6902         ,p_segment7               => p_scl_segment7
6903         ,p_segment8               => p_scl_segment8
6904         ,p_segment9               => p_scl_segment9
6905         ,p_segment10              => p_scl_segment10
6906         ,p_segment11              => p_scl_segment11
6907         ,p_segment12              => p_scl_segment12
6908         ,p_segment13              => p_scl_segment13
6909         ,p_segment14              => p_scl_segment14
6910         ,p_segment15              => p_scl_segment15
6911         ,p_segment16              => p_scl_segment16
6912         ,p_segment17              => p_scl_segment17
6913         ,p_segment18              => p_scl_segment18
6914         ,p_segment19              => p_scl_segment19
6915         ,p_segment20              => p_scl_segment20
6916         ,p_segment21              => p_scl_segment21
6917         ,p_segment22              => p_scl_segment22
6918         ,p_segment23              => p_scl_segment23
6919         ,p_segment24              => p_scl_segment24
6920         ,p_segment25              => p_scl_segment25
6921         ,p_segment26              => p_scl_segment26
6922         ,p_segment27              => p_scl_segment27
6923         ,p_segment28              => p_scl_segment28
6924         ,p_segment29              => p_scl_segment29
6925         ,p_segment30              => p_scl_segment30
6926         ,p_concat_segments_in     => l_old_scl_conc_segments
6927         ,p_ccid                   => l_soft_coding_keyflex_id
6928         ,p_concat_segments_out    => l_concatenated_segments);
6929       --
6930       -- update the combinations column
6931       --
6932       update_scl_concat_segs
6933       (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
6934       ,p_concatenated_segments   => l_concatenated_segments
6935       );
6936       --
6937     end if;
6938     --
6939   end if;
6940   --
6941   -- Insert of select the people_group_id.
6942   --
6943   hr_kflex_utility.ins_or_sel_keyflex_comb
6944     (p_appl_short_name        => 'PAY'
6945     ,p_flex_code              => 'GRP'
6946     ,p_flex_num               => l_grp_flex_num
6947     ,p_segment1               => p_pgp_segment1
6948     ,p_segment2               => p_pgp_segment2
6949     ,p_segment3               => p_pgp_segment3
6950     ,p_segment4               => p_pgp_segment4
6951     ,p_segment5               => p_pgp_segment5
6952     ,p_segment6               => p_pgp_segment6
6953     ,p_segment7               => p_pgp_segment7
6954     ,p_segment8               => p_pgp_segment8
6955     ,p_segment9               => p_pgp_segment9
6956     ,p_segment10              => p_pgp_segment10
6957     ,p_segment11              => p_pgp_segment11
6958     ,p_segment12              => p_pgp_segment12
6959     ,p_segment13              => p_pgp_segment13
6960     ,p_segment14              => p_pgp_segment14
6961     ,p_segment15              => p_pgp_segment15
6962     ,p_segment16              => p_pgp_segment16
6963     ,p_segment17              => p_pgp_segment17
6964     ,p_segment18              => p_pgp_segment18
6965     ,p_segment19              => p_pgp_segment19
6966     ,p_segment20              => p_pgp_segment20
6967     ,p_segment21              => p_pgp_segment21
6968     ,p_segment22              => p_pgp_segment22
6969     ,p_segment23              => p_pgp_segment23
6970     ,p_segment24              => p_pgp_segment24
6971     ,p_segment25              => p_pgp_segment25
6972     ,p_segment26              => p_pgp_segment26
6973     ,p_segment27              => p_pgp_segment27
6974     ,p_segment28              => p_pgp_segment28
6975     ,p_segment29              => p_pgp_segment29
6976     ,p_segment30              => p_pgp_segment30
6977     ,p_concat_segments_in     => l_old_group_name
6978     ,p_ccid                   => l_people_group_id
6979     ,p_concat_segments_out    => l_group_name
6980     );
6981   --
6982  if g_debug then
6983   hr_utility.set_location(l_proc, 35);
6984  end if;
6985 
6986   --
6987   -- Default the PO Header if the line is passed in and the
6988   -- header is not.
6989   --
6990   IF p_po_line_id IS NOT NULL AND l_po_header_id IS NULL THEN
6991 
6992     l_po_header_id := get_po_for_line
6993       (p_po_line_id => p_po_line_id);
6994 
6995   END IF;
6996 
6997   --
6998   -- Default the Supplier if the Site is entered and Supplier is not.
6999   --
7000   IF l_vendor_site_id IS NOT NULL AND l_vendor_id IS NULL THEN
7001 
7002     l_vendor_id := get_supplier_for_site
7003       (p_vendor_site_id => l_vendor_site_id);
7004 
7005   END IF;
7006 
7007   --
7008   -- Default the supplier details if they are not entered and a
7009   -- PO is given.
7010   --
7011   IF l_po_header_id IS NOT NULL
7012   AND (l_vendor_id IS NULL OR l_vendor_site_id IS NULL) THEN
7013 
7014     --
7015     -- Copy the variables temporarily so that if one or the
7016     -- other values are passed in, the below call does not
7017     -- override them.  A single call is made because it is
7018     -- more performant.
7019     --
7020     get_supplier_info_for_po
7021       (p_po_header_id   => l_po_header_id
7022       ,p_vendor_id      => l_vendor_id_temp
7023       ,p_vendor_site_id => l_vendor_site_id_temp);
7024 
7025     IF l_vendor_id IS NULL THEN
7026       l_vendor_id := l_vendor_id_temp;
7027     END IF;
7028 
7029     IF l_vendor_site_id IS NULL THEN
7030       l_vendor_site_id := l_vendor_site_id_temp;
7031     END IF;
7032 
7033   END IF;
7034 
7035  if g_debug then
7036   hr_utility.set_location(l_proc, 37);
7037  end if;
7038 
7039   --
7040   -- update the combinations column
7041   --
7042   update_pgp_concat_segs
7043     (p_people_group_id        => l_people_group_id
7044     ,p_group_name             => l_group_name);
7045   --
7046   -- select or insert the Collective Agreement grade
7047   --
7048   /*
7049   hr_cgd_ins.ins_or_sel
7050     (p_segment1               => p_cag_segment1
7051     ,p_segment2               => p_cag_segment2
7052     ,p_segment3               => p_cag_segment3
7053     ,p_segment4               => p_cag_segment4
7054     ,p_segment5               => p_cag_segment5
7055     ,p_segment6               => p_cag_segment6
7056     ,p_segment7               => p_cag_segment7
7057     ,p_segment8               => p_cag_segment8
7058     ,p_segment9               => p_cag_segment9
7059     ,p_segment10              => p_cag_segment10
7060     ,p_segment11              => p_cag_segment11
7061     ,p_segment12              => p_cag_segment12
7062     ,p_segment13              => p_cag_segment13
7063     ,p_segment14              => p_cag_segment14
7064     ,p_segment15              => p_cag_segment15
7065     ,p_segment16              => p_cag_segment16
7066     ,p_segment17              => p_cag_segment17
7067     ,p_segment18              => p_cag_segment18
7068     ,p_segment19              => p_cag_segment19
7069     ,p_segment20              => p_cag_segment20
7070     ,p_id_flex_num            => p_cagr_id_flex_num
7071     ,p_business_group_id      => l_business_group_id
7072     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
7073     ,p_concatenated_segments  => l_cagr_concatenated_segments);
7074 	*/
7075   --
7076   -- Insert secondary assignment
7077   --
7078   hr_assignment_internal.create_cwk_asg
7079     (p_validate                     => p_validate
7080     ,p_effective_date               => l_effective_date
7081     ,p_business_group_id            => l_business_group_id
7082     ,p_legislation_code             => l_legislation_code
7083     ,p_person_id                    => p_person_id
7084     ,p_placement_date_start         => l_pop_date_start
7085     ,p_organization_id              => p_organization_id
7086     ,p_primary_flag                 => 'N'
7087     ,p_assignment_number            => l_assignment_number
7088     ,p_assignment_category          => null
7089     ,p_assignment_status_type_id    => p_assignment_status_type_id
7090     ,p_change_reason                => p_change_reason
7091     ,p_comments                     => p_comments
7092     ,p_default_code_comb_id         => p_default_code_comb_id
7093     ,p_employment_category          => p_assignment_category
7094     ,p_establishment_id             => p_establishment_id
7095     ,p_frequency                    => p_frequency
7096     ,p_internal_address_line        => p_internal_address_line
7097     ,p_job_id                       => p_job_id
7098     ,p_labor_union_member_flag      => p_labour_union_member_flag
7099     ,p_location_id                  => p_location_id
7100     ,p_manager_flag                 => p_manager_flag
7101     ,p_normal_hours                 => p_normal_hours
7102     ,p_position_id                  => p_position_id
7103     -- Bug 3545065, Grade should not be maintained for CWK asg
7104     -- ,p_grade_id                     => p_grade_id
7105     ,p_project_title                => p_project_title
7106     ,p_title                        => p_title
7107     ,p_set_of_books_id              => p_set_of_books_id
7108     ,p_source_type                  => p_source_type
7109     ,p_supervisor_id                => p_supervisor_id
7110     ,p_time_normal_start            => p_time_normal_start
7111     ,p_time_normal_finish           => p_time_normal_finish
7112     ,p_vendor_assignment_number     => p_vendor_assignment_number
7113     ,p_vendor_employee_number       => p_vendor_employee_number
7114     ,p_vendor_id                    => l_vendor_id
7115     ,p_vendor_site_id               => l_vendor_site_id
7116     ,p_po_header_id                 => l_po_header_id
7117     ,p_po_line_id                   => p_po_line_id
7118     ,p_projected_assignment_end     => p_projected_assignment_end
7119     ,p_people_group_id              => l_people_group_id
7120     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
7121     ,p_ass_attribute_category       => p_attribute_category
7122     ,p_ass_attribute1               => p_attribute1
7123     ,p_ass_attribute2               => p_attribute2
7124     ,p_ass_attribute3               => p_attribute3
7125     ,p_ass_attribute4               => p_attribute4
7126     ,p_ass_attribute5               => p_attribute5
7127     ,p_ass_attribute6               => p_attribute6
7128     ,p_ass_attribute7               => p_attribute7
7129     ,p_ass_attribute8               => p_attribute8
7130     ,p_ass_attribute9               => p_attribute9
7131     ,p_ass_attribute10              => p_attribute10
7132     ,p_ass_attribute11              => p_attribute11
7133     ,p_ass_attribute12              => p_attribute12
7134     ,p_ass_attribute13              => p_attribute13
7135     ,p_ass_attribute14              => p_attribute14
7136     ,p_ass_attribute15              => p_attribute15
7137     ,p_ass_attribute16              => p_attribute16
7138     ,p_ass_attribute17              => p_attribute17
7139     ,p_ass_attribute18              => p_attribute18
7140     ,p_ass_attribute19              => p_attribute19
7141     ,p_ass_attribute20              => p_attribute20
7142     ,p_ass_attribute21              => p_attribute21
7143     ,p_ass_attribute22              => p_attribute22
7144     ,p_ass_attribute23              => p_attribute23
7145     ,p_ass_attribute24              => p_attribute24
7146     ,p_ass_attribute25              => p_attribute25
7147     ,p_ass_attribute26              => p_attribute26
7148     ,p_ass_attribute27              => p_attribute27
7149     ,p_ass_attribute28              => p_attribute28
7150     ,p_ass_attribute29              => p_attribute29
7151     ,p_ass_attribute30              => p_attribute30
7152     ,p_assignment_id                => l_assignment_id
7153     ,p_object_version_number        => l_object_version_number
7154     ,p_effective_start_date         => l_effective_start_date
7155     ,p_effective_end_date           => l_effective_end_date
7156     ,p_assignment_sequence          => l_assignment_sequence
7157     ,p_comment_id                   => l_comment_id
7158     ,p_other_manager_warning        => l_other_manager_warning
7159     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
7160     );
7161   --
7162   -- add rows to the security table if it is a current assignment.
7163   --
7164   if(l_effective_date <= sysdate) then
7165     --
7166     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
7167 	--
7168   end if;
7169   --
7170  if g_debug then
7171   hr_utility.set_location(l_proc, 40);
7172  end if;
7173   --
7174   BEGIN
7175     --
7176     -- Start of API User Hook for the after hook of create_secondary_emp_asg
7177     --
7178     -- Bug 944911
7179     -- No amendments required for outs as the values carried forward
7180     -- Adding the 2 additional ins - p_concat_segments and p_pgp_concat_segments
7181     -- Both with the same value as passed to _b proc
7182 	--
7183     hr_assignment_bkn.create_secondary_cwk_asg_a
7184       (p_effective_date               => l_effective_date
7185       ,p_business_group_id            => p_business_group_id
7186       ,p_person_id                    => p_person_id
7187       ,p_organization_id              => p_organization_id
7188       ,p_assignment_number            => l_assignment_number
7189       ,p_assignment_category          => p_assignment_category
7190       ,p_assignment_status_type_id    => p_assignment_status_type_id
7191       ,p_change_reason                => p_change_reason
7192       ,p_comments                     => p_comments
7193       ,p_default_code_comb_id         => p_default_code_comb_id
7194       ,p_establishment_id             => p_establishment_id
7195       ,p_frequency                    => p_frequency
7196       ,p_internal_address_line        => p_internal_address_line
7197       ,p_job_id                       => p_job_id
7198       ,p_labour_union_member_flag     => p_labour_union_member_flag
7199       ,p_location_id                  => p_location_id
7200       ,p_manager_flag                 => p_manager_flag
7201       ,p_normal_hours                 => p_normal_hours
7202       ,p_position_id                  => p_position_id
7203       ,p_grade_id                     => l_grade_id -- Bug 3545065
7204       ,p_project_title                => p_project_title
7205       ,p_set_of_books_id              => p_set_of_books_id
7206       ,p_source_type                  => p_source_type
7207       ,p_supervisor_id                => p_supervisor_id
7208       ,p_time_normal_finish           => p_time_normal_finish
7209       ,p_time_normal_start            => p_time_normal_start
7210       ,p_title                        => p_title
7211       ,p_vendor_assignment_number     => p_vendor_assignment_number
7212       ,p_vendor_employee_number       => p_vendor_employee_number
7213       ,p_vendor_id                    => l_vendor_id
7214       ,p_vendor_site_id               => l_vendor_site_id
7215       ,p_po_header_id                 => l_po_header_id
7216       ,p_po_line_id                   => p_po_line_id
7217       ,p_projected_assignment_end     => p_projected_assignment_end
7218       ,p_attribute_category           => p_attribute_category
7219       ,p_attribute1                   => p_attribute1
7220       ,p_attribute2                   => p_attribute2
7221       ,p_attribute3                   => p_attribute3
7222       ,p_attribute4                   => p_attribute4
7223       ,p_attribute5                   => p_attribute5
7224       ,p_attribute6                   => p_attribute6
7225       ,p_attribute7                   => p_attribute7
7226       ,p_attribute8                   => p_attribute8
7227       ,p_attribute9                   => p_attribute9
7228       ,p_attribute10                  => p_attribute10
7229       ,p_attribute11                  => p_attribute11
7230       ,p_attribute12                  => p_attribute12
7231       ,p_attribute13                  => p_attribute13
7232       ,p_attribute14                  => p_attribute14
7233       ,p_attribute15                  => p_attribute15
7234       ,p_attribute16                  => p_attribute16
7235       ,p_attribute17                  => p_attribute17
7236       ,p_attribute18                  => p_attribute18
7237       ,p_attribute19                  => p_attribute19
7238       ,p_attribute20                  => p_attribute20
7239       ,p_attribute21                  => p_attribute21
7240       ,p_attribute22                  => p_attribute22
7241       ,p_attribute23                  => p_attribute23
7242       ,p_attribute24                  => p_attribute24
7243       ,p_attribute25                  => p_attribute25
7244       ,p_attribute26                  => p_attribute26
7245       ,p_attribute27                  => p_attribute27
7246       ,p_attribute28                  => p_attribute28
7247       ,p_attribute29                  => p_attribute29
7248       ,p_attribute30                  => p_attribute30
7249       ,p_scl_concat_segments          => l_old_scl_conc_segments
7250       ,p_pgp_segment1                 => p_pgp_segment1
7251       ,p_pgp_segment2                 => p_pgp_segment2
7252       ,p_pgp_segment3                 => p_pgp_segment3
7253       ,p_pgp_segment4                 => p_pgp_segment4
7254       ,p_pgp_segment5                 => p_pgp_segment5
7255       ,p_pgp_segment6                 => p_pgp_segment6
7256       ,p_pgp_segment7                 => p_pgp_segment7
7257       ,p_pgp_segment8                 => p_pgp_segment8
7258       ,p_pgp_segment9                 => p_pgp_segment9
7259       ,p_pgp_segment10                => p_pgp_segment10
7260       ,p_pgp_segment11                => p_pgp_segment11
7261       ,p_pgp_segment12                => p_pgp_segment12
7262       ,p_pgp_segment13                => p_pgp_segment13
7263       ,p_pgp_segment14                => p_pgp_segment14
7264       ,p_pgp_segment15                => p_pgp_segment15
7265       ,p_pgp_segment16                => p_pgp_segment16
7266       ,p_pgp_segment17                => p_pgp_segment17
7267       ,p_pgp_segment18                => p_pgp_segment18
7268       ,p_pgp_segment19                => p_pgp_segment19
7269       ,p_pgp_segment20                => p_pgp_segment20
7270       ,p_pgp_segment21                => p_pgp_segment21
7271       ,p_pgp_segment22                => p_pgp_segment22
7272       ,p_pgp_segment23                => p_pgp_segment23
7273       ,p_pgp_segment24                => p_pgp_segment24
7274       ,p_pgp_segment25                => p_pgp_segment25
7275       ,p_pgp_segment26                => p_pgp_segment26
7276       ,p_pgp_segment27                => p_pgp_segment27
7277       ,p_pgp_segment28                => p_pgp_segment28
7278       ,p_pgp_segment29                => p_pgp_segment29
7279       ,p_pgp_segment30                => p_pgp_segment30
7280       ,p_scl_segment1                 => p_scl_segment1
7281       ,p_scl_segment2                 => p_scl_segment2
7282       ,p_scl_segment3                 => p_scl_segment3
7283       ,p_scl_segment4                 => p_scl_segment4
7284       ,p_scl_segment5                 => p_scl_segment5
7285       ,p_scl_segment6                 => p_scl_segment6
7286       ,p_scl_segment7                 => p_scl_segment7
7287       ,p_scl_segment8                 => p_scl_segment8
7288       ,p_scl_segment9                 => p_scl_segment9
7289       ,p_scl_segment10                => p_scl_segment10
7290       ,p_scl_segment11                => p_scl_segment11
7291       ,p_scl_segment12                => p_scl_segment12
7292       ,p_scl_segment13                => p_scl_segment13
7293       ,p_scl_segment14                => p_scl_segment14
7294       ,p_scl_segment15                => p_scl_segment15
7295       ,p_scl_segment16                => p_scl_segment16
7296       ,p_scl_segment17                => p_scl_segment17
7297       ,p_scl_segment18                => p_scl_segment18
7298       ,p_scl_segment19                => p_scl_segment19
7299       ,p_scl_segment20                => p_scl_segment20
7300       ,p_scl_segment21                => p_scl_segment21
7301       ,p_scl_segment22                => p_scl_segment22
7302       ,p_scl_segment23                => p_scl_segment23
7303       ,p_scl_segment24                => p_scl_segment24
7304       ,p_scl_segment25                => p_scl_segment25
7305       ,p_scl_segment26                => p_scl_segment26
7306       ,p_scl_segment27                => p_scl_segment27
7307       ,p_scl_segment28                => p_scl_segment28
7308       ,p_scl_segment29                => p_scl_segment29
7309       ,p_scl_segment30                => p_scl_segment30
7310       ,p_pgp_concat_segments          => l_old_group_name
7311       ,p_assignment_id                => l_assignment_id
7312       ,p_object_version_number        => l_object_version_number
7313       ,p_effective_start_date         => l_effective_start_date
7314       ,p_effective_end_date           => l_effective_end_date
7315       ,p_assignment_sequence          => l_assignment_sequence
7316       ,p_comment_id                   => l_comment_id
7317       ,p_people_group_id              => l_people_group_id
7318       ,p_people_group_name            => l_group_name
7319       ,p_other_manager_warning        => l_other_manager_warning
7320       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
7321       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
7322       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
7323       );
7324     --
7325   EXCEPTION
7326     --
7327     WHEN hr_api.cannot_find_prog_unit THEN
7328 	  --
7329       hr_api.cannot_find_prog_unit_error
7330         (p_module_name => 'CREATE_SECONDARY_CWK_ASG'
7331         ,p_hook_type   => 'AP');
7332     --
7333     -- End of API User Hook for the after hook of create_secondary_emp_asg
7334     --
7335   END;
7336   --
7337   -- When in validation only mode raise the Validate_Enabled exception
7338   --
7339   IF p_validate THEN
7340     --
7341     RAISE hr_api.validate_enabled;
7342 	--
7343   END IF;
7344   --
7345   -- Set remaining output arguments
7346   --
7347   p_assignment_number          := l_assignment_number;
7348   p_assignment_id              := l_assignment_id;
7349   p_soft_coding_keyflex_id     := l_soft_coding_keyflex_id;
7350   p_people_group_id            := l_people_group_id;
7351   p_object_version_number      := l_object_version_number;
7352   p_effective_start_date       := l_effective_start_date;
7353   p_effective_end_date         := l_effective_end_date;
7354   p_assignment_sequence        := l_assignment_sequence;
7355   p_comment_id                 := l_comment_id;
7356   p_people_group_name          := l_group_name;
7357   p_other_manager_warning      := l_other_manager_warning;
7358   p_hourly_salaried_warning    := l_hourly_salaried_warning;
7359   --
7360   -- remove data from the session table
7361   --
7362   hr_kflex_utility.unset_session_date
7363     (p_session_id     => l_session_id);
7364   --
7365  if g_debug then
7366   hr_utility.set_location(' Leaving:'||l_proc, 999);
7367  end if;
7368   --
7369 EXCEPTION
7370   --
7371   WHEN hr_api.validate_enabled THEN
7372     --
7373     -- As the Validate_Enabled exception has been raised
7374     -- we must rollback to the savepoint
7375     --
7376     ROLLBACK TO create_secondary_cwk_asg;
7377     --
7378     -- Only set output warning arguments
7379     -- (Any key or derived arguments must be set to null
7380     -- when validation only mode is being used.)
7381     --
7382     p_assignment_number       := l_assignment_number;
7383     p_assignment_id           := NULL;
7384     p_soft_coding_keyflex_id  := NULL;
7385     p_people_group_id         := NULL;
7386     p_object_version_number   := NULL;
7387     p_effective_start_date    := NULL;
7388     p_effective_end_date      := NULL;
7389     p_assignment_sequence     := NULL;
7390     p_comment_id              := NULL;
7391     p_people_group_name       := l_old_group_name;
7392     p_other_manager_warning   := l_other_manager_warning;
7393     p_hourly_salaried_warning := l_hourly_salaried_warning;
7394     --
7395   WHEN others THEN
7396     --
7397     -- A validation or unexpected error has occurred
7398     --
7399     -- Added as part of fix to bug 632479
7400     --
7401     p_assignment_number := lv_assignment_number ;
7402 
7403     p_assignment_id             := NULL;
7404     p_object_version_number     := NULL;
7405     p_effective_start_date      := NULL;
7406     p_effective_end_date        := NULL;
7407     p_assignment_sequence       := NULL;
7408     p_comment_id                := NULL;
7409     p_people_group_id           := NULL;
7410     p_people_group_name         := NULL;
7411     p_other_manager_warning     := NULL;
7412     p_hourly_salaried_warning   := NULL;
7413     p_soft_coding_keyflex_id    := NULL;
7414 
7415     ROLLBACK TO create_secondary_cwk_asg;
7416     RAISE;
7417     --
7418     -- End of fix.
7419     --
7420 END create_secondary_cwk_asg;
7421 --
7422 -- ----------------------------------------------------------------------------
7423 -- |---------------------< get_supplier_info_for_po >--------------------------|
7424 -- ----------------------------------------------------------------------------
7425 --
7426 PROCEDURE get_supplier_info_for_po
7427   (p_po_header_id                 IN            NUMBER
7428   ,p_vendor_id                       OUT NOCOPY NUMBER
7429   ,p_vendor_site_id                  OUT NOCOPY NUMBER)
7430 IS
7431 
7432   l_proc              VARCHAR2(72)  :=  g_package||'get_supplier_info_for_po';
7433 
7434   --
7435   -- Fetch the Supplier and Supplier Site.
7436   --
7437   CURSOR csr_get_supplier_info IS
7438   SELECT poh.vendor_id
7439         ,poh.vendor_site_id
7440   FROM   po_temp_labor_headers_v poh
7441   WHERE  poh.po_header_id = p_po_header_id;
7442 
7443 BEGIN
7444 
7445   IF g_debug THEN
7446     hr_utility.set_location('Entering: ' || l_proc, 10);
7447   END IF;
7448 
7449   --
7450   -- If the header is not null, fetch the Supplier info.
7451   --
7452   IF p_po_header_id IS NOT NULL THEN
7453 
7454     IF g_debug THEN
7455       hr_utility.set_location(l_proc, 20);
7456     END IF;
7457 
7458     OPEN  csr_get_supplier_info;
7459     FETCH csr_get_supplier_info INTO p_vendor_id
7460                                     ,p_vendor_site_id;
7461     CLOSE csr_get_supplier_info;
7462 
7463   END IF;
7464 
7465   IF g_debug THEN
7466     hr_utility.set_location('Leaving: ' || l_proc, 999);
7467   END IF;
7468 
7469 END get_supplier_info_for_po;
7470 --
7471 -- ----------------------------------------------------------------------------
7472 -- |---------------------< get_supplier_for_site >-----------------------------|
7473 -- ----------------------------------------------------------------------------
7474 --
7475 FUNCTION get_supplier_for_site
7476   (p_vendor_site_id               IN     NUMBER)
7477 RETURN NUMBER IS
7478 
7479   l_proc              VARCHAR2(72)  :=  g_package||'get_supplier_for_site';
7480   l_vendor_id         NUMBER;
7481 
7482   --
7483   -- Fetch the Supplier and Supplier Site.
7484   --
7485   CURSOR csr_get_supplier IS
7486   SELECT povs.vendor_id
7487   FROM   po_vendor_sites_all povs
7488   WHERE  povs.vendor_site_id = p_vendor_site_id;
7489 
7490 BEGIN
7491 
7492   IF g_debug THEN
7493     hr_utility.set_location('Entering: ' || l_proc, 10);
7494   END IF;
7495 
7496   --
7497   -- If the Supplier Site is not null, fetch the Supplier.
7498   --
7499   IF p_vendor_site_id IS NOT NULL THEN
7500 
7501     IF g_debug THEN
7502       hr_utility.set_location(l_proc, 20);
7503     END IF;
7504 
7505     OPEN  csr_get_supplier;
7506     FETCH csr_get_supplier INTO l_vendor_id;
7507     CLOSE csr_get_supplier;
7508 
7509   END IF;
7510 
7511   IF g_debug THEN
7512     hr_utility.set_location('Leaving: ' || l_proc, 999);
7513   END IF;
7514 
7515   RETURN l_vendor_id;
7516 
7517 END get_supplier_for_site;
7518 --
7519 -- ----------------------------------------------------------------------------
7520 -- |---------------------< get_po_for_line >-----------------------------------|
7521 -- ----------------------------------------------------------------------------
7522 --
7523 FUNCTION get_po_for_line
7524   (p_po_line_id                   IN     NUMBER)
7525 RETURN NUMBER IS
7526 
7527   l_proc              VARCHAR2(72)  :=  g_package||'get_po_for_line';
7528   l_po_header_id      NUMBER;
7529 
7530   --
7531   -- Fetch the Purchase Order given a line.
7532   --
7533   CURSOR csr_get_po IS
7534   SELECT pol.po_header_id
7535   FROM   po_temp_labor_lines_v pol
7536   WHERE  pol.po_line_id = p_po_line_id;
7537 
7538 BEGIN
7539 
7540   IF g_debug THEN
7541     hr_utility.set_location('Entering: ' || l_proc, 10);
7542   END IF;
7543 
7544   --
7545   -- If the PO Line is not null, fetch the PO (header).
7546   --
7547   IF p_po_line_id IS NOT NULL THEN
7548 
7549     IF g_debug THEN
7550       hr_utility.set_location(l_proc, 20);
7551     END IF;
7552 
7553     OPEN  csr_get_po;
7554     FETCH csr_get_po INTO l_po_header_id;
7555     CLOSE csr_get_po;
7556 
7557   END IF;
7558 
7559   IF g_debug THEN
7560     hr_utility.set_location('Leaving: ' || l_proc, 999);
7561   END IF;
7562 
7563   RETURN l_po_header_id;
7564 
7565 END get_po_for_line;
7566 --
7567 -- ----------------------------------------------------------------------------
7568 -- |---------------------< get_job_for_po_line >-------------------------------|
7569 -- ----------------------------------------------------------------------------
7570 --
7571 FUNCTION get_job_for_po_line
7572   (p_po_line_id                   IN     NUMBER)
7573 RETURN NUMBER IS
7574 
7575   l_proc              VARCHAR2(72)  :=  g_package||'get_job_for_po_line';
7576   l_job_id            NUMBER;
7577 
7578   --
7579   -- Fetch the Purchase Order given a line.
7580   --
7581   CURSOR csr_get_job IS
7582   SELECT pol.job_id
7583   FROM   po_temp_labor_lines_v pol
7584   WHERE  pol.po_line_id = p_po_line_id;
7585 
7586 BEGIN
7587 
7588   IF g_debug THEN
7589     hr_utility.set_location('Entering: ' || l_proc, 10);
7590   END IF;
7591 
7592   --
7593   -- If the PO Line is not null, fetch the Job.
7594   --
7595   IF p_po_line_id IS NOT NULL THEN
7596 
7597     IF g_debug THEN
7598       hr_utility.set_location(l_proc, 20);
7599     END IF;
7600 
7601     OPEN  csr_get_job;
7602     FETCH csr_get_job INTO l_job_id;
7603     CLOSE csr_get_job;
7604 
7605   END IF;
7606 
7607   IF g_debug THEN
7608     hr_utility.set_location('Leaving: ' || l_proc, 999);
7609   END IF;
7610 
7611   RETURN l_job_id;
7612 
7613 END get_job_for_po_line;
7614 --
7615 -- ----------------------------------------------------------------------------
7616 -- |---------------------< create_gb_secondary_emp_asg >-----------------------|
7617 -- ----------------------------------------------------------------------------
7618 --
7619 procedure create_gb_secondary_emp_asg
7620   (p_validate                     in     boolean
7621   ,p_effective_date               in     date
7622   ,p_person_id                    in     number
7623   ,p_organization_id              in     number
7624   ,p_grade_id                     in     number
7625   ,p_position_id                  in     number
7626   ,p_job_id                       in     number
7627   ,p_assignment_status_type_id    in     number
7628   ,p_payroll_id                   in     number
7629   ,p_location_id                  in     number
7630   ,p_supervisor_id                in     number
7631   ,p_special_ceiling_step_id      in     number
7632   ,p_pay_basis_id                 in     number
7633   ,p_assignment_number            in out nocopy varchar2
7634   ,p_change_reason                in     varchar2
7635   ,p_comments                     in     varchar2
7636   ,p_date_probation_end           in     date
7637   ,p_default_code_comb_id         in     number
7638   ,p_employment_category          in     varchar2
7639   ,p_frequency                    in     varchar2
7640   ,p_internal_address_line        in     varchar2
7641   ,p_manager_flag                 in     varchar2
7642   ,p_normal_hours                 in     number
7643   ,p_perf_review_period           in     number
7644   ,p_perf_review_period_frequency in     varchar2
7645   ,p_probation_period             in     number
7646   ,p_probation_unit               in     varchar2
7647   ,p_sal_review_period            in     number
7648   ,p_sal_review_period_frequency  in     varchar2
7649   ,p_set_of_books_id              in     number
7650   ,p_source_type                  in     varchar2
7651   ,p_time_normal_finish           in     varchar2
7652   ,p_time_normal_start            in     varchar2
7653   ,p_bargaining_unit_code         in     varchar2
7654   ,p_labour_union_member_flag     in     varchar2
7655   ,p_hourly_salaried_code         in     varchar2
7656   ,p_ass_attribute_category       in     varchar2
7657   ,p_ass_attribute1               in     varchar2
7658   ,p_ass_attribute2               in     varchar2
7659   ,p_ass_attribute3               in     varchar2
7660   ,p_ass_attribute4               in     varchar2
7661   ,p_ass_attribute5               in     varchar2
7662   ,p_ass_attribute6               in     varchar2
7663   ,p_ass_attribute7               in     varchar2
7664   ,p_ass_attribute8               in     varchar2
7665   ,p_ass_attribute9               in     varchar2
7666   ,p_ass_attribute10              in     varchar2
7667   ,p_ass_attribute11              in     varchar2
7668   ,p_ass_attribute12              in     varchar2
7669   ,p_ass_attribute13              in     varchar2
7670   ,p_ass_attribute14              in     varchar2
7671   ,p_ass_attribute15              in     varchar2
7672   ,p_ass_attribute16              in     varchar2
7673   ,p_ass_attribute17              in     varchar2
7674   ,p_ass_attribute18              in     varchar2
7675   ,p_ass_attribute19              in     varchar2
7676   ,p_ass_attribute20              in     varchar2
7677   ,p_ass_attribute21              in     varchar2
7678   ,p_ass_attribute22              in     varchar2
7679   ,p_ass_attribute23              in     varchar2
7680   ,p_ass_attribute24              in     varchar2
7681   ,p_ass_attribute25              in     varchar2
7682   ,p_ass_attribute26              in     varchar2
7683   ,p_ass_attribute27              in     varchar2
7684   ,p_ass_attribute28              in     varchar2
7685   ,p_ass_attribute29              in     varchar2
7686   ,p_ass_attribute30              in     varchar2
7687   ,p_title                        in     varchar2
7688   ,p_pgp_segment1                 in     varchar2
7689   ,p_pgp_segment2                 in     varchar2
7690   ,p_pgp_segment3                 in     varchar2
7691   ,p_pgp_segment4                 in     varchar2
7692   ,p_pgp_segment5                 in     varchar2
7693   ,p_pgp_segment6                 in     varchar2
7694   ,p_pgp_segment7                 in     varchar2
7695   ,p_pgp_segment8                 in     varchar2
7696   ,p_pgp_segment9                 in     varchar2
7697   ,p_pgp_segment10                in     varchar2
7698   ,p_pgp_segment11                in     varchar2
7699   ,p_pgp_segment12                in     varchar2
7700   ,p_pgp_segment13                in     varchar2
7701   ,p_pgp_segment14                in     varchar2
7702   ,p_pgp_segment15                in     varchar2
7703   ,p_pgp_segment16                in     varchar2
7704   ,p_pgp_segment17                in     varchar2
7705   ,p_pgp_segment18                in     varchar2
7706   ,p_pgp_segment19                in     varchar2
7707   ,p_pgp_segment20                in     varchar2
7708   ,p_pgp_segment21                in     varchar2
7709   ,p_pgp_segment22                in     varchar2
7710   ,p_pgp_segment23                in     varchar2
7711   ,p_pgp_segment24                in     varchar2
7712   ,p_pgp_segment25                in     varchar2
7713   ,p_pgp_segment26                in     varchar2
7714   ,p_pgp_segment27                in     varchar2
7715   ,p_pgp_segment28                in     varchar2
7716   ,p_pgp_segment29                in     varchar2
7717   ,p_pgp_segment30                in     varchar2
7718 -- Bug 944911
7719 -- Made p_group_name to be out param
7720 -- and add p_concat_segment to be IN
7721 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7722   ,p_pgp_concat_segments	  in     varchar2
7723   ,p_supervisor_assignment_id     in     number
7724   ,p_group_name                      out nocopy varchar2
7725   ,p_assignment_id                   out nocopy number
7726   ,p_people_group_id                 out nocopy number
7727   ,p_object_version_number           out nocopy number
7728   ,p_effective_start_date            out nocopy date
7729   ,p_effective_end_date              out nocopy date
7730   ,p_assignment_sequence             out nocopy number
7731   ,p_comment_id                      out nocopy number
7732   ,p_other_manager_warning           out nocopy boolean
7733   ) is
7734   --
7735   -- Declare cursors and local variables
7736   --
7737   -- Assigned the value p_assignment_number for fix of #2823013
7738   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
7739   l_effective_date     date;
7740   l_legislation_code   per_business_groups.legislation_code%TYPE;
7741   l_proc               varchar2(72);
7742   --
7743   -- Declare dummy variables
7744   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
7745   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
7746   --
7747   -- Declare cursors
7748   --
7749   cursor csr_legislation is
7750     select null
7751     from per_all_assignments_f paf,
7752          per_business_groups_perf pbg
7753     where paf.person_id = p_person_id
7754     and   l_effective_date between paf.effective_start_date
7755                            and     paf.effective_end_date
7756     and   pbg.business_group_id = paf.business_group_id
7757     and   pbg.legislation_code = 'GB';
7758   --
7759   --
7760 begin
7761  if g_debug then
7762  l_proc := g_package||'create_gb_secondary_emp_asg';
7763   hr_utility.set_location('Entering:'|| l_proc, 10);
7764  end if;
7765   --
7766   -- Initialise local variable
7767   --
7768   l_effective_date := trunc(p_effective_date);
7769   --
7770   -- Validation in addition to Table Handlers
7771   --
7772   -- Ensure that the employee is within a GB business group
7773   --
7774   open csr_legislation;
7775   fetch csr_legislation
7776   into l_legislation_code;
7777   if csr_legislation%notfound then
7778     close csr_legislation;
7779     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
7780     hr_utility.set_message_token('LEG_CODE', 'GB');
7781     hr_utility.raise_error;
7782   end if;
7783   close csr_legislation;
7784   --
7785  if g_debug then
7786   hr_utility.set_location(l_proc, 20);
7787  end if;
7788   --
7789   -- Call create_secondary_emp_asg
7790   --
7791 -- Bug 944911
7792 -- Amended param p_scl_concatenated_segments to p_concatenated_segments
7793   hr_assignment_api.create_secondary_emp_asg
7794   (p_validate                     =>     p_validate
7795   ,p_effective_date               =>     l_effective_date
7796   ,p_person_id                    =>     p_person_id
7797   ,p_organization_id              =>     p_organization_id
7798   ,p_grade_id                     =>     p_grade_id
7799   ,p_position_id                  =>     p_position_id
7800   ,p_job_id                       =>     p_job_id
7801   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
7802   ,p_payroll_id                   =>     p_payroll_id
7803   ,p_location_id                  =>     p_location_id
7804   ,p_supervisor_id                =>     p_supervisor_id
7805   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
7806   ,p_pay_basis_id                 =>     p_pay_basis_id
7807   ,p_assignment_number            =>     l_assignment_number
7808   ,p_change_reason                =>     p_change_reason
7809   ,p_comments                     =>     p_comments
7810   ,p_date_probation_end           =>     trunc(p_date_probation_end)
7811   ,p_default_code_comb_id         =>     p_default_code_comb_id
7812   ,p_employment_category          =>     p_employment_category
7813   ,p_frequency                    =>     p_frequency
7814   ,p_internal_address_line        =>     p_internal_address_line
7815   ,p_manager_flag                 =>     p_manager_flag
7816   ,p_normal_hours                 =>     p_normal_hours
7817   ,p_perf_review_period           =>     p_perf_review_period
7818   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
7819   ,p_probation_period             =>     p_probation_period
7820   ,p_probation_unit               =>     p_probation_unit
7821   ,p_sal_review_period            =>     p_sal_review_period
7822   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
7823   ,p_set_of_books_id              =>     p_set_of_books_id
7824   ,p_source_type                  =>     p_source_type
7825   ,p_time_normal_finish           =>     p_time_normal_finish
7826   ,p_time_normal_start            =>     p_time_normal_start
7827   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
7828   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
7829   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
7830   ,p_ass_attribute_category       =>     p_ass_attribute_category
7831   ,p_ass_attribute1               =>     p_ass_attribute1
7832   ,p_ass_attribute2               =>     p_ass_attribute2
7833   ,p_ass_attribute3               =>     p_ass_attribute3
7834   ,p_ass_attribute4               =>     p_ass_attribute4
7835   ,p_ass_attribute5               =>     p_ass_attribute5
7836   ,p_ass_attribute6               =>     p_ass_attribute6
7837   ,p_ass_attribute7               =>     p_ass_attribute7
7838   ,p_ass_attribute8               =>     p_ass_attribute8
7839   ,p_ass_attribute9               =>     p_ass_attribute9
7840   ,p_ass_attribute10              =>     p_ass_attribute10
7841   ,p_ass_attribute11              =>     p_ass_attribute11
7842   ,p_ass_attribute12              =>     p_ass_attribute12
7843   ,p_ass_attribute13              =>     p_ass_attribute13
7844   ,p_ass_attribute14              =>     p_ass_attribute14
7845   ,p_ass_attribute15              =>     p_ass_attribute15
7846   ,p_ass_attribute16              =>     p_ass_attribute16
7847   ,p_ass_attribute17              =>     p_ass_attribute17
7848   ,p_ass_attribute18              =>     p_ass_attribute18
7849   ,p_ass_attribute19              =>     p_ass_attribute19
7850   ,p_ass_attribute20              =>     p_ass_attribute20
7851   ,p_ass_attribute21              =>     p_ass_attribute21
7852   ,p_ass_attribute22              =>     p_ass_attribute22
7853   ,p_ass_attribute23              =>     p_ass_attribute23
7854   ,p_ass_attribute24              =>     p_ass_attribute24
7855   ,p_ass_attribute25              =>     p_ass_attribute25
7856   ,p_ass_attribute26              =>     p_ass_attribute26
7857   ,p_ass_attribute27              =>     p_ass_attribute27
7858   ,p_ass_attribute28              =>     p_ass_attribute28
7859   ,p_ass_attribute29              =>     p_ass_attribute29
7860   ,p_ass_attribute30              =>     p_ass_attribute30
7861   ,p_title                        =>     p_title
7862   ,p_pgp_segment1                 =>     p_pgp_segment1
7863   ,p_pgp_segment2                 =>     p_pgp_segment2
7864   ,p_pgp_segment3                 =>     p_pgp_segment3
7865   ,p_pgp_segment4                 =>     p_pgp_segment4
7866   ,p_pgp_segment5                 =>     p_pgp_segment5
7867   ,p_pgp_segment6                 =>     p_pgp_segment6
7868   ,p_pgp_segment7                 =>     p_pgp_segment7
7869   ,p_pgp_segment8                 =>     p_pgp_segment8
7870   ,p_pgp_segment9                 =>     p_pgp_segment9
7871   ,p_pgp_segment10                =>     p_pgp_segment10
7872   ,p_pgp_segment11                =>     p_pgp_segment11
7873   ,p_pgp_segment12                =>     p_pgp_segment12
7874   ,p_pgp_segment13                =>     p_pgp_segment13
7875   ,p_pgp_segment14                =>     p_pgp_segment14
7876   ,p_pgp_segment15                =>     p_pgp_segment15
7877   ,p_pgp_segment16                =>     p_pgp_segment16
7878   ,p_pgp_segment17                =>     p_pgp_segment17
7879   ,p_pgp_segment18                =>     p_pgp_segment18
7880   ,p_pgp_segment19                =>     p_pgp_segment19
7881   ,p_pgp_segment20                =>     p_pgp_segment20
7882   ,p_pgp_segment21                =>     p_pgp_segment21
7883   ,p_pgp_segment22                =>     p_pgp_segment22
7884   ,p_pgp_segment23                =>     p_pgp_segment23
7885   ,p_pgp_segment24                =>     p_pgp_segment24
7886   ,p_pgp_segment25                =>     p_pgp_segment25
7887   ,p_pgp_segment26                =>     p_pgp_segment26
7888   ,p_pgp_segment27                =>     p_pgp_segment27
7889   ,p_pgp_segment28                =>     p_pgp_segment28
7890   ,p_pgp_segment29                =>     p_pgp_segment29
7891   ,p_pgp_segment30                =>     p_pgp_segment30
7892 -- Bug 944911
7893 -- Made p_group_name to be out param
7894 -- and add p_concat_segment to be IN
7895 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7896 -- Amended call - added new param p_pgp_concat_segments
7897   ,p_pgp_concat_segments          =>     p_pgp_concat_segments
7898   ,p_group_name                   =>     p_group_name
7899   ,p_assignment_id                =>     p_assignment_id
7900   ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
7901   ,p_people_group_id              =>     p_people_group_id
7902   ,p_object_version_number        =>     p_object_version_number
7903   ,p_effective_start_date         =>     p_effective_start_date
7904   ,p_effective_end_date           =>     p_effective_end_date
7905   ,p_assignment_sequence          =>     p_assignment_sequence
7906   ,p_comment_id                   =>     p_comment_id
7907   ,p_concatenated_segments        =>     l_concatenated_segments
7908   ,p_other_manager_warning        =>     p_other_manager_warning
7909   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
7910   );
7911   --
7912  if g_debug then
7913   hr_utility.set_location(' Leaving:'||l_proc, 30);
7914  end if;
7915   --
7916   end create_gb_secondary_emp_asg;
7917 
7918 --
7919 --
7920 -- ----------------------------------------------------------------------------
7921 -- |---------------------< create_gb_secondary_emp_asg >-----------------------|
7922 -- ----------------------------------------------------------------------------
7923 --   Overloded procedure to include p_hourly_salaried_warning
7924 --
7925 procedure create_gb_secondary_emp_asg
7926   (p_validate                     in     boolean
7927   ,p_effective_date               in     date
7928   ,p_person_id                    in     number
7929   ,p_organization_id              in     number
7930   ,p_grade_id                     in     number
7931   ,p_position_id                  in     number
7932   ,p_job_id                       in     number
7933   ,p_assignment_status_type_id    in     number
7934   ,p_payroll_id                   in     number
7935   ,p_location_id                  in     number
7936   ,p_supervisor_id                in     number
7937   ,p_special_ceiling_step_id      in     number
7938   ,p_pay_basis_id                 in     number
7939   ,p_assignment_number            in out nocopy varchar2
7940   ,p_change_reason                in     varchar2
7941   ,p_comments                     in     varchar2
7942   ,p_date_probation_end           in     date
7943   ,p_default_code_comb_id         in     number
7944   ,p_employment_category          in     varchar2
7945   ,p_frequency                    in     varchar2
7946   ,p_internal_address_line        in     varchar2
7947   ,p_manager_flag                 in     varchar2
7948   ,p_normal_hours                 in     number
7949   ,p_perf_review_period           in     number
7950   ,p_perf_review_period_frequency in     varchar2
7951   ,p_probation_period             in     number
7952   ,p_probation_unit               in     varchar2
7953   ,p_sal_review_period            in     number
7954   ,p_sal_review_period_frequency  in     varchar2
7955   ,p_set_of_books_id              in     number
7956   ,p_source_type                  in     varchar2
7957   ,p_time_normal_finish           in     varchar2
7958   ,p_time_normal_start            in     varchar2
7959   ,p_bargaining_unit_code         in     varchar2
7960   ,p_labour_union_member_flag     in     varchar2
7961   ,p_hourly_salaried_code         in     varchar2
7962   ,p_ass_attribute_category       in     varchar2
7963   ,p_ass_attribute1               in     varchar2
7964   ,p_ass_attribute2               in     varchar2
7965   ,p_ass_attribute3               in     varchar2
7966   ,p_ass_attribute4               in     varchar2
7967   ,p_ass_attribute5               in     varchar2
7968   ,p_ass_attribute6               in     varchar2
7969   ,p_ass_attribute7               in     varchar2
7970   ,p_ass_attribute8               in     varchar2
7971   ,p_ass_attribute9               in     varchar2
7972   ,p_ass_attribute10              in     varchar2
7973   ,p_ass_attribute11              in     varchar2
7974   ,p_ass_attribute12              in     varchar2
7975   ,p_ass_attribute13              in     varchar2
7976   ,p_ass_attribute14              in     varchar2
7977   ,p_ass_attribute15              in     varchar2
7978   ,p_ass_attribute16              in     varchar2
7979   ,p_ass_attribute17              in     varchar2
7980   ,p_ass_attribute18              in     varchar2
7981   ,p_ass_attribute19              in     varchar2
7982   ,p_ass_attribute20              in     varchar2
7983   ,p_ass_attribute21              in     varchar2
7984   ,p_ass_attribute22              in     varchar2
7985   ,p_ass_attribute23              in     varchar2
7986   ,p_ass_attribute24              in     varchar2
7987   ,p_ass_attribute25              in     varchar2
7988   ,p_ass_attribute26              in     varchar2
7989   ,p_ass_attribute27              in     varchar2
7990   ,p_ass_attribute28              in     varchar2
7991   ,p_ass_attribute29              in     varchar2
7992   ,p_ass_attribute30              in     varchar2
7993   ,p_title                        in     varchar2
7994   ,p_pgp_segment1                 in     varchar2
7995   ,p_pgp_segment2                 in     varchar2
7996   ,p_pgp_segment3                 in     varchar2
7997   ,p_pgp_segment4                 in     varchar2
7998   ,p_pgp_segment5                 in     varchar2
7999   ,p_pgp_segment6                 in     varchar2
8000   ,p_pgp_segment7                 in     varchar2
8001   ,p_pgp_segment8                 in     varchar2
8002   ,p_pgp_segment9                 in     varchar2
8003   ,p_pgp_segment10                in     varchar2
8004   ,p_pgp_segment11                in     varchar2
8005   ,p_pgp_segment12                in     varchar2
8006   ,p_pgp_segment13                in     varchar2
8007   ,p_pgp_segment14                in     varchar2
8008   ,p_pgp_segment15                in     varchar2
8009   ,p_pgp_segment16                in     varchar2
8010   ,p_pgp_segment17                in     varchar2
8011   ,p_pgp_segment18                in     varchar2
8012   ,p_pgp_segment19                in     varchar2
8013   ,p_pgp_segment20                in     varchar2
8014   ,p_pgp_segment21                in     varchar2
8015   ,p_pgp_segment22                in     varchar2
8016   ,p_pgp_segment23                in     varchar2
8017   ,p_pgp_segment24                in     varchar2
8018   ,p_pgp_segment25                in     varchar2
8019   ,p_pgp_segment26                in     varchar2
8020   ,p_pgp_segment27                in     varchar2
8021   ,p_pgp_segment28                in     varchar2
8022   ,p_pgp_segment29                in     varchar2
8023   ,p_pgp_segment30                in     varchar2
8024 -- Bug 944911
8025 -- Made p_group_name to be out param
8026 -- and add p_concat_segment to be IN
8027 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8028   ,p_pgp_concat_segments	  in     varchar2
8029   ,p_supervisor_assignment_id     in     number
8030   ,p_group_name                      out nocopy varchar2
8031   ,p_assignment_id                   out nocopy number
8032   ,p_people_group_id                 out nocopy number
8033   ,p_object_version_number           out nocopy number
8034   ,p_effective_start_date            out nocopy date
8035   ,p_effective_end_date              out nocopy date
8036   ,p_assignment_sequence             out nocopy number
8037   ,p_comment_id                      out nocopy number
8038   ,p_other_manager_warning           out nocopy boolean
8039   ,p_hourly_salaried_warning         out nocopy boolean
8040   ,p_cagr_grade_def_id               out nocopy number
8041   ,p_cagr_concatenated_segments      out nocopy varchar2
8042   ) is
8043   --
8044   -- Declare cursors and local variables
8045   --
8046   -- Assigned the value p_assignment_number for fix of #2823013
8047   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
8048   l_effective_date     date;
8049   l_legislation_code   per_business_groups.legislation_code%TYPE;
8050   l_proc               varchar2(72);
8051   --
8052   -- Declare dummy variables
8053   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
8054   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
8055   --
8056   -- Declare cursors
8057   --
8058   cursor csr_legislation is
8059     select null
8060     from per_all_assignments_f paf,
8061          per_business_groups_perf pbg
8062     where paf.person_id = p_person_id
8063     and   l_effective_date between paf.effective_start_date
8064                            and     paf.effective_end_date
8065     and   pbg.business_group_id = paf.business_group_id
8066     and   pbg.legislation_code = 'GB';
8067   --
8068   --
8069 begin
8070  if g_debug then
8071  l_proc := g_package||'create_gb_secondary_emp_asg';
8072   hr_utility.set_location('Entering:'|| l_proc, 10);
8073  end if;
8074   --
8075   -- Initialise local variable
8076   --
8077   l_effective_date := trunc(p_effective_date);
8078   --
8079   -- Validation in addition to Table Handlers
8080   --
8081   -- Ensure that the employee is within a GB business group
8082   --
8083   open csr_legislation;
8084   fetch csr_legislation
8085   into l_legislation_code;
8086   if csr_legislation%notfound then
8087     close csr_legislation;
8088     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
8089     hr_utility.set_message_token('LEG_CODE', 'GB');
8090     hr_utility.raise_error;
8091   end if;
8092   close csr_legislation;
8093   --
8094  if g_debug then
8095   hr_utility.set_location(l_proc, 20);
8096  end if;
8097   --
8098   -- Call create_secondary_emp_asg
8099   --
8100 -- Bug 944911
8101 -- Amended param p_scl_concatenated_segments to p_concatenated_segments
8102   hr_assignment_api.create_secondary_emp_asg
8103   (p_validate                     =>     p_validate
8104   ,p_effective_date               =>     l_effective_date
8105   ,p_person_id                    =>     p_person_id
8106   ,p_organization_id              =>     p_organization_id
8107   ,p_grade_id                     =>     p_grade_id
8108   ,p_position_id                  =>     p_position_id
8109   ,p_job_id                       =>     p_job_id
8110   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
8111   ,p_payroll_id                   =>     p_payroll_id
8112   ,p_location_id                  =>     p_location_id
8113   ,p_supervisor_id                =>     p_supervisor_id
8114   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
8115   ,p_pay_basis_id                 =>     p_pay_basis_id
8116   ,p_assignment_number            =>     l_assignment_number
8117   ,p_change_reason                =>     p_change_reason
8118   ,p_comments                     =>     p_comments
8119   ,p_date_probation_end           =>     trunc(p_date_probation_end)
8120   ,p_default_code_comb_id         =>     p_default_code_comb_id
8121   ,p_employment_category          =>     p_employment_category
8122   ,p_frequency                    =>     p_frequency
8123   ,p_internal_address_line        =>     p_internal_address_line
8124   ,p_manager_flag                 =>     p_manager_flag
8125   ,p_normal_hours                 =>     p_normal_hours
8126   ,p_perf_review_period           =>     p_perf_review_period
8127   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
8128   ,p_probation_period             =>     p_probation_period
8129   ,p_probation_unit               =>     p_probation_unit
8130   ,p_sal_review_period            =>     p_sal_review_period
8131   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
8132   ,p_set_of_books_id              =>     p_set_of_books_id
8133   ,p_source_type                  =>     p_source_type
8134   ,p_time_normal_finish           =>     p_time_normal_finish
8135   ,p_time_normal_start            =>     p_time_normal_start
8136   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
8137   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
8138   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
8139   ,p_ass_attribute_category       =>     p_ass_attribute_category
8140   ,p_ass_attribute1               =>     p_ass_attribute1
8141   ,p_ass_attribute2               =>     p_ass_attribute2
8142   ,p_ass_attribute3               =>     p_ass_attribute3
8143   ,p_ass_attribute4               =>     p_ass_attribute4
8144   ,p_ass_attribute5               =>     p_ass_attribute5
8145   ,p_ass_attribute6               =>     p_ass_attribute6
8146   ,p_ass_attribute7               =>     p_ass_attribute7
8147   ,p_ass_attribute8               =>     p_ass_attribute8
8148   ,p_ass_attribute9               =>     p_ass_attribute9
8149   ,p_ass_attribute10              =>     p_ass_attribute10
8150   ,p_ass_attribute11              =>     p_ass_attribute11
8151   ,p_ass_attribute12              =>     p_ass_attribute12
8152   ,p_ass_attribute13              =>     p_ass_attribute13
8153   ,p_ass_attribute14              =>     p_ass_attribute14
8154   ,p_ass_attribute15              =>     p_ass_attribute15
8155   ,p_ass_attribute16              =>     p_ass_attribute16
8156   ,p_ass_attribute17              =>     p_ass_attribute17
8157   ,p_ass_attribute18              =>     p_ass_attribute18
8158   ,p_ass_attribute19              =>     p_ass_attribute19
8159   ,p_ass_attribute20              =>     p_ass_attribute20
8160   ,p_ass_attribute21              =>     p_ass_attribute21
8161   ,p_ass_attribute22              =>     p_ass_attribute22
8162   ,p_ass_attribute23              =>     p_ass_attribute23
8163   ,p_ass_attribute24              =>     p_ass_attribute24
8164   ,p_ass_attribute25              =>     p_ass_attribute25
8165   ,p_ass_attribute26              =>     p_ass_attribute26
8166   ,p_ass_attribute27              =>     p_ass_attribute27
8167   ,p_ass_attribute28              =>     p_ass_attribute28
8168   ,p_ass_attribute29              =>     p_ass_attribute29
8169   ,p_ass_attribute30              =>     p_ass_attribute30
8170   ,p_title                        =>     p_title
8171   ,p_pgp_segment1                 =>     p_pgp_segment1
8172   ,p_pgp_segment2                 =>     p_pgp_segment2
8173   ,p_pgp_segment3                 =>     p_pgp_segment3
8174   ,p_pgp_segment4                 =>     p_pgp_segment4
8175   ,p_pgp_segment5                 =>     p_pgp_segment5
8176   ,p_pgp_segment6                 =>     p_pgp_segment6
8177   ,p_pgp_segment7                 =>     p_pgp_segment7
8178   ,p_pgp_segment8                 =>     p_pgp_segment8
8179   ,p_pgp_segment9                 =>     p_pgp_segment9
8180   ,p_pgp_segment10                =>     p_pgp_segment10
8181   ,p_pgp_segment11                =>     p_pgp_segment11
8182   ,p_pgp_segment12                =>     p_pgp_segment12
8183   ,p_pgp_segment13                =>     p_pgp_segment13
8184   ,p_pgp_segment14                =>     p_pgp_segment14
8185   ,p_pgp_segment15                =>     p_pgp_segment15
8186   ,p_pgp_segment16                =>     p_pgp_segment16
8187   ,p_pgp_segment17                =>     p_pgp_segment17
8188   ,p_pgp_segment18                =>     p_pgp_segment18
8189   ,p_pgp_segment19                =>     p_pgp_segment19
8190   ,p_pgp_segment20                =>     p_pgp_segment20
8191   ,p_pgp_segment21                =>     p_pgp_segment21
8192   ,p_pgp_segment22                =>     p_pgp_segment22
8193   ,p_pgp_segment23                =>     p_pgp_segment23
8194   ,p_pgp_segment24                =>     p_pgp_segment24
8195   ,p_pgp_segment25                =>     p_pgp_segment25
8196   ,p_pgp_segment26                =>     p_pgp_segment26
8197   ,p_pgp_segment27                =>     p_pgp_segment27
8198   ,p_pgp_segment28                =>     p_pgp_segment28
8199   ,p_pgp_segment29                =>     p_pgp_segment29
8200   ,p_pgp_segment30                =>     p_pgp_segment30
8201 -- Bug 944911
8202 -- Made p_group_name to be out param
8203 -- and add p_concat_segment to be IN
8204 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8205 -- Amended call - added new param p_pgp_concat_segments
8206   ,p_pgp_concat_segments          =>     p_pgp_concat_segments
8207   ,p_group_name                   =>     p_group_name
8208   ,p_assignment_id                =>     p_assignment_id
8209   ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
8210   ,p_people_group_id              =>     p_people_group_id
8211   ,p_object_version_number        =>     p_object_version_number
8212   ,p_effective_start_date         =>     p_effective_start_date
8213   ,p_effective_end_date           =>     p_effective_end_date
8214   ,p_assignment_sequence          =>     p_assignment_sequence
8215   ,p_comment_id                   =>     p_comment_id
8216   ,p_concatenated_segments        =>     l_concatenated_segments
8217   ,p_other_manager_warning        =>     p_other_manager_warning
8218   ,p_hourly_salaried_warning      =>     p_hourly_salaried_warning
8219   ,p_cagr_grade_def_id            =>     p_cagr_grade_def_id
8220   ,p_cagr_concatenated_segments   =>     p_cagr_concatenated_segments
8221   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
8222   );
8223   --
8224  if g_debug then
8225   hr_utility.set_location(' Leaving:'||l_proc, 30);
8226  end if;
8227   --
8228   end create_gb_secondary_emp_asg;
8229 
8230 --
8231 -- ----------------------------------------------------------------------------
8232 -- |---------------------< create_us_secondary_emp_asg >-----------------------|
8233 -- ----------------------------------------------------------------------------
8234 --
8235 procedure create_us_secondary_emp_asg
8236   (p_validate                     in     boolean
8237   ,p_effective_date               in     date
8238   ,p_person_id                    in     number
8239   ,p_organization_id              in     number
8240   ,p_grade_id                     in     number
8241   ,p_position_id                  in     number
8242   ,p_job_id                       in     number
8243   ,p_assignment_status_type_id    in     number
8244   ,p_payroll_id                   in     number
8245   ,p_location_id                  in     number
8246   ,p_supervisor_id                in     number
8247   ,p_special_ceiling_step_id      in     number
8248   ,p_pay_basis_id                 in     number
8249   ,p_assignment_number            in out nocopy varchar2
8250   ,p_change_reason                in     varchar2
8251   ,p_comments                     in     varchar2
8252   ,p_date_probation_end           in     date
8253   ,p_default_code_comb_id         in     number
8254   ,p_employment_category          in     varchar2
8255   ,p_frequency                    in     varchar2
8256   ,p_internal_address_line        in     varchar2
8257   ,p_manager_flag                 in     varchar2
8258   ,p_normal_hours                 in     number
8259   ,p_perf_review_period           in     number
8260   ,p_perf_review_period_frequency in     varchar2
8261   ,p_probation_period             in     number
8262   ,p_probation_unit               in     varchar2
8263   ,p_sal_review_period            in     number
8264   ,p_sal_review_period_frequency  in     varchar2
8265   ,p_set_of_books_id              in     number
8266   ,p_source_type                  in     varchar2
8267   ,p_time_normal_finish           in     varchar2
8268   ,p_time_normal_start            in     varchar2
8269   ,p_bargaining_unit_code         in     varchar2
8270   ,p_labour_union_member_flag     in     varchar2
8271   ,p_hourly_salaried_code         in     varchar2
8272   ,p_ass_attribute_category       in     varchar2
8273   ,p_ass_attribute1               in     varchar2
8274   ,p_ass_attribute2               in     varchar2
8275   ,p_ass_attribute3               in     varchar2
8276   ,p_ass_attribute4               in     varchar2
8277   ,p_ass_attribute5               in     varchar2
8278   ,p_ass_attribute6               in     varchar2
8279   ,p_ass_attribute7               in     varchar2
8280   ,p_ass_attribute8               in     varchar2
8281   ,p_ass_attribute9               in     varchar2
8282   ,p_ass_attribute10              in     varchar2
8283   ,p_ass_attribute11              in     varchar2
8284   ,p_ass_attribute12              in     varchar2
8285   ,p_ass_attribute13              in     varchar2
8286   ,p_ass_attribute14              in     varchar2
8287   ,p_ass_attribute15              in     varchar2
8288   ,p_ass_attribute16              in     varchar2
8289   ,p_ass_attribute17              in     varchar2
8290   ,p_ass_attribute18              in     varchar2
8291   ,p_ass_attribute19              in     varchar2
8292   ,p_ass_attribute20              in     varchar2
8293   ,p_ass_attribute21              in     varchar2
8294   ,p_ass_attribute22              in     varchar2
8295   ,p_ass_attribute23              in     varchar2
8296   ,p_ass_attribute24              in     varchar2
8297   ,p_ass_attribute25              in     varchar2
8298   ,p_ass_attribute26              in     varchar2
8299   ,p_ass_attribute27              in     varchar2
8300   ,p_ass_attribute28              in     varchar2
8301   ,p_ass_attribute29              in     varchar2
8302   ,p_ass_attribute30              in     varchar2
8303   ,p_title                        in     varchar2
8304   ,p_tax_unit                     in     varchar2
8305   ,p_timecard_approver            in     varchar2
8306   ,p_timecard_required            in     varchar2
8307   ,p_work_schedule                in     varchar2
8308   ,p_shift                        in     varchar2
8309   ,p_spouse_salary                in     varchar2
8310   ,p_legal_representative         in     varchar2
8311   ,p_wc_override_code             in     varchar2
8312   ,p_eeo_1_establishment          in     varchar2
8313   ,p_pgp_segment1                 in     varchar2
8314   ,p_pgp_segment2                 in     varchar2
8315   ,p_pgp_segment3                 in     varchar2
8316   ,p_pgp_segment4                 in     varchar2
8317   ,p_pgp_segment5                 in     varchar2
8318   ,p_pgp_segment6                 in     varchar2
8319   ,p_pgp_segment7                 in     varchar2
8320   ,p_pgp_segment8                 in     varchar2
8321   ,p_pgp_segment9                 in     varchar2
8322   ,p_pgp_segment10                in     varchar2
8323   ,p_pgp_segment11                in     varchar2
8324   ,p_pgp_segment12                in     varchar2
8325   ,p_pgp_segment13                in     varchar2
8326   ,p_pgp_segment14                in     varchar2
8327   ,p_pgp_segment15                in     varchar2
8328   ,p_pgp_segment16                in     varchar2
8329   ,p_pgp_segment17                in     varchar2
8330   ,p_pgp_segment18                in     varchar2
8331   ,p_pgp_segment19                in     varchar2
8332   ,p_pgp_segment20                in     varchar2
8333   ,p_pgp_segment21                in     varchar2
8334   ,p_pgp_segment22                in     varchar2
8335   ,p_pgp_segment23                in     varchar2
8336   ,p_pgp_segment24                in     varchar2
8337   ,p_pgp_segment25                in     varchar2
8338   ,p_pgp_segment26                in     varchar2
8339   ,p_pgp_segment27                in     varchar2
8340   ,p_pgp_segment28                in     varchar2
8341   ,p_pgp_segment29                in     varchar2
8342   ,p_pgp_segment30                in     varchar2
8343 -- Bug 944911
8344 -- Made p_group_name to be out param
8345 -- and add p_concat_segment to be IN
8346 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8347   ,p_pgp_concat_segments	  in     varchar2
8348   ,p_supervisor_assignment_id     in     number
8349   ,p_group_name                      out nocopy varchar2
8350   ,p_assignment_id                   out nocopy number
8351   ,p_soft_coding_keyflex_id          out nocopy number
8352   ,p_people_group_id                 out nocopy number
8353   ,p_object_version_number           out nocopy number
8354   ,p_effective_start_date            out nocopy date
8355   ,p_effective_end_date              out nocopy date
8356   ,p_assignment_sequence             out nocopy number
8357   ,p_comment_id                      out nocopy number
8358 -- Bug 944911
8359 -- Amended p_concatenated_segments to out from in out
8360 -- added new param p_concat_segments in
8361   ,p_concatenated_segments           out nocopy varchar2
8362   ,p_concat_segments              in     varchar2
8363   ,p_other_manager_warning           out nocopy boolean
8364   ) is
8365   --
8366   -- Declare cursors and local variables
8367   --
8368   -- Declare variables
8369   --
8370   -- WWBUG 2539685
8371   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
8372   l_effective_date     date;
8373   --
8374   l_business_group_id  per_business_groups.business_group_id%TYPE;
8375   l_legislation_code   per_business_groups.legislation_code%TYPE;
8376   l_proc               varchar2(72);
8377   --
8378   -- Declare cursors
8379   --
8380   cursor csr_legislation is
8381     select null
8382     from per_all_assignments_f paf,
8383          per_business_groups_perf pbg
8384     where paf.person_id = p_person_id
8385     and   l_effective_date between paf.effective_start_date
8386                            and     paf.effective_end_date
8387     and   pbg.business_group_id = paf.business_group_id
8388     and   pbg.legislation_code = 'US';
8389   --
8390   --
8391 begin
8392  if g_debug then
8393  l_proc := g_package||'create_secondary_us_emp_asg';
8394   hr_utility.set_location('Entering:'|| l_proc, 10);
8395  end if;
8396   --
8397   -- Initialise local variable
8398   --
8399   l_effective_date := trunc(p_effective_date);
8400   --
8401   -- Validation in addition to Table Handlers
8402   --
8403   -- Ensure that the employee is within a US business group
8404   --
8405   open csr_legislation;
8406   fetch csr_legislation
8407   into l_legislation_code;
8408   if csr_legislation%notfound then
8409     close csr_legislation;
8410     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
8411     hr_utility.set_message_token('LEG_CODE', 'US');
8412     hr_utility.raise_error;
8413   end if;
8414   close csr_legislation;
8415   --
8416   --
8417   -- Call create_secondary_emp_asg
8418   --
8419 -- Bug 944911
8420 -- Added new param p_concat_segments in
8421 -- made p_concatenated_segments to be out only
8422 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
8423 
8424   hr_assignment_api.create_secondary_emp_asg
8425   (p_validate                     =>     p_validate
8426   ,p_effective_date               =>     l_effective_date
8427   ,p_person_id                    =>     p_person_id
8428   ,p_organization_id              =>     p_organization_id
8429   ,p_grade_id                     =>     p_grade_id
8430   ,p_position_id                  =>     p_position_id
8431   ,p_job_id                       =>     p_job_id
8432   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
8433   ,p_payroll_id                   =>     p_payroll_id
8434   ,p_location_id                  =>     p_location_id
8435   ,p_supervisor_id                =>     p_supervisor_id
8436   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
8437   ,p_pay_basis_id                 =>     p_pay_basis_id
8438   ,p_assignment_number            =>     l_assignment_number
8439   ,p_change_reason                =>     p_change_reason
8440   ,p_comments                     =>     p_comments
8441   ,p_date_probation_end           =>     trunc(p_date_probation_end)
8442   ,p_default_code_comb_id         =>     p_default_code_comb_id
8443   ,p_employment_category          =>     p_employment_category
8444   ,p_frequency                    =>     p_frequency
8445   ,p_internal_address_line        =>     p_internal_address_line
8446   ,p_manager_flag                 =>     p_manager_flag
8447   ,p_normal_hours                 =>     p_normal_hours
8448   ,p_perf_review_period           =>     p_perf_review_period
8449   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
8450   ,p_probation_period             =>     p_probation_period
8451   ,p_probation_unit               =>     p_probation_unit
8452   ,p_sal_review_period            =>     p_sal_review_period
8453   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
8454   ,p_set_of_books_id              =>     p_set_of_books_id
8455   ,p_source_type                  =>     p_source_type
8456   ,p_time_normal_finish           =>     p_time_normal_finish
8457   ,p_time_normal_start            =>     p_time_normal_start
8458   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
8459   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
8460   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
8461   ,p_ass_attribute_category       =>     p_ass_attribute_category
8462   ,p_ass_attribute1               =>     p_ass_attribute1
8463   ,p_ass_attribute2               =>     p_ass_attribute2
8464   ,p_ass_attribute3               =>     p_ass_attribute3
8465   ,p_ass_attribute4               =>     p_ass_attribute4
8466   ,p_ass_attribute5               =>     p_ass_attribute5
8467   ,p_ass_attribute6               =>     p_ass_attribute6
8468   ,p_ass_attribute7               =>     p_ass_attribute7
8469   ,p_ass_attribute8               =>     p_ass_attribute8
8470   ,p_ass_attribute9               =>     p_ass_attribute9
8471   ,p_ass_attribute10              =>     p_ass_attribute10
8472   ,p_ass_attribute11              =>     p_ass_attribute11
8473   ,p_ass_attribute12              =>     p_ass_attribute12
8474   ,p_ass_attribute13              =>     p_ass_attribute13
8475   ,p_ass_attribute14              =>     p_ass_attribute14
8476   ,p_ass_attribute15              =>     p_ass_attribute15
8477   ,p_ass_attribute16              =>     p_ass_attribute16
8478   ,p_ass_attribute17              =>     p_ass_attribute17
8479   ,p_ass_attribute18              =>     p_ass_attribute18
8480   ,p_ass_attribute19              =>     p_ass_attribute19
8481   ,p_ass_attribute20              =>     p_ass_attribute20
8482   ,p_ass_attribute21              =>     p_ass_attribute21
8483   ,p_ass_attribute22              =>     p_ass_attribute22
8484   ,p_ass_attribute23              =>     p_ass_attribute23
8485   ,p_ass_attribute24              =>     p_ass_attribute24
8486   ,p_ass_attribute25              =>     p_ass_attribute25
8487   ,p_ass_attribute26              =>     p_ass_attribute26
8488   ,p_ass_attribute27              =>     p_ass_attribute27
8489   ,p_ass_attribute28              =>     p_ass_attribute28
8490   ,p_ass_attribute29              =>     p_ass_attribute29
8491   ,p_ass_attribute30              =>     p_ass_attribute30
8492   ,p_title                        =>     p_title
8493   ,p_scl_segment1                 =>     p_tax_unit
8494   ,p_scl_segment2                 =>     p_timecard_approver
8495   ,p_scl_segment3                 =>     p_timecard_required
8496   ,p_scl_segment4                 =>     p_work_schedule
8497   ,p_scl_segment5                 =>     p_shift
8498   ,p_scl_segment6                 =>     p_spouse_salary
8499   ,p_scl_segment7                 =>     p_legal_representative
8500   ,p_scl_segment8                 =>     p_wc_override_code
8501   ,p_scl_segment9                 =>     p_eeo_1_establishment
8502   ,p_pgp_segment1                 =>     p_pgp_segment1
8503   ,p_pgp_segment2                 =>     p_pgp_segment2
8504   ,p_pgp_segment3                 =>     p_pgp_segment3
8505   ,p_pgp_segment4                 =>     p_pgp_segment4
8506   ,p_pgp_segment5                 =>     p_pgp_segment5
8507   ,p_pgp_segment6                 =>     p_pgp_segment6
8508   ,p_pgp_segment7                 =>     p_pgp_segment7
8509   ,p_pgp_segment8                 =>     p_pgp_segment8
8510   ,p_pgp_segment9                 =>     p_pgp_segment9
8511   ,p_pgp_segment10                =>     p_pgp_segment10
8512   ,p_pgp_segment11                =>     p_pgp_segment11
8513   ,p_pgp_segment12                =>     p_pgp_segment12
8514   ,p_pgp_segment13                =>     p_pgp_segment13
8515   ,p_pgp_segment14                =>     p_pgp_segment14
8516   ,p_pgp_segment15                =>     p_pgp_segment15
8517   ,p_pgp_segment16                =>     p_pgp_segment16
8518   ,p_pgp_segment17                =>     p_pgp_segment17
8519   ,p_pgp_segment18                =>     p_pgp_segment18
8520   ,p_pgp_segment19                =>     p_pgp_segment19
8521   ,p_pgp_segment20                =>     p_pgp_segment20
8522   ,p_pgp_segment21                =>     p_pgp_segment21
8523   ,p_pgp_segment22                =>     p_pgp_segment22
8524   ,p_pgp_segment23                =>     p_pgp_segment23
8525   ,p_pgp_segment24                =>     p_pgp_segment24
8526   ,p_pgp_segment25                =>     p_pgp_segment25
8527   ,p_pgp_segment26                =>     p_pgp_segment26
8528   ,p_pgp_segment27                =>     p_pgp_segment27
8529   ,p_pgp_segment28                =>     p_pgp_segment28
8530   ,p_pgp_segment29                =>     p_pgp_segment29
8531   ,p_pgp_segment30                =>     p_pgp_segment30
8532 -- Bug 944911
8533 -- Made p_group_name to be out param
8534 -- and add p_concat_segment to be IN
8535 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8536 -- Added new param p_pgp_concat_segments
8537   ,p_pgp_concat_segments	  =>	 p_pgp_concat_segments
8538   ,p_group_name                   =>     p_group_name
8539   ,p_assignment_id                =>     p_assignment_id
8540   ,p_soft_coding_keyflex_id       =>     p_soft_coding_keyflex_id
8541   ,p_people_group_id              =>     p_people_group_id
8542   ,p_object_version_number        =>     p_object_version_number
8543   ,p_effective_start_date         =>     p_effective_start_date
8544   ,p_effective_end_date           =>     p_effective_end_date
8545   ,p_assignment_sequence          =>     p_assignment_sequence
8546   ,p_comment_id                   =>     p_comment_id
8547   ,p_concatenated_segments        =>     p_concatenated_segments
8548   ,p_scl_concat_segments          =>     p_concat_segments
8549   ,p_other_manager_warning        =>     p_other_manager_warning
8550   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
8551   );
8552   --
8553  if g_debug then
8554   hr_utility.set_location(' Leaving:'||l_proc, 30);
8555  end if;
8556   --
8557   end create_us_secondary_emp_asg;
8558 
8559 --
8560 -- ----------------------------------------------------------------------------
8561 -- |---------------------< create_us_secondary_emp_asg >-----------------------|
8562 -- ----------------------------------------------------------------------------
8563 --   Overloded procedure to include p_hourly_salaried_warning
8564 --
8565 procedure create_us_secondary_emp_asg
8566   (p_validate                     in     boolean
8567   ,p_effective_date               in     date
8568   ,p_person_id                    in     number
8569   ,p_organization_id              in     number
8570   ,p_grade_id                     in     number
8571   ,p_position_id                  in     number
8572   ,p_job_id                       in     number
8573   ,p_assignment_status_type_id    in     number
8574   ,p_payroll_id                   in     number
8575   ,p_location_id                  in     number
8576   ,p_supervisor_id                in     number
8577   ,p_special_ceiling_step_id      in     number
8578   ,p_pay_basis_id                 in     number
8579   ,p_assignment_number            in out nocopy varchar2
8580   ,p_change_reason                in     varchar2
8581   ,p_comments                     in     varchar2
8582   ,p_date_probation_end           in     date
8583   ,p_default_code_comb_id         in     number
8584   ,p_employment_category          in     varchar2
8585   ,p_frequency                    in     varchar2
8586   ,p_internal_address_line        in     varchar2
8587   ,p_manager_flag                 in     varchar2
8588   ,p_normal_hours                 in     number
8589   ,p_perf_review_period           in     number
8590   ,p_perf_review_period_frequency in     varchar2
8591   ,p_probation_period             in     number
8592   ,p_probation_unit               in     varchar2
8593   ,p_sal_review_period            in     number
8594   ,p_sal_review_period_frequency  in     varchar2
8595   ,p_set_of_books_id              in     number
8596   ,p_source_type                  in     varchar2
8597   ,p_time_normal_finish           in     varchar2
8598   ,p_time_normal_start            in     varchar2
8599   ,p_bargaining_unit_code         in     varchar2
8600   ,p_labour_union_member_flag     in     varchar2
8601   ,p_hourly_salaried_code         in     varchar2
8602   ,p_ass_attribute_category       in     varchar2
8603   ,p_ass_attribute1               in     varchar2
8604   ,p_ass_attribute2               in     varchar2
8605   ,p_ass_attribute3               in     varchar2
8606   ,p_ass_attribute4               in     varchar2
8607   ,p_ass_attribute5               in     varchar2
8608   ,p_ass_attribute6               in     varchar2
8609   ,p_ass_attribute7               in     varchar2
8610   ,p_ass_attribute8               in     varchar2
8611   ,p_ass_attribute9               in     varchar2
8612   ,p_ass_attribute10              in     varchar2
8613   ,p_ass_attribute11              in     varchar2
8614   ,p_ass_attribute12              in     varchar2
8615   ,p_ass_attribute13              in     varchar2
8616   ,p_ass_attribute14              in     varchar2
8617   ,p_ass_attribute15              in     varchar2
8618   ,p_ass_attribute16              in     varchar2
8619   ,p_ass_attribute17              in     varchar2
8620   ,p_ass_attribute18              in     varchar2
8621   ,p_ass_attribute19              in     varchar2
8622   ,p_ass_attribute20              in     varchar2
8623   ,p_ass_attribute21              in     varchar2
8624   ,p_ass_attribute22              in     varchar2
8625   ,p_ass_attribute23              in     varchar2
8626   ,p_ass_attribute24              in     varchar2
8627   ,p_ass_attribute25              in     varchar2
8628   ,p_ass_attribute26              in     varchar2
8629   ,p_ass_attribute27              in     varchar2
8630   ,p_ass_attribute28              in     varchar2
8631   ,p_ass_attribute29              in     varchar2
8632   ,p_ass_attribute30              in     varchar2
8633   ,p_title                        in     varchar2
8634   ,p_tax_unit                     in     varchar2
8635   ,p_timecard_approver            in     varchar2
8636   ,p_timecard_required            in     varchar2
8637   ,p_work_schedule                in     varchar2
8638   ,p_shift                        in     varchar2
8639   ,p_spouse_salary                in     varchar2
8640   ,p_legal_representative         in     varchar2
8641   ,p_wc_override_code             in     varchar2
8642   ,p_eeo_1_establishment          in     varchar2
8643   ,p_pgp_segment1                 in     varchar2
8644   ,p_pgp_segment2                 in     varchar2
8645   ,p_pgp_segment3                 in     varchar2
8646   ,p_pgp_segment4                 in     varchar2
8647   ,p_pgp_segment5                 in     varchar2
8648   ,p_pgp_segment6                 in     varchar2
8649   ,p_pgp_segment7                 in     varchar2
8650   ,p_pgp_segment8                 in     varchar2
8651   ,p_pgp_segment9                 in     varchar2
8652   ,p_pgp_segment10                in     varchar2
8653   ,p_pgp_segment11                in     varchar2
8654   ,p_pgp_segment12                in     varchar2
8655   ,p_pgp_segment13                in     varchar2
8656   ,p_pgp_segment14                in     varchar2
8657   ,p_pgp_segment15                in     varchar2
8658   ,p_pgp_segment16                in     varchar2
8659   ,p_pgp_segment17                in     varchar2
8660   ,p_pgp_segment18                in     varchar2
8661   ,p_pgp_segment19                in     varchar2
8662   ,p_pgp_segment20                in     varchar2
8663   ,p_pgp_segment21                in     varchar2
8664   ,p_pgp_segment22                in     varchar2
8665   ,p_pgp_segment23                in     varchar2
8666   ,p_pgp_segment24                in     varchar2
8667   ,p_pgp_segment25                in     varchar2
8668   ,p_pgp_segment26                in     varchar2
8669   ,p_pgp_segment27                in     varchar2
8670   ,p_pgp_segment28                in     varchar2
8671   ,p_pgp_segment29                in     varchar2
8672   ,p_pgp_segment30                in     varchar2
8673 -- Bug 944911
8674 -- Made p_group_name to be out param
8675 -- and add p_concat_segment to be IN
8676 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8677   ,p_pgp_concat_segments	  in     varchar2
8678   ,p_supervisor_assignment_id     in     number
8679   ,p_group_name                      out nocopy varchar2
8680   ,p_assignment_id                   out nocopy number
8681   ,p_soft_coding_keyflex_id          out nocopy number
8682   ,p_people_group_id                 out nocopy number
8683   ,p_object_version_number           out nocopy number
8684   ,p_effective_start_date            out nocopy date
8685   ,p_effective_end_date              out nocopy date
8686   ,p_assignment_sequence             out nocopy number
8687   ,p_comment_id                      out nocopy number
8688 -- Bug 944911
8689 -- Amended p_concatenated_segments to out from in out
8690 -- added new param p_concat_segments in
8691   ,p_concatenated_segments           out nocopy varchar2
8692   ,p_concat_segments                 in     varchar2
8693   ,p_other_manager_warning           out nocopy boolean
8694   ,p_hourly_salaried_warning         out nocopy boolean
8695   ,p_cagr_grade_def_id               out nocopy number
8696   ,p_cagr_concatenated_segments      out nocopy varchar2
8697   ) is
8698   --
8699   -- Declare cursors and local variables
8700   --
8701   -- Declare variables
8702   --
8703   -- Assigned the value p_assignment_number for fix of #2823013
8704   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
8705   l_effective_date     date;
8706   --
8707   l_business_group_id  per_business_groups.business_group_id%TYPE;
8708   l_legislation_code   per_business_groups.legislation_code%TYPE;
8709   l_proc               varchar2(72);
8710   --
8711   -- Declare cursors
8712   --
8713   cursor csr_legislation is
8714     select null
8715     from per_all_assignments_f paf,
8716          per_business_groups_perf pbg
8717     where paf.person_id = p_person_id
8718     and   l_effective_date between paf.effective_start_date
8719                            and     paf.effective_end_date
8720     and   pbg.business_group_id = paf.business_group_id
8721     and   pbg.legislation_code = 'US';
8722   --
8723   --
8724 begin
8725  if g_debug then
8726  l_proc := g_package||'create_secondary_us_emp_asg';
8727   hr_utility.set_location('Entering:'|| l_proc, 10);
8728  end if;
8729   --
8730   -- Initialise local variable
8731   --
8732   l_effective_date := trunc(p_effective_date);
8733   --
8734   -- Validation in addition to Table Handlers
8735   --
8736   -- Ensure that the employee is within a US business group
8737   --
8738   open csr_legislation;
8739   fetch csr_legislation
8740   into l_legislation_code;
8741   if csr_legislation%notfound then
8742     close csr_legislation;
8743     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
8744     hr_utility.set_message_token('LEG_CODE', 'US');
8745     hr_utility.raise_error;
8746   end if;
8747   close csr_legislation;
8748   --
8749   --
8750   -- Call create_secondary_emp_asg
8751   --
8752 -- Bug 944911
8753 -- Added new param p_concat_segments in
8754 -- made p_concatenated_segments to be out only
8755 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
8756 
8757   hr_assignment_api.create_secondary_emp_asg
8758   (p_validate                     =>     p_validate
8759   ,p_effective_date               =>     l_effective_date
8760   ,p_person_id                    =>     p_person_id
8761   ,p_organization_id              =>     p_organization_id
8762   ,p_grade_id                     =>     p_grade_id
8763   ,p_position_id                  =>     p_position_id
8764   ,p_job_id                       =>     p_job_id
8765   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
8766   ,p_payroll_id                   =>     p_payroll_id
8767   ,p_location_id                  =>     p_location_id
8768   ,p_supervisor_id                =>     p_supervisor_id
8769   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
8770   ,p_pay_basis_id                 =>     p_pay_basis_id
8771   ,p_assignment_number            =>     l_assignment_number
8772   ,p_change_reason                =>     p_change_reason
8773   ,p_comments                     =>     p_comments
8774   ,p_date_probation_end           =>     trunc(p_date_probation_end)
8775   ,p_default_code_comb_id         =>     p_default_code_comb_id
8776   ,p_employment_category          =>     p_employment_category
8777   ,p_frequency                    =>     p_frequency
8778   ,p_internal_address_line        =>     p_internal_address_line
8779   ,p_manager_flag                 =>     p_manager_flag
8780   ,p_normal_hours                 =>     p_normal_hours
8781   ,p_perf_review_period           =>     p_perf_review_period
8782   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
8783   ,p_probation_period             =>     p_probation_period
8784   ,p_probation_unit               =>     p_probation_unit
8785   ,p_sal_review_period            =>     p_sal_review_period
8786   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
8787   ,p_set_of_books_id              =>     p_set_of_books_id
8788   ,p_source_type                  =>     p_source_type
8789   ,p_time_normal_finish           =>     p_time_normal_finish
8790   ,p_time_normal_start            =>     p_time_normal_start
8791   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
8792   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
8793   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
8794   ,p_ass_attribute_category       =>     p_ass_attribute_category
8795   ,p_ass_attribute1               =>     p_ass_attribute1
8796   ,p_ass_attribute2               =>     p_ass_attribute2
8797   ,p_ass_attribute3               =>     p_ass_attribute3
8798   ,p_ass_attribute4               =>     p_ass_attribute4
8799   ,p_ass_attribute5               =>     p_ass_attribute5
8800   ,p_ass_attribute6               =>     p_ass_attribute6
8801   ,p_ass_attribute7               =>     p_ass_attribute7
8802   ,p_ass_attribute8               =>     p_ass_attribute8
8803   ,p_ass_attribute9               =>     p_ass_attribute9
8804   ,p_ass_attribute10              =>     p_ass_attribute10
8805   ,p_ass_attribute11              =>     p_ass_attribute11
8806   ,p_ass_attribute12              =>     p_ass_attribute12
8807   ,p_ass_attribute13              =>     p_ass_attribute13
8808   ,p_ass_attribute14              =>     p_ass_attribute14
8809   ,p_ass_attribute15              =>     p_ass_attribute15
8810   ,p_ass_attribute16              =>     p_ass_attribute16
8811   ,p_ass_attribute17              =>     p_ass_attribute17
8812   ,p_ass_attribute18              =>     p_ass_attribute18
8813   ,p_ass_attribute19              =>     p_ass_attribute19
8814   ,p_ass_attribute20              =>     p_ass_attribute20
8815   ,p_ass_attribute21              =>     p_ass_attribute21
8816   ,p_ass_attribute22              =>     p_ass_attribute22
8817   ,p_ass_attribute23              =>     p_ass_attribute23
8818   ,p_ass_attribute24              =>     p_ass_attribute24
8819   ,p_ass_attribute25              =>     p_ass_attribute25
8820   ,p_ass_attribute26              =>     p_ass_attribute26
8821   ,p_ass_attribute27              =>     p_ass_attribute27
8822   ,p_ass_attribute28              =>     p_ass_attribute28
8823   ,p_ass_attribute29              =>     p_ass_attribute29
8824   ,p_ass_attribute30              =>     p_ass_attribute30
8825   ,p_title                        =>     p_title
8826   ,p_scl_segment1                 =>     p_tax_unit
8827   ,p_scl_segment2                 =>     p_timecard_approver
8828   ,p_scl_segment3                 =>     p_timecard_required
8829   ,p_scl_segment4                 =>     p_work_schedule
8830   ,p_scl_segment5                 =>     p_shift
8831   ,p_scl_segment6                 =>     p_spouse_salary
8832   ,p_scl_segment7                 =>     p_legal_representative
8833   ,p_scl_segment8                 =>     p_wc_override_code
8834   ,p_scl_segment9                 =>     p_eeo_1_establishment
8835   ,p_pgp_segment1                 =>     p_pgp_segment1
8836   ,p_pgp_segment2                 =>     p_pgp_segment2
8837   ,p_pgp_segment3                 =>     p_pgp_segment3
8838   ,p_pgp_segment4                 =>     p_pgp_segment4
8839   ,p_pgp_segment5                 =>     p_pgp_segment5
8840   ,p_pgp_segment6                 =>     p_pgp_segment6
8841   ,p_pgp_segment7                 =>     p_pgp_segment7
8842   ,p_pgp_segment8                 =>     p_pgp_segment8
8843   ,p_pgp_segment9                 =>     p_pgp_segment9
8844   ,p_pgp_segment10                =>     p_pgp_segment10
8845   ,p_pgp_segment11                =>     p_pgp_segment11
8846   ,p_pgp_segment12                =>     p_pgp_segment12
8847   ,p_pgp_segment13                =>     p_pgp_segment13
8848   ,p_pgp_segment14                =>     p_pgp_segment14
8849   ,p_pgp_segment15                =>     p_pgp_segment15
8850   ,p_pgp_segment16                =>     p_pgp_segment16
8851   ,p_pgp_segment17                =>     p_pgp_segment17
8852   ,p_pgp_segment18                =>     p_pgp_segment18
8853   ,p_pgp_segment19                =>     p_pgp_segment19
8854   ,p_pgp_segment20                =>     p_pgp_segment20
8855   ,p_pgp_segment21                =>     p_pgp_segment21
8856   ,p_pgp_segment22                =>     p_pgp_segment22
8857   ,p_pgp_segment23                =>     p_pgp_segment23
8858   ,p_pgp_segment24                =>     p_pgp_segment24
8859   ,p_pgp_segment25                =>     p_pgp_segment25
8860   ,p_pgp_segment26                =>     p_pgp_segment26
8861   ,p_pgp_segment27                =>     p_pgp_segment27
8862   ,p_pgp_segment28                =>     p_pgp_segment28
8863   ,p_pgp_segment29                =>     p_pgp_segment29
8864   ,p_pgp_segment30                =>     p_pgp_segment30
8865 -- Bug 944911
8866 -- Made p_group_name to be out param
8867 -- and add p_concat_segment to be IN
8868 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8869 -- Added new param p_pgp_concat_segments
8870   ,p_pgp_concat_segments	  =>	 p_pgp_concat_segments
8871   ,p_group_name                   =>     p_group_name
8872   ,p_assignment_id                =>     p_assignment_id
8873   ,p_soft_coding_keyflex_id       =>     p_soft_coding_keyflex_id
8874   ,p_people_group_id              =>     p_people_group_id
8875   ,p_object_version_number        =>     p_object_version_number
8876   ,p_effective_start_date         =>     p_effective_start_date
8877   ,p_effective_end_date           =>     p_effective_end_date
8878   ,p_assignment_sequence          =>     p_assignment_sequence
8879   ,p_comment_id                   =>     p_comment_id
8880   ,p_concatenated_segments        =>     p_concatenated_segments
8881   ,p_scl_concat_segments          =>     p_concat_segments
8882   ,p_other_manager_warning        =>     p_other_manager_warning
8883   ,p_hourly_salaried_warning      =>     p_hourly_salaried_warning
8884   ,p_cagr_grade_def_id            =>     p_cagr_grade_def_id
8885   ,p_cagr_concatenated_segments   =>     p_cagr_concatenated_segments
8886   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
8887   );
8888   --
8889  if g_debug then
8890   hr_utility.set_location(' Leaving:'||l_proc, 30);
8891  end if;
8892   --
8893   end create_us_secondary_emp_asg;
8894 
8895 --
8896 -- ----------------------------------------------------------------------------
8897 -- |------------------------< final_process_emp_asg >-------------------------|
8898 -- ----------------------------------------------------------------------------
8899 --
8900 procedure final_process_emp_asg
8901   (p_validate                     in     boolean
8902   ,p_assignment_id                in     number
8903   ,p_object_version_number        in out nocopy number
8904   ,p_final_process_date           in     date
8905   ,p_effective_start_date            out nocopy date
8906   ,p_effective_end_date              out nocopy date
8907   ,p_org_now_no_manager_warning      out nocopy boolean
8908   ,p_asg_future_changes_warning      out nocopy boolean
8909   ,p_entries_changed_warning         out nocopy varchar2
8910   ) is
8911   --
8912   -- Declare cursors and local variables
8913   --
8914   -- Out variables
8915   --
8916   l_asg_future_changes_warning boolean := FALSE;
8917   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
8918   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
8919   l_entries_changed_warning    varchar2(1) := 'N';
8920   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
8921   l_org_now_no_manager_warning boolean := FALSE;
8922   --
8923   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
8924   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
8925   l_proc                       varchar2(72)
8926                                      := g_package || 'final_process_emp_asg';
8927   l_actual_termination_date    date;
8928   l_final_process_date         date;
8929   l_max_asg_end_date           date;
8930   --
8931   lv_object_version_number     number := p_object_version_number ;
8932   --
8933   cursor csr_get_derived_details is
8934     select asg.assignment_type
8935          , asg.primary_flag
8936       from per_all_assignments_f      asg
8937      where asg.assignment_id        = p_assignment_id
8938        and l_final_process_date     between asg.effective_start_date
8939                                     and     asg.effective_end_date;
8940   --
8941   cursor csr_valid_term_assign is
8942     select min(asg.effective_start_date) - 1
8943       from per_all_assignments_f           asg
8944      where asg.assignment_id             = p_assignment_id
8945        and exists ( select null
8946 		    from per_assignment_status_types ast
8947 		    where ast.assignment_status_type_id
8948 		     = asg.assignment_status_type_id
8949                      and ast.per_system_status = 'TERM_ASSIGN');
8950 
8951 --
8952   cursor csr_invalid_term_assign is
8953     select max(asg.effective_end_date)
8954       from per_all_assignments_f           asg
8955      where asg.assignment_id      = p_assignment_id
8956        and exists ( select null
8957 		    from per_assignment_status_types ast
8958 		    where ast.assignment_status_type_id
8959 		     = asg.assignment_status_type_id
8960                      and ast.per_system_status = 'TERM_ASSIGN');
8961 
8962 --
8963 begin
8964  if g_debug then
8965   hr_utility.set_location('Entering:'|| l_proc, 1);
8966  end if;
8967   --
8968   l_object_version_number := p_object_version_number;
8969   l_final_process_date    := trunc(p_final_process_date);
8970   --
8971   -- Issue a savepoint.
8972   --
8973   savepoint final_process_emp_asg;
8974   --
8975  if g_debug then
8976   hr_utility.set_location(l_proc, 10);
8977  end if;
8978   --
8979   -- Validation in addition to Table Handlers
8980   --
8981   -- Get assignment and business group details for validation.
8982   --
8983   hr_api.mandatory_arg_error
8984      (p_api_name       => l_proc
8985      ,p_argument       => 'assignment_id'
8986      ,p_argument_value => p_assignment_id
8987      );
8988   --
8989   hr_api.mandatory_arg_error
8990      (p_api_name       => l_proc
8991      ,p_argument       => 'final_process_date'
8992      ,p_argument_value => l_final_process_date
8993      );
8994   --
8995  if g_debug then
8996   hr_utility.set_location(l_proc, 20);
8997  end if;
8998   --
8999   open  csr_get_derived_details;
9000   fetch csr_get_derived_details
9001    into l_assignment_type
9002       , l_primary_flag;
9003   --
9004   if csr_get_derived_details%NOTFOUND
9005   then
9006     --
9007  if g_debug then
9008     hr_utility.set_location(l_proc, 30);
9009  end if;
9010     --
9011     close csr_get_derived_details;
9012     --
9013     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
9014     hr_utility.raise_error;
9015   end if;
9016   --
9017   close csr_get_derived_details;
9018   --
9019   -- Start of API User Hook for the before hook of final_process_emp_asg.
9020   --
9021   begin
9022      hr_assignment_bka.final_process_emp_asg_b
9023        (p_assignment_id                 =>  p_assignment_id
9024        ,p_object_version_number         =>  p_object_version_number
9025        ,p_final_process_date            =>  l_final_process_date
9026        );
9027   exception
9028      when hr_api.cannot_find_prog_unit then
9029        hr_api.cannot_find_prog_unit_error
9030          (p_module_name       => 'FINAL_PROCESS_EMP_ASG',
9031           p_hook_type         => 'BP'
9032          );
9033   end;
9034   --
9035   --
9036  if g_debug then
9037   hr_utility.set_location(l_proc, 40);
9038  end if;
9039   --
9040   -- The assignment must not be a primary assignment.
9041   --
9042   if l_primary_flag <> 'N'
9043   then
9044     --
9045  if g_debug then
9046     hr_utility.set_location(l_proc, 50);
9047  end if;
9048     --
9049     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
9050     hr_utility.raise_error;
9051   end if;
9052   --
9053  if g_debug then
9054   hr_utility.set_location(l_proc, 60);
9055  end if;
9056   --
9057   -- The assignment must be an employee assignment.
9058   --
9059   if l_assignment_type <> 'E'
9060   then
9061     --
9062  if g_debug then
9063     hr_utility.set_location(l_proc, 70);
9064  end if;
9065     --
9066     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
9067     hr_utility.raise_error;
9068   end if;
9069 
9070   -- Ensure that the assignment has not been terminated previously
9071 
9072   --
9073   open  csr_invalid_term_assign;
9074   fetch csr_invalid_term_assign
9075    into l_max_asg_end_date;
9076   close csr_invalid_term_assign;
9077 
9078   --
9079   if l_max_asg_end_date <> hr_api.g_eot
9080   then
9081     --
9082  if g_debug then
9083     hr_utility.set_location(l_proc, 90);
9084  end if;
9085     --
9086     hr_utility.set_message(801,'HR_7962_PDS_INV_FP_CHANGE');
9087     hr_utility.raise_error;
9088   end if;
9089   --
9090  if g_debug then
9091   hr_utility.set_location(l_proc, 80);
9092  end if;
9093   --
9094   -- Ensure that the the final process date is on or after the actual
9095   -- termination date by checking that the assignment status is TERM_ASSIGN for
9096   -- the day after the final process date.
9097   --
9098   open  csr_valid_term_assign;
9099   fetch csr_valid_term_assign
9100    into l_actual_termination_date;
9101   close csr_valid_term_assign;
9102 
9103   --
9104   if l_actual_termination_date is null
9105   then
9106     --
9107  if g_debug then
9108     hr_utility.set_location(l_proc, 90);
9109  end if;
9110     --
9111     hr_utility.set_message(801,'HR_51007_ASG_INV_NOT_ACT_TERM');
9112     hr_utility.raise_error;
9113   end if;
9114 
9115   if l_final_process_date < l_actual_termination_date then
9116 
9117  if g_debug then
9118     hr_utility.set_location(l_proc, 95);
9119  end if;
9120 
9121     -- This error message has been set temporarily
9122 
9123     hr_utility.set_message(801,'HR_7963_PDS_INV_FP_BEFORE_ATT');
9124     hr_utility.raise_error;
9125   end if;
9126   --
9127   --
9128  if g_debug then
9129   hr_utility.set_location(l_proc, 100);
9130  end if;
9131   --
9132   -- Process Logic
9133   --
9134   -- Call the business support process to update assignment and maintain the
9135   -- element entries.
9136   --
9137   hr_assignment_internal.final_process_emp_asg_sup
9138     (p_assignment_id              => p_assignment_id
9139     ,p_object_version_number      => l_object_version_number
9140     ,p_final_process_date         => l_final_process_date
9141     ,p_actual_termination_date    => l_actual_termination_date
9142     ,p_effective_start_date       => l_effective_start_date
9143     ,p_effective_end_date         => l_effective_end_date
9144     ,p_org_now_no_manager_warning => l_org_now_no_manager_warning
9145     ,p_asg_future_changes_warning => l_asg_future_changes_warning
9146     ,p_entries_changed_warning    => l_entries_changed_warning
9147     );
9148   --
9149  if g_debug then
9150   hr_utility.set_location(l_proc, 110);
9151  end if;
9152   --
9153   -- Start of API User Hook for the after hook of final_process_emp_asg.
9154   --
9155   begin
9156      hr_assignment_bka.final_process_emp_asg_a
9157         (p_assignment_id                 =>     p_assignment_id
9158         ,p_object_version_number         =>     l_object_version_number
9159         ,p_final_process_date            =>     p_final_process_date
9160         ,p_effective_start_date          =>     l_effective_start_date
9161         ,p_effective_end_date            =>     l_effective_end_date
9162         ,p_org_now_no_manager_warning    =>     l_org_now_no_manager_warning
9163         ,p_asg_future_changes_warning    =>     l_asg_future_changes_warning
9164         ,p_entries_changed_warning       =>     l_entries_changed_warning
9165         );
9166   exception
9167      when hr_api.cannot_find_prog_unit then
9168        hr_api.cannot_find_prog_unit_error
9169          (p_module_name       => 'FINAL_PROCESS_EMP_ASG',
9170           p_hook_type         => 'AP'
9171          );
9172   end;
9173   --
9174   -- End of API User Hook for the after hook of final_process_emp_asg.
9175   --
9176   --
9177   -- When in validation only mode raise the Validate_Enabled exception
9178   --
9179   if p_validate then
9180     raise hr_api.validate_enabled;
9181   end if;
9182   --
9183   -- Set all output arguments
9184   --
9185   p_asg_future_changes_warning := l_asg_future_changes_warning;
9186   p_effective_end_date         := l_effective_end_date;
9187   p_effective_start_date       := l_effective_start_date;
9188   p_entries_changed_warning    := l_entries_changed_warning;
9189   p_object_version_number      := l_object_version_number;
9190   p_org_now_no_manager_warning := l_org_now_no_manager_warning;
9191   --
9192  if g_debug then
9193   hr_utility.set_location(' Leaving:'||l_proc, 300);
9194  end if;
9195 exception
9196   when hr_api.validate_enabled then
9197     --
9198     -- As the Validate_Enabled exception has been raised
9199     -- we must rollback to the savepoint
9200     --
9201     ROLLBACK TO final_process_emp_asg;
9202     --
9203     -- Only set output warning arguments
9204     -- (Any key or derived arguments must be set to null
9205     -- when validation only mode is being used.)
9206     --
9207     p_asg_future_changes_warning := l_asg_future_changes_warning;
9208     p_effective_end_date         := null;
9209     p_effective_start_date       := null;
9210     p_entries_changed_warning    := l_entries_changed_warning;
9211     p_org_now_no_manager_warning := l_org_now_no_manager_warning;
9212     --
9213   when others then
9214     --
9215     -- A validation or unexpected error has occurred
9216     --
9217     -- Added as part of fix to bug 632479
9218     --
9219     p_object_version_number := lv_object_version_number;
9220 
9221     p_effective_start_date            := null;
9222     p_effective_end_date              := null;
9223     p_org_now_no_manager_warning      := null;
9224     p_asg_future_changes_warning      := null;
9225     p_entries_changed_warning         := null;
9226 
9227 
9228     ROLLBACK TO final_process_emp_asg;
9229     raise;
9230     --
9231     -- End of fix.
9232     --
9233 end final_process_emp_asg;
9234 --
9235 -- 70.4 change end.
9236 --
9237 -- ----------------------------------------------------------------------------
9238 -- |---------------------------< suspend_emp_asg >----------------------------|
9239 -- ----------------------------------------------------------------------------
9240 --
9241 procedure suspend_emp_asg
9242   (p_validate                     in     boolean
9243   ,p_effective_date               in     date
9244   ,p_datetrack_update_mode        in     varchar2
9245   ,p_assignment_id                in     number
9246   ,p_change_reason                in     varchar2
9247   ,p_object_version_number        in out nocopy number
9248   ,p_assignment_status_type_id    in     number
9249   ,p_effective_start_date            out nocopy date
9250   ,p_effective_end_date              out nocopy date
9251   ) is
9252   --
9253   -- Declare cursors and local variables
9254   --
9255   l_effective_date             date;
9256   --
9257   -- Out variables
9258   --
9259   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
9260   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
9261   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
9262   --
9263   lv_object_version_number     number := p_object_version_number ;
9264   --
9265   l_proc                       varchar2(72);
9266   --
9267 begin
9268  if g_debug then
9269  l_proc := g_package||'suspend_emp_asg';
9270   hr_utility.set_location('Entering:'|| l_proc, 5);
9271  end if;
9272   --
9273   --
9274   l_object_version_number := p_object_version_number;
9275   --
9276   -- Issue a savepoint.
9277   --
9278   savepoint suspend_emp_asg;
9279   --
9280  if g_debug then
9281   hr_utility.set_location(l_proc, 10);
9282  end if;
9283   --
9284   -- Initialise local variable - added 25-Aug-97. RMF.
9285   --
9286   l_effective_date := trunc(p_effective_date);
9287   --
9288   -- Validation in addition to Table Handlers
9289   --
9290   -- None required.
9291   --
9292   -- Process Logic
9293   --
9294   -- Start of API User Hook for the before hook of suspend_emp_asg.
9295   --
9296   begin
9297      hr_assignment_bk7.suspend_emp_asg_b
9298        (p_effective_date               => l_effective_date
9299        ,p_datetrack_update_mode        => p_datetrack_update_mode
9300        ,p_assignment_id                => p_assignment_id
9301        ,p_change_reason                => p_change_reason
9302        ,p_object_version_number        => p_object_version_number
9303        ,p_assignment_status_type_id    => p_assignment_status_type_id
9304        );
9305   exception
9306      when hr_api.cannot_find_prog_unit then
9307        hr_api.cannot_find_prog_unit_error
9308          (p_module_name       => 'SUSPEND_EMP_ASG',
9309           p_hook_type         => 'BP'
9310          );
9311   end;
9312   --
9313   --
9314   -- Update employee assignment.
9315   --
9316   hr_assignment_internal.update_status_type_emp_asg
9317     (p_effective_date               => l_effective_date
9318     ,p_datetrack_update_mode        => p_datetrack_update_mode
9319     ,p_assignment_id                => p_assignment_id
9320     ,p_change_reason                => p_change_reason
9321     ,p_object_version_number        => l_object_version_number
9322     ,p_expected_system_status       => 'SUSP_ASSIGN'
9323     ,p_assignment_status_type_id    => p_assignment_status_type_id
9324     ,p_effective_start_date         => l_effective_start_date
9325     ,p_effective_end_date           => l_effective_end_date
9326     );
9327   --
9328  if g_debug then
9329   hr_utility.set_location(l_proc, 20);
9330  end if;
9331   --
9332   -- Start of API User Hook for the after hook of suspend_emp_asg.
9333   --
9334   begin
9335      hr_assignment_bk7.suspend_emp_asg_a
9336         (p_effective_date               => l_effective_date
9337         ,p_datetrack_update_mode        => p_datetrack_update_mode
9338         ,p_assignment_id                => p_assignment_id
9339         ,p_change_reason                => p_change_reason
9340         ,p_object_version_number        => l_object_version_number
9341         ,p_assignment_status_type_id    => p_assignment_status_type_id
9342         ,p_effective_start_date         => l_effective_start_date
9343         ,p_effective_end_date           => l_effective_end_date
9344         );
9345   exception
9346      when hr_api.cannot_find_prog_unit then
9347        hr_api.cannot_find_prog_unit_error
9348          (p_module_name       => 'SUSPEND_EMP_ASG',
9349           p_hook_type         => 'AP'
9350          );
9351   end;
9352   --
9353   -- End of API User Hook for the after hook of suspend_emp_asg.
9354   --
9355   --
9356   -- When in validation only mode raise the Validate_Enabled exception
9357   --
9358   if p_validate then
9359     raise hr_api.validate_enabled;
9360   end if;
9361   --
9362   -- Set all output arguments
9363   --
9364   p_object_version_number := l_object_version_number;
9365   p_effective_start_date  := l_effective_start_date;
9366   p_effective_end_date    := l_effective_end_date;
9367   --
9368  if g_debug then
9369   hr_utility.set_location(' Leaving:'||l_proc, 100);
9370  end if;
9371 exception
9372   when hr_api.validate_enabled then
9373     --
9374     -- As the Validate_Enabled exception has been raised
9375     -- we must rollback to the savepoint
9376     --
9377     ROLLBACK TO suspend_emp_asg;
9378     --
9379     -- Only set output warning arguments
9380     -- (Any key or derived arguments must be set to null
9381     -- when validation only mode is being used.)
9382     --
9383     p_object_version_number  := p_object_version_number;
9384     p_effective_start_date   := null;
9385     p_effective_end_date     := null;
9386     --
9387   when others then
9388     --
9389     -- A validation or unexpected error has occurred
9390     --
9391     -- Added as part of fix to bug 632479
9392     --
9393     p_object_version_number := lv_object_version_number;
9394     p_effective_start_date   := null;
9395     p_effective_end_date     := null;
9396     --
9397     ROLLBACK TO suspend_emp_asg;
9398     raise;
9399     --
9400     -- End of fix.
9401     --
9402 end suspend_emp_asg;
9403 --
9404 -- ----------------------------------------------------------------------------
9405 -- |--------------------------< update_emp_asg >-OLD--------------------------|
9406 -- ----------------------------------------------------------------------------
9407 -- This is the old procedure that simply calls the new updated
9408 -- procedure passing in nulls for the new in parms and trapping
9409 -- new out parms in local variables.
9410 --
9411 procedure update_emp_asg
9412   (p_validate                     in     boolean
9413   ,p_effective_date               in     date
9414   ,p_datetrack_update_mode        in     varchar2
9415   ,p_assignment_id                in     number
9416   ,p_object_version_number        in out nocopy number
9417   ,p_supervisor_id                in     number
9418   ,p_assignment_number            in     varchar2
9419   ,p_change_reason                in     varchar2
9420   ,p_comments                     in     varchar2
9421   ,p_date_probation_end           in     date
9422   ,p_default_code_comb_id         in     number
9423   ,p_frequency                    in     varchar2
9424   ,p_internal_address_line        in     varchar2
9425   ,p_manager_flag                 in     varchar2
9426   ,p_normal_hours                 in     number
9427   ,p_perf_review_period           in     number
9428   ,p_perf_review_period_frequency in     varchar2
9429   ,p_probation_period             in     number
9430   ,p_probation_unit               in     varchar2
9431   ,p_sal_review_period            in     number
9432   ,p_sal_review_period_frequency  in     varchar2
9433   ,p_set_of_books_id              in     number
9434   ,p_source_type                  in     varchar2
9435   ,p_time_normal_finish           in     varchar2
9436   ,p_time_normal_start            in     varchar2
9437   ,p_bargaining_unit_code         in     varchar2
9438   ,p_labour_union_member_flag     in     varchar2
9439   ,p_hourly_salaried_code         in     varchar2
9440   ,p_ass_attribute_category       in     varchar2
9441   ,p_ass_attribute1               in     varchar2
9442   ,p_ass_attribute2               in     varchar2
9443   ,p_ass_attribute3               in     varchar2
9444   ,p_ass_attribute4               in     varchar2
9445   ,p_ass_attribute5               in     varchar2
9446   ,p_ass_attribute6               in     varchar2
9447   ,p_ass_attribute7               in     varchar2
9448   ,p_ass_attribute8               in     varchar2
9449   ,p_ass_attribute9               in     varchar2
9450   ,p_ass_attribute10              in     varchar2
9451   ,p_ass_attribute11              in     varchar2
9452   ,p_ass_attribute12              in     varchar2
9453   ,p_ass_attribute13              in     varchar2
9454   ,p_ass_attribute14              in     varchar2
9455   ,p_ass_attribute15              in     varchar2
9456   ,p_ass_attribute16              in     varchar2
9457   ,p_ass_attribute17              in     varchar2
9458   ,p_ass_attribute18              in     varchar2
9459   ,p_ass_attribute19              in     varchar2
9460   ,p_ass_attribute20              in     varchar2
9461   ,p_ass_attribute21              in     varchar2
9462   ,p_ass_attribute22              in     varchar2
9463   ,p_ass_attribute23              in     varchar2
9464   ,p_ass_attribute24              in     varchar2
9465   ,p_ass_attribute25              in     varchar2
9466   ,p_ass_attribute26              in     varchar2
9467   ,p_ass_attribute27              in     varchar2
9468   ,p_ass_attribute28              in     varchar2
9469   ,p_ass_attribute29              in     varchar2
9470   ,p_ass_attribute30              in     varchar2
9471   ,p_title                        in     varchar2
9472   ,p_segment1                     in     varchar2
9473   ,p_segment2                     in     varchar2
9474   ,p_segment3                     in     varchar2
9475   ,p_segment4                     in     varchar2
9476   ,p_segment5                     in     varchar2
9477   ,p_segment6                     in     varchar2
9478   ,p_segment7                     in     varchar2
9479   ,p_segment8                     in     varchar2
9480   ,p_segment9                     in     varchar2
9481   ,p_segment10                    in     varchar2
9482   ,p_segment11                    in     varchar2
9483   ,p_segment12                    in     varchar2
9484   ,p_segment13                    in     varchar2
9485   ,p_segment14                    in     varchar2
9486   ,p_segment15                    in     varchar2
9487   ,p_segment16                    in     varchar2
9488   ,p_segment17                    in     varchar2
9489   ,p_segment18                    in     varchar2
9490   ,p_segment19                    in     varchar2
9491   ,p_segment20                    in     varchar2
9492   ,p_segment21                    in     varchar2
9493   ,p_segment22                    in     varchar2
9494   ,p_segment23                    in     varchar2
9495   ,p_segment24                    in     varchar2
9496   ,p_segment25                    in     varchar2
9497   ,p_segment26                    in     varchar2
9498   ,p_segment27                    in     varchar2
9499   ,p_segment28                    in     varchar2
9500   ,p_segment29                    in     varchar2
9501   ,p_segment30                    in     varchar2
9502 -- Bug fix for 944911
9503 -- p_concatenated_segments has been changed from in out to out
9504 -- Added new param p_concat_segments as in param
9505   ,p_concat_segments              in     varchar2
9506   ,p_supervisor_assignment_id     in     number
9507   ,p_concatenated_segments           out nocopy varchar2
9508   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
9509   ,p_comment_id                      out nocopy number
9510   ,p_effective_start_date            out nocopy date
9511   ,p_effective_end_date              out nocopy date
9512   ,p_no_managers_warning             out nocopy boolean
9513   ,p_other_manager_warning           out nocopy boolean
9514   ) is
9515   --
9516   -- Declare cursors and local variables
9517   --
9518   -- Out variables
9519   --
9520   l_comment_id             per_all_assignments_f.comment_id%TYPE;
9521   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
9522   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
9523   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
9524   l_no_managers_warning    boolean;
9525   l_other_manager_warning  boolean;
9526   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
9527   := p_soft_coding_keyflex_id; -- bug 2359997
9528   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9529   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9530   l_effective_date         date;
9531   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
9532   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
9533   l_organization_id        per_all_assignments_f.organization_id%type;
9534   l_location_id            per_all_assignments_f.location_id%type;
9535   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE;
9536   l_cagr_concatenated_segments varchar2(2000);
9537   l_proc                       varchar2(72);
9538   --
9539   begin
9540   --
9541   l_object_version_number := p_object_version_number;
9542   --
9543  if g_debug then
9544  l_proc := g_package||'update_emp_asg';
9545   hr_utility.set_location('Entering:'|| l_proc, 5);
9546  end if;
9547   ---- Call the new code
9548  hr_assignment_api.update_emp_asg
9549   (p_validate                     => p_validate
9550   ,p_effective_date               => p_effective_date
9551   ,p_datetrack_update_mode        => p_datetrack_update_mode
9552   ,p_assignment_id                => p_assignment_id
9553   ,p_object_version_number        => l_object_version_number
9554   ,p_supervisor_id                => p_supervisor_id
9555   ,p_assignment_number            => p_assignment_number
9556   ,p_change_reason                => p_change_reason
9557   ,p_comments                     => p_comments
9558   ,p_date_probation_end           => p_date_probation_end
9559   ,p_default_code_comb_id         => p_default_code_comb_id
9560   ,p_frequency                    => p_frequency
9561   ,p_internal_address_line        => p_internal_address_line
9562   ,p_manager_flag                 => p_manager_flag
9563   ,p_normal_hours                 => p_normal_hours
9564   ,p_perf_review_period           => p_perf_review_period
9565   ,p_perf_review_period_frequency => p_perf_review_period_frequency
9566   ,p_probation_period             => p_probation_period
9567   ,p_probation_unit               => p_probation_unit
9568   ,p_sal_review_period            => p_sal_review_period
9569   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
9570   ,p_set_of_books_id              => p_set_of_books_id
9571   ,p_source_type                  => p_source_type
9572   ,p_time_normal_finish           => p_time_normal_finish
9573   ,p_time_normal_start            => p_time_normal_start
9574   ,p_bargaining_unit_code         => p_bargaining_unit_code
9575   ,p_labour_union_member_flag     => p_labour_union_member_flag
9576   ,p_hourly_salaried_code         => p_hourly_salaried_code
9577   ,p_ass_attribute_category       => p_ass_attribute_category
9578   ,p_ass_attribute1               => p_ass_attribute1
9579   ,p_ass_attribute2               => p_ass_attribute2
9580   ,p_ass_attribute3               => p_ass_attribute3
9581   ,p_ass_attribute4               => p_ass_attribute4
9582   ,p_ass_attribute5               => p_ass_attribute5
9583   ,p_ass_attribute6               => p_ass_attribute6
9584   ,p_ass_attribute7               => p_ass_attribute7
9585   ,p_ass_attribute8               => p_ass_attribute8
9586   ,p_ass_attribute9               => p_ass_attribute9
9587   ,p_ass_attribute10              => p_ass_attribute10
9588   ,p_ass_attribute11              => p_ass_attribute11
9589   ,p_ass_attribute12              => p_ass_attribute12
9590   ,p_ass_attribute13              => p_ass_attribute13
9591   ,p_ass_attribute14              => p_ass_attribute14
9592   ,p_ass_attribute15              => p_ass_attribute15
9593   ,p_ass_attribute16              => p_ass_attribute16
9594   ,p_ass_attribute17              => p_ass_attribute17
9595   ,p_ass_attribute18              => p_ass_attribute18
9596   ,p_ass_attribute19              => p_ass_attribute19
9597   ,p_ass_attribute20              => p_ass_attribute20
9598   ,p_ass_attribute21              => p_ass_attribute21
9599   ,p_ass_attribute22              => p_ass_attribute22
9600   ,p_ass_attribute23              => p_ass_attribute23
9601   ,p_ass_attribute24              => p_ass_attribute24
9602   ,p_ass_attribute25              => p_ass_attribute25
9603   ,p_ass_attribute26              => p_ass_attribute26
9604   ,p_ass_attribute27              => p_ass_attribute27
9605   ,p_ass_attribute28              => p_ass_attribute28
9606   ,p_ass_attribute29              => p_ass_attribute29
9607   ,p_ass_attribute30              => p_ass_attribute30
9608   ,p_title                        => p_title
9609   ,p_segment1                     => p_segment1
9610   ,p_segment2                     => p_segment2
9611   ,p_segment3                     => p_segment3
9612   ,p_segment4                     => p_segment4
9613   ,p_segment5                     => p_segment5
9614   ,p_segment6                     => p_segment6
9615   ,p_segment7                     => p_segment7
9616   ,p_segment8                     => p_segment8
9617   ,p_segment9                     => p_segment9
9618   ,p_segment10                    => p_segment10
9619   ,p_segment11                    => p_segment11
9620   ,p_segment12                    => p_segment12
9621   ,p_segment13                    => p_segment13
9622   ,p_segment14                    => p_segment14
9623   ,p_segment15                    => p_segment15
9624   ,p_segment16                    => p_segment16
9625   ,p_segment17                    => p_segment17
9626   ,p_segment18                    => p_segment18
9627   ,p_segment19                    => p_segment19
9628   ,p_segment20                    => p_segment20
9629   ,p_segment21                    => p_segment21
9630   ,p_segment22                    => p_segment22
9631   ,p_segment23                    => p_segment23
9632   ,p_segment24                    => p_segment24
9633   ,p_segment25                    => p_segment25
9634   ,p_segment26                    => p_segment26
9635   ,p_segment27                    => p_segment27
9636   ,p_segment28                    => p_segment28
9637   ,p_segment29                    => p_segment29
9638   ,p_segment30                    => p_segment30
9639   ,p_concat_segments              => p_concat_segments
9640   ,p_contract_id                  => hr_api.g_number
9641   ,p_establishment_id             => hr_api.g_number
9642   ,p_collective_agreement_id      => hr_api.g_number
9643   ,p_cagr_id_flex_num             => hr_api.g_number
9644   ,p_cag_segment1                 => hr_api.g_varchar2
9645   ,p_cag_segment2                 => hr_api.g_varchar2
9646   ,p_cag_segment3                 => hr_api.g_varchar2
9647   ,p_cag_segment4                 => hr_api.g_varchar2
9648   ,p_cag_segment5                 => hr_api.g_varchar2
9649   ,p_cag_segment6                 => hr_api.g_varchar2
9650   ,p_cag_segment7                 => hr_api.g_varchar2
9651   ,p_cag_segment8                 => hr_api.g_varchar2
9652   ,p_cag_segment9                 => hr_api.g_varchar2
9653   ,p_cag_segment10                => hr_api.g_varchar2
9654   ,p_cag_segment11                => hr_api.g_varchar2
9655   ,p_cag_segment12                => hr_api.g_varchar2
9656   ,p_cag_segment13                => hr_api.g_varchar2
9657   ,p_cag_segment14                => hr_api.g_varchar2
9658   ,p_cag_segment15                => hr_api.g_varchar2
9659   ,p_cag_segment16                => hr_api.g_varchar2
9660   ,p_cag_segment17                => hr_api.g_varchar2
9661   ,p_cag_segment18                => hr_api.g_varchar2
9662   ,p_cag_segment19                => hr_api.g_varchar2
9663   ,p_cag_segment20                => hr_api.g_varchar2
9664   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
9665   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
9666   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
9667   ,p_comment_id                   => l_comment_id
9668   ,p_effective_start_date         => l_effective_start_date
9669   ,p_effective_end_date           => l_effective_end_date
9670   ,p_concatenated_segments        => l_concatenated_segments
9671   ,p_no_managers_warning          => l_no_managers_warning
9672   ,p_other_manager_warning        => l_other_manager_warning
9673   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
9674 );
9675 
9676   -- Set all output arguments
9677   --
9678   p_object_version_number  := l_object_version_number;
9679   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
9680   p_comment_id             := l_comment_id;
9681   p_effective_start_date   := l_effective_start_date;
9682   p_effective_end_date     := l_effective_end_date;
9683   p_concatenated_segments  := l_concatenated_segments;
9684   p_no_managers_warning    := l_no_managers_warning;
9685   p_other_manager_warning  := l_other_manager_warning;
9686 
9687   --
9688  if g_debug then
9689   hr_utility.set_location(' Leaving:'||l_proc, 30);
9690  end if;
9691 end update_emp_asg;
9692 -- ----------------------------------------------------------------------------
9693 -- |--------------------------< update_emp_asg >--NEW--------------------------|
9694 -- ----------------------------------------------------------------------------
9695 --
9696 -- This is an overloaded procedure to include new parms
9697 -- for collective agreements and contracts
9698 -- added new parameters notice_period, units, employee_category,
9699 -- work_at_home and job_source on 05-OCT-01
9700 --
9701 procedure update_emp_asg
9702   (p_validate                     in     boolean
9703   ,p_effective_date               in     date
9704   ,p_datetrack_update_mode        in     varchar2
9705   ,p_assignment_id                in     number
9706   ,p_object_version_number        in out nocopy number
9707   ,p_supervisor_id                in     number
9708   ,p_assignment_number            in     varchar2
9709   ,p_change_reason                in     varchar2
9710   ,p_assignment_status_type_id    in     number
9711   ,p_comments                     in     varchar2
9712   ,p_date_probation_end           in     date
9713   ,p_default_code_comb_id         in     number
9714   ,p_frequency                    in     varchar2
9715   ,p_internal_address_line        in     varchar2
9716   ,p_manager_flag                 in     varchar2
9717   ,p_normal_hours                 in     number
9718   ,p_perf_review_period           in     number
9719   ,p_perf_review_period_frequency in     varchar2
9720   ,p_probation_period             in     number
9721   ,p_probation_unit               in     varchar2
9722   ,p_sal_review_period            in     number
9723   ,p_sal_review_period_frequency  in     varchar2
9724   ,p_set_of_books_id              in     number
9725   ,p_source_type                  in     varchar2
9726   ,p_time_normal_finish           in     varchar2
9727   ,p_time_normal_start            in     varchar2
9728   ,p_bargaining_unit_code         in     varchar2
9729   ,p_labour_union_member_flag     in     varchar2
9730   ,p_hourly_salaried_code         in     varchar2
9731   ,p_ass_attribute_category       in     varchar2
9732   ,p_ass_attribute1               in     varchar2
9733   ,p_ass_attribute2               in     varchar2
9734   ,p_ass_attribute3               in     varchar2
9735   ,p_ass_attribute4               in     varchar2
9736   ,p_ass_attribute5               in     varchar2
9737   ,p_ass_attribute6               in     varchar2
9738   ,p_ass_attribute7               in     varchar2
9739   ,p_ass_attribute8               in     varchar2
9740   ,p_ass_attribute9               in     varchar2
9741   ,p_ass_attribute10              in     varchar2
9742   ,p_ass_attribute11              in     varchar2
9743   ,p_ass_attribute12              in     varchar2
9744   ,p_ass_attribute13              in     varchar2
9745   ,p_ass_attribute14              in     varchar2
9746   ,p_ass_attribute15              in     varchar2
9747   ,p_ass_attribute16              in     varchar2
9748   ,p_ass_attribute17              in     varchar2
9749   ,p_ass_attribute18              in     varchar2
9750   ,p_ass_attribute19              in     varchar2
9751   ,p_ass_attribute20              in     varchar2
9752   ,p_ass_attribute21              in     varchar2
9753   ,p_ass_attribute22              in     varchar2
9754   ,p_ass_attribute23              in     varchar2
9755   ,p_ass_attribute24              in     varchar2
9756   ,p_ass_attribute25              in     varchar2
9757   ,p_ass_attribute26              in     varchar2
9758   ,p_ass_attribute27              in     varchar2
9759   ,p_ass_attribute28              in     varchar2
9760   ,p_ass_attribute29              in     varchar2
9761   ,p_ass_attribute30              in     varchar2
9762   ,p_title                        in     varchar2
9763   ,p_segment1                     in     varchar2
9764   ,p_segment2                     in     varchar2
9765   ,p_segment3                     in     varchar2
9766   ,p_segment4                     in     varchar2
9767   ,p_segment5                     in     varchar2
9768   ,p_segment6                     in     varchar2
9769   ,p_segment7                     in     varchar2
9770   ,p_segment8                     in     varchar2
9771   ,p_segment9                     in     varchar2
9772   ,p_segment10                    in     varchar2
9773   ,p_segment11                    in     varchar2
9774   ,p_segment12                    in     varchar2
9775   ,p_segment13                    in     varchar2
9776   ,p_segment14                    in     varchar2
9777   ,p_segment15                    in     varchar2
9778   ,p_segment16                    in     varchar2
9779   ,p_segment17                    in     varchar2
9780   ,p_segment18                    in     varchar2
9781   ,p_segment19                    in     varchar2
9782   ,p_segment20                    in     varchar2
9783   ,p_segment21                    in     varchar2
9784   ,p_segment22                    in     varchar2
9785   ,p_segment23                    in     varchar2
9786   ,p_segment24                    in     varchar2
9787   ,p_segment25                    in     varchar2
9788   ,p_segment26                    in     varchar2
9789   ,p_segment27                    in     varchar2
9790   ,p_segment28                    in     varchar2
9791   ,p_segment29                    in     varchar2
9792   ,p_segment30                    in     varchar2
9793 -- Bug fix for 944911
9794 -- p_concatenated_segments has been changed from in out to out
9795 -- Added new param p_concat_segments as in param
9796   ,p_concat_segments              in     varchar2
9797   ,p_contract_id                  in     number
9798   ,p_establishment_id             in     number
9799   ,p_collective_agreement_id      in     number
9800   ,p_cagr_id_flex_num             in     number
9801   ,p_cag_segment1                 in     varchar2
9802   ,p_cag_segment2                 in     varchar2
9803   ,p_cag_segment3                 in     varchar2
9804   ,p_cag_segment4                 in     varchar2
9805   ,p_cag_segment5                 in     varchar2
9806   ,p_cag_segment6                 in     varchar2
9807   ,p_cag_segment7                 in     varchar2
9808   ,p_cag_segment8                 in     varchar2
9809   ,p_cag_segment9                 in     varchar2
9810   ,p_cag_segment10                in     varchar2
9811   ,p_cag_segment11                in     varchar2
9812   ,p_cag_segment12                in     varchar2
9813   ,p_cag_segment13                in     varchar2
9814   ,p_cag_segment14                in     varchar2
9815   ,p_cag_segment15                in     varchar2
9816   ,p_cag_segment16                in     varchar2
9817   ,p_cag_segment17                in     varchar2
9818   ,p_cag_segment18                in     varchar2
9819   ,p_cag_segment19                in     varchar2
9820   ,p_cag_segment20                in     varchar2
9821   ,p_notice_period		  in     number
9822   ,p_notice_period_uom	      	  in     varchar2
9823   ,p_employee_category	          in     varchar2
9824   ,p_work_at_home		  in     varchar2
9825   ,p_job_post_source_name	  in     varchar2
9826   ,p_supervisor_assignment_id     in     number
9827   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
9828   ,p_cagr_concatenated_segments      out nocopy varchar2
9829   ,p_concatenated_segments           out nocopy varchar2
9830   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
9831   ,p_comment_id                      out nocopy number
9832   ,p_effective_start_date            out nocopy date
9833   ,p_effective_end_date              out nocopy date
9834   ,p_no_managers_warning             out nocopy boolean
9835   ,p_other_manager_warning           out nocopy boolean
9836   ) is
9837   --
9838   -- Declare cursors and local variables
9839   --
9840   -- Out variables
9841   --
9842   l_comment_id              per_all_assignments_f.comment_id%TYPE;
9843   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
9844   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
9845   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
9846   l_no_managers_warning     boolean;
9847   l_other_manager_warning   boolean;
9848   l_hourly_salaried_warning boolean;
9849   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
9850   := p_soft_coding_keyflex_id; -- bug 2359997
9851   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
9852   l_old_conc_segments       hr_soft_coding_keyflex.concatenated_segments%TYPE;
9853   l_effective_date          date;
9854   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
9855   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
9856   l_organization_id         per_all_assignments_f.organization_id%type;
9857   l_location_id             per_all_assignments_f.location_id%type;
9858   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
9859   := p_cagr_grade_def_id;   -- bug 2359997
9860   l_cagr_id_flex_num        per_cagr_grades_def.id_flex_num%TYPE;
9861   l_cagr_concatenated_segments varchar2(2000);
9862   l_proc                       varchar2(72);
9863 
9864   begin
9865   --
9866   l_object_version_number := p_object_version_number;
9867   --
9868  if g_debug then
9869   l_proc := g_package||'update_emp_asg';
9870   hr_utility.set_location('Entering:'|| l_proc, 5);
9871  end if;
9872   ---- Call the new code
9873   -- Added notice_period through to job_post_source_name in this call as they
9874   -- were missing
9875   -- see bug 2122535 for details
9876   --
9877  hr_assignment_api.update_emp_asg
9878   (p_validate                     => p_validate
9879   ,p_effective_date               => p_effective_date
9880   ,p_datetrack_update_mode        => p_datetrack_update_mode
9881   ,p_assignment_id                => p_assignment_id
9882   ,p_object_version_number        => l_object_version_number
9883   ,p_supervisor_id                => p_supervisor_id
9884   ,p_assignment_number            => p_assignment_number
9885   ,p_change_reason                => p_change_reason
9886   ,p_assignment_status_type_id    => p_assignment_status_type_id
9887   ,p_comments                     => p_comments
9888   ,p_date_probation_end           => p_date_probation_end
9889   ,p_default_code_comb_id         => p_default_code_comb_id
9890   ,p_frequency                    => p_frequency
9891   ,p_internal_address_line        => p_internal_address_line
9892   ,p_manager_flag                 => p_manager_flag
9893   ,p_normal_hours                 => p_normal_hours
9894   ,p_perf_review_period           => p_perf_review_period
9895   ,p_perf_review_period_frequency => p_perf_review_period_frequency
9896   ,p_probation_period             => p_probation_period
9897   ,p_probation_unit               => p_probation_unit
9898   ,p_sal_review_period            => p_sal_review_period
9899   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
9900   ,p_set_of_books_id              => p_set_of_books_id
9901   ,p_source_type                  => p_source_type
9902   ,p_time_normal_finish           => p_time_normal_finish
9903   ,p_time_normal_start            => p_time_normal_start
9904   ,p_bargaining_unit_code         => p_bargaining_unit_code
9905   ,p_labour_union_member_flag     => p_labour_union_member_flag
9906   ,p_hourly_salaried_code         => p_hourly_salaried_code
9907   ,p_ass_attribute_category       => p_ass_attribute_category
9908   ,p_ass_attribute1               => p_ass_attribute1
9909   ,p_ass_attribute2               => p_ass_attribute2
9910   ,p_ass_attribute3               => p_ass_attribute3
9911   ,p_ass_attribute4               => p_ass_attribute4
9912   ,p_ass_attribute5               => p_ass_attribute5
9913   ,p_ass_attribute6               => p_ass_attribute6
9914   ,p_ass_attribute7               => p_ass_attribute7
9915   ,p_ass_attribute8               => p_ass_attribute8
9916   ,p_ass_attribute9               => p_ass_attribute9
9917   ,p_ass_attribute10              => p_ass_attribute10
9918   ,p_ass_attribute11              => p_ass_attribute11
9919   ,p_ass_attribute12              => p_ass_attribute12
9920   ,p_ass_attribute13              => p_ass_attribute13
9921   ,p_ass_attribute14              => p_ass_attribute14
9922   ,p_ass_attribute15              => p_ass_attribute15
9923   ,p_ass_attribute16              => p_ass_attribute16
9924   ,p_ass_attribute17              => p_ass_attribute17
9925   ,p_ass_attribute18              => p_ass_attribute18
9926   ,p_ass_attribute19              => p_ass_attribute19
9927   ,p_ass_attribute20              => p_ass_attribute20
9928   ,p_ass_attribute21              => p_ass_attribute21
9929   ,p_ass_attribute22              => p_ass_attribute22
9930   ,p_ass_attribute23              => p_ass_attribute23
9931   ,p_ass_attribute24              => p_ass_attribute24
9932   ,p_ass_attribute25              => p_ass_attribute25
9933   ,p_ass_attribute26              => p_ass_attribute26
9934   ,p_ass_attribute27              => p_ass_attribute27
9935   ,p_ass_attribute28              => p_ass_attribute28
9936   ,p_ass_attribute29              => p_ass_attribute29
9937   ,p_ass_attribute30              => p_ass_attribute30
9938   ,p_title                        => p_title
9939   ,p_segment1                     => p_segment1
9940   ,p_segment2                     => p_segment2
9941   ,p_segment3                     => p_segment3
9942   ,p_segment4                     => p_segment4
9943   ,p_segment5                     => p_segment5
9944   ,p_segment6                     => p_segment6
9945   ,p_segment7                     => p_segment7
9946   ,p_segment8                     => p_segment8
9947   ,p_segment9                     => p_segment9
9948   ,p_segment10                    => p_segment10
9949   ,p_segment11                    => p_segment11
9950   ,p_segment12                    => p_segment12
9951   ,p_segment13                    => p_segment13
9952   ,p_segment14                    => p_segment14
9953   ,p_segment15                    => p_segment15
9954   ,p_segment16                    => p_segment16
9955   ,p_segment17                    => p_segment17
9956   ,p_segment18                    => p_segment18
9957   ,p_segment19                    => p_segment19
9958   ,p_segment20                    => p_segment20
9959   ,p_segment21                    => p_segment21
9960   ,p_segment22                    => p_segment22
9961   ,p_segment23                    => p_segment23
9962   ,p_segment24                    => p_segment24
9963   ,p_segment25                    => p_segment25
9964   ,p_segment26                    => p_segment26
9965   ,p_segment27                    => p_segment27
9966   ,p_segment28                    => p_segment28
9967   ,p_segment29                    => p_segment29
9968   ,p_segment30                    => p_segment30
9969   ,p_concat_segments              => p_concat_segments
9970   ,p_contract_id                  => p_contract_id
9971   ,p_establishment_id             => p_establishment_id
9972   ,p_collective_agreement_id      => p_collective_agreement_id
9973   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
9974   ,p_cag_segment1                 => p_cag_segment1
9975   ,p_cag_segment2                 => p_cag_segment2
9976   ,p_cag_segment3                 => p_cag_segment3
9977   ,p_cag_segment4                 => p_cag_segment4
9978   ,p_cag_segment5                 => p_cag_segment5
9979   ,p_cag_segment6                 => p_cag_segment6
9980   ,p_cag_segment7                 => p_cag_segment7
9981   ,p_cag_segment8                 => p_cag_segment8
9982   ,p_cag_segment9                 => p_cag_segment9
9983   ,p_cag_segment10                => p_cag_segment10
9984   ,p_cag_segment11                => p_cag_segment11
9985   ,p_cag_segment12                => p_cag_segment12
9986   ,p_cag_segment13                => p_cag_segment13
9987   ,p_cag_segment14                => p_cag_segment14
9988   ,p_cag_segment15                => p_cag_segment15
9989   ,p_cag_segment16                => p_cag_segment16
9990   ,p_cag_segment17                => p_cag_segment17
9991   ,p_cag_segment18                => p_cag_segment18
9992   ,p_cag_segment19                => p_cag_segment19
9993   ,p_cag_segment20                => p_cag_segment20
9994   ,p_notice_period                => p_notice_period
9995   ,p_notice_period_uom            => p_notice_period_uom
9996   ,p_employee_category            => p_employee_category
9997   ,p_work_at_home                 => p_work_at_home
9998   ,p_job_post_source_name	  => p_job_post_source_name
9999   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
10000   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
10001   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
10002   ,p_comment_id                   => l_comment_id
10003   ,p_effective_start_date         => l_effective_start_date
10004   ,p_effective_end_date           => l_effective_end_date
10005   ,p_concatenated_segments        => l_concatenated_segments
10006   ,p_no_managers_warning          => l_no_managers_warning
10007   ,p_other_manager_warning        => l_other_manager_warning
10008   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
10009   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
10010 );
10011   --
10012   -- Set all output arguments
10013   --
10014   p_object_version_number  := l_object_version_number;
10015   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
10016   p_comment_id             := l_comment_id;
10017   p_effective_start_date   := l_effective_start_date;
10018   p_effective_end_date     := l_effective_end_date;
10019   p_concatenated_segments  := l_concatenated_segments;
10020   p_no_managers_warning    := l_no_managers_warning;
10021   p_other_manager_warning  := l_other_manager_warning;
10022   --
10023  if g_debug then
10024   hr_utility.set_location(' Leaving:'||l_proc, 30);
10025  end if;
10026 end update_emp_asg;
10027 -- ----------------------------------------------------------------------------
10028 -- |-------------------------< update_emp_asg >--NEW2-------------------------|
10029 -- ----------------------------------------------------------------------------
10030 --
10031 -- This is an overloaded procedure to include new parms
10032 -- for collective agreements and contracts
10033 -- added new parameters notice_period, units, employee_category,
10034 -- work_at_home and job_source on 05-OCT-01
10035 --
10036 procedure update_emp_asg
10037   (p_validate                     in     boolean
10038   ,p_effective_date               in     date
10039   ,p_datetrack_update_mode        in     varchar2
10040   ,p_assignment_id                in     number
10041   ,p_object_version_number        in out nocopy number
10042   ,p_supervisor_id                in     number
10043   ,p_assignment_number            in     varchar2
10044   ,p_change_reason                in     varchar2
10045   ,p_assignment_status_type_id    in     number
10046   ,p_comments                     in     varchar2
10047   ,p_date_probation_end           in     date
10048   ,p_default_code_comb_id         in     number
10049   ,p_frequency                    in     varchar2
10050   ,p_internal_address_line        in     varchar2
10051   ,p_manager_flag                 in     varchar2
10052   ,p_normal_hours                 in     number
10053   ,p_perf_review_period           in     number
10054   ,p_perf_review_period_frequency in     varchar2
10055   ,p_probation_period             in     number
10056   ,p_probation_unit               in     varchar2
10057   ,p_sal_review_period            in     number
10058   ,p_sal_review_period_frequency  in     varchar2
10059   ,p_set_of_books_id              in     number
10060   ,p_source_type                  in     varchar2
10061   ,p_time_normal_finish           in     varchar2
10062   ,p_time_normal_start            in     varchar2
10063   ,p_bargaining_unit_code         in     varchar2
10064   ,p_labour_union_member_flag     in     varchar2
10065   ,p_hourly_salaried_code         in     varchar2
10066   ,p_ass_attribute_category       in     varchar2
10067   ,p_ass_attribute1               in     varchar2
10068   ,p_ass_attribute2               in     varchar2
10069   ,p_ass_attribute3               in     varchar2
10070   ,p_ass_attribute4               in     varchar2
10071   ,p_ass_attribute5               in     varchar2
10072   ,p_ass_attribute6               in     varchar2
10073   ,p_ass_attribute7               in     varchar2
10074   ,p_ass_attribute8               in     varchar2
10075   ,p_ass_attribute9               in     varchar2
10076   ,p_ass_attribute10              in     varchar2
10077   ,p_ass_attribute11              in     varchar2
10078   ,p_ass_attribute12              in     varchar2
10079   ,p_ass_attribute13              in     varchar2
10080   ,p_ass_attribute14              in     varchar2
10081   ,p_ass_attribute15              in     varchar2
10082   ,p_ass_attribute16              in     varchar2
10083   ,p_ass_attribute17              in     varchar2
10084   ,p_ass_attribute18              in     varchar2
10085   ,p_ass_attribute19              in     varchar2
10086   ,p_ass_attribute20              in     varchar2
10087   ,p_ass_attribute21              in     varchar2
10088   ,p_ass_attribute22              in     varchar2
10089   ,p_ass_attribute23              in     varchar2
10090   ,p_ass_attribute24              in     varchar2
10091   ,p_ass_attribute25              in     varchar2
10092   ,p_ass_attribute26              in     varchar2
10093   ,p_ass_attribute27              in     varchar2
10094   ,p_ass_attribute28              in     varchar2
10095   ,p_ass_attribute29              in     varchar2
10096   ,p_ass_attribute30              in     varchar2
10097   ,p_title                        in     varchar2
10098   ,p_segment1                     in     varchar2
10099   ,p_segment2                     in     varchar2
10100   ,p_segment3                     in     varchar2
10101   ,p_segment4                     in     varchar2
10102   ,p_segment5                     in     varchar2
10103   ,p_segment6                     in     varchar2
10104   ,p_segment7                     in     varchar2
10105   ,p_segment8                     in     varchar2
10106   ,p_segment9                     in     varchar2
10107   ,p_segment10                    in     varchar2
10108   ,p_segment11                    in     varchar2
10109   ,p_segment12                    in     varchar2
10110   ,p_segment13                    in     varchar2
10111   ,p_segment14                    in     varchar2
10112   ,p_segment15                    in     varchar2
10113   ,p_segment16                    in     varchar2
10114   ,p_segment17                    in     varchar2
10115   ,p_segment18                    in     varchar2
10116   ,p_segment19                    in     varchar2
10117   ,p_segment20                    in     varchar2
10118   ,p_segment21                    in     varchar2
10119   ,p_segment22                    in     varchar2
10120   ,p_segment23                    in     varchar2
10121   ,p_segment24                    in     varchar2
10122   ,p_segment25                    in     varchar2
10123   ,p_segment26                    in     varchar2
10124   ,p_segment27                    in     varchar2
10125   ,p_segment28                    in     varchar2
10126   ,p_segment29                    in     varchar2
10127   ,p_segment30                    in     varchar2
10128 -- Bug fix for 944911
10129 -- p_concatenated_segments has been changed from in out to out
10130 -- Added new param p_concat_segments as in param
10131   ,p_concat_segments              in     varchar2
10132   ,p_contract_id                  in     number
10133   ,p_establishment_id             in     number
10134   ,p_collective_agreement_id      in     number
10135   ,p_cagr_id_flex_num             in     number
10136   ,p_cag_segment1                 in     varchar2
10137   ,p_cag_segment2                 in     varchar2
10138   ,p_cag_segment3                 in     varchar2
10139   ,p_cag_segment4                 in     varchar2
10140   ,p_cag_segment5                 in     varchar2
10141   ,p_cag_segment6                 in     varchar2
10142   ,p_cag_segment7                 in     varchar2
10143   ,p_cag_segment8                 in     varchar2
10144   ,p_cag_segment9                 in     varchar2
10145   ,p_cag_segment10                in     varchar2
10146   ,p_cag_segment11                in     varchar2
10147   ,p_cag_segment12                in     varchar2
10148   ,p_cag_segment13                in     varchar2
10149   ,p_cag_segment14                in     varchar2
10150   ,p_cag_segment15                in     varchar2
10151   ,p_cag_segment16                in     varchar2
10152   ,p_cag_segment17                in     varchar2
10153   ,p_cag_segment18                in     varchar2
10154   ,p_cag_segment19                in     varchar2
10155   ,p_cag_segment20                in     varchar2
10156   ,p_notice_period		  in     number
10157   ,p_notice_period_uom	      	  in     varchar2
10158   ,p_employee_category	          in     varchar2
10159   ,p_work_at_home		  in     varchar2
10160   ,p_job_post_source_name	  in     varchar2
10161   ,p_supervisor_assignment_id     in     number
10162   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
10163   ,p_cagr_concatenated_segments      out nocopy varchar2
10164   ,p_concatenated_segments           out nocopy varchar2
10165   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
10166   ,p_comment_id                      out nocopy number
10167   ,p_effective_start_date            out nocopy date
10168   ,p_effective_end_date              out nocopy date
10169   ,p_no_managers_warning             out nocopy boolean
10170   ,p_other_manager_warning           out nocopy boolean
10171   ,p_hourly_salaried_warning         out nocopy boolean
10172   ) is
10173   --
10174   -- Declare cursors and local variables
10175   --
10176   -- Out variables
10177   --
10178   l_comment_id             per_all_assignments_f.comment_id%TYPE;
10179   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
10180   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
10181   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
10182   l_no_managers_warning    boolean;
10183   l_other_manager_warning  boolean;
10184   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
10185   := p_soft_coding_keyflex_id;  -- bug 2359997
10186   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
10187   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
10188   l_effective_date         date;
10189   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
10190   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
10191   l_organization_id        per_all_assignments_f.organization_id%type;
10192   l_location_id            per_all_assignments_f.location_id%type;
10193   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
10194   := p_cagr_grade_def_id;  -- bug 2359997
10195   l_cagr_id_flex_num       per_cagr_grades_def.id_flex_num%TYPE;
10196   l_cagr_concatenated_segments varchar2(2000);
10197   l_hourly_salaried_warning boolean;
10198   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
10199   --
10200   -- Internal working variables
10201   --
10202   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
10203   l_business_group_id          per_business_groups.business_group_id%TYPE;
10204   l_payroll_id_updated         boolean;
10205   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
10206   l_org_now_no_manager_warning boolean;
10207   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
10208   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
10209   l_proc                       varchar2(72) := g_package||'update_emp_asg';
10210   l_session_id                 number;
10211   l_unused_start_date          date;
10212   l_unused_end_date            date;
10213   l_old_asg_status per_assignment_status_types.per_system_status%type;
10214   l_new_asg_status per_assignment_status_types.per_system_status%type;
10215 
10216 begin
10217  --
10218   l_object_version_number := p_object_version_number;
10219 
10220  if g_debug then
10221   hr_utility.set_location(' Entering:'||l_proc, 10);
10222  end if;
10223   --
10224   -- Call the new code
10225   -- Added p_gsp_post_process_warning
10226   --
10227   hr_assignment_api.update_emp_asg
10228   (p_validate                     => p_validate
10229   ,p_effective_date               => p_effective_date
10230   ,p_datetrack_update_mode        => p_datetrack_update_mode
10231   ,p_assignment_id                => p_assignment_id
10232   ,p_object_version_number        => l_object_version_number
10233   ,p_supervisor_id                => p_supervisor_id
10234   ,p_assignment_number            => p_assignment_number
10235   ,p_change_reason                => p_change_reason
10236   ,p_assignment_status_type_id    => p_assignment_status_type_id
10237   ,p_comments                     => p_comments
10238   ,p_date_probation_end           => p_date_probation_end
10239   ,p_default_code_comb_id         => p_default_code_comb_id
10240   ,p_frequency                    => p_frequency
10241   ,p_internal_address_line        => p_internal_address_line
10242   ,p_manager_flag                 => p_manager_flag
10243   ,p_normal_hours                 => p_normal_hours
10244   ,p_perf_review_period           => p_perf_review_period
10245   ,p_perf_review_period_frequency => p_perf_review_period_frequency
10246   ,p_probation_period             => p_probation_period
10247   ,p_probation_unit               => p_probation_unit
10248   ,p_sal_review_period            => p_sal_review_period
10249   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
10250   ,p_set_of_books_id              => p_set_of_books_id
10251   ,p_source_type                  => p_source_type
10252   ,p_time_normal_finish           => p_time_normal_finish
10253   ,p_time_normal_start            => p_time_normal_start
10254   ,p_bargaining_unit_code         => p_bargaining_unit_code
10255   ,p_labour_union_member_flag     => p_labour_union_member_flag
10256   ,p_hourly_salaried_code         => p_hourly_salaried_code
10257   ,p_ass_attribute_category       => p_ass_attribute_category
10258   ,p_ass_attribute1               => p_ass_attribute1
10259   ,p_ass_attribute2               => p_ass_attribute2
10260   ,p_ass_attribute3               => p_ass_attribute3
10261   ,p_ass_attribute4               => p_ass_attribute4
10262   ,p_ass_attribute5               => p_ass_attribute5
10263   ,p_ass_attribute6               => p_ass_attribute6
10264   ,p_ass_attribute7               => p_ass_attribute7
10265   ,p_ass_attribute8               => p_ass_attribute8
10266   ,p_ass_attribute9               => p_ass_attribute9
10267   ,p_ass_attribute10              => p_ass_attribute10
10268   ,p_ass_attribute11              => p_ass_attribute11
10269   ,p_ass_attribute12              => p_ass_attribute12
10270   ,p_ass_attribute13              => p_ass_attribute13
10271   ,p_ass_attribute14              => p_ass_attribute14
10272   ,p_ass_attribute15              => p_ass_attribute15
10273   ,p_ass_attribute16              => p_ass_attribute16
10274   ,p_ass_attribute17              => p_ass_attribute17
10275   ,p_ass_attribute18              => p_ass_attribute18
10276   ,p_ass_attribute19              => p_ass_attribute19
10277   ,p_ass_attribute20              => p_ass_attribute20
10278   ,p_ass_attribute21              => p_ass_attribute21
10279   ,p_ass_attribute22              => p_ass_attribute22
10280   ,p_ass_attribute23              => p_ass_attribute23
10281   ,p_ass_attribute24              => p_ass_attribute24
10282   ,p_ass_attribute25              => p_ass_attribute25
10283   ,p_ass_attribute26              => p_ass_attribute26
10284   ,p_ass_attribute27              => p_ass_attribute27
10285   ,p_ass_attribute28              => p_ass_attribute28
10286   ,p_ass_attribute29              => p_ass_attribute29
10287   ,p_ass_attribute30              => p_ass_attribute30
10288   ,p_title                        => p_title
10289   ,p_segment1                     => p_segment1
10290   ,p_segment2                     => p_segment2
10291   ,p_segment3                     => p_segment3
10292   ,p_segment4                     => p_segment4
10293   ,p_segment5                     => p_segment5
10294   ,p_segment6                     => p_segment6
10295   ,p_segment7                     => p_segment7
10296   ,p_segment8                     => p_segment8
10297   ,p_segment9                     => p_segment9
10298   ,p_segment10                    => p_segment10
10299   ,p_segment11                    => p_segment11
10300   ,p_segment12                    => p_segment12
10301   ,p_segment13                    => p_segment13
10302   ,p_segment14                    => p_segment14
10303   ,p_segment15                    => p_segment15
10304   ,p_segment16                    => p_segment16
10305   ,p_segment17                    => p_segment17
10306   ,p_segment18                    => p_segment18
10307   ,p_segment19                    => p_segment19
10308   ,p_segment20                    => p_segment20
10309   ,p_segment21                    => p_segment21
10310   ,p_segment22                    => p_segment22
10311   ,p_segment23                    => p_segment23
10312   ,p_segment24                    => p_segment24
10313   ,p_segment25                    => p_segment25
10314   ,p_segment26                    => p_segment26
10315   ,p_segment27                    => p_segment27
10316   ,p_segment28                    => p_segment28
10317   ,p_segment29                    => p_segment29
10318   ,p_segment30                    => p_segment30
10319   ,p_concat_segments              => p_concat_segments
10320   ,p_contract_id                  => p_contract_id
10321   ,p_establishment_id             => p_establishment_id
10322   ,p_collective_agreement_id      => p_collective_agreement_id
10323   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
10324   ,p_cag_segment1                 => p_cag_segment1
10325   ,p_cag_segment2                 => p_cag_segment2
10326   ,p_cag_segment3                 => p_cag_segment3
10327   ,p_cag_segment4                 => p_cag_segment4
10328   ,p_cag_segment5                 => p_cag_segment5
10329   ,p_cag_segment6                 => p_cag_segment6
10330   ,p_cag_segment7                 => p_cag_segment7
10331   ,p_cag_segment8                 => p_cag_segment8
10332   ,p_cag_segment9                 => p_cag_segment9
10333   ,p_cag_segment10                => p_cag_segment10
10334   ,p_cag_segment11                => p_cag_segment11
10335   ,p_cag_segment12                => p_cag_segment12
10336   ,p_cag_segment13                => p_cag_segment13
10337   ,p_cag_segment14                => p_cag_segment14
10338   ,p_cag_segment15                => p_cag_segment15
10339   ,p_cag_segment16                => p_cag_segment16
10340   ,p_cag_segment17                => p_cag_segment17
10341   ,p_cag_segment18                => p_cag_segment18
10342   ,p_cag_segment19                => p_cag_segment19
10343   ,p_cag_segment20                => p_cag_segment20
10344   ,p_notice_period                => p_notice_period
10345   ,p_notice_period_uom            => p_notice_period_uom
10346   ,p_employee_category            => p_employee_category
10347   ,p_work_at_home                 => p_work_at_home
10348   ,p_job_post_source_name	  => p_job_post_source_name
10349   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
10350   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
10351   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
10352   ,p_comment_id                   => l_comment_id
10353   ,p_effective_start_date         => l_effective_start_date
10354   ,p_effective_end_date           => l_effective_end_date
10355   ,p_concatenated_segments        => l_concatenated_segments
10356   ,p_no_managers_warning          => l_no_managers_warning
10357   ,p_other_manager_warning        => l_other_manager_warning
10358   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
10359   ,p_gsp_post_process_warning     => l_gsp_post_process_warning
10360   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
10361 ); -- bug 2999562
10362 
10363   --
10364   -- Set all output arguments
10365   --
10366   p_object_version_number  := l_object_version_number;
10367   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
10368   p_comment_id             := l_comment_id;
10369   p_effective_start_date   := l_effective_start_date;
10370   p_effective_end_date     := l_effective_end_date;
10371   p_concatenated_segments  := l_concatenated_segments;
10372   p_no_managers_warning    := l_no_managers_warning;
10373   p_other_manager_warning  := l_other_manager_warning;
10374   p_cagr_grade_def_id          := l_cagr_grade_def_id;
10375   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
10376   p_hourly_salaried_warning    := l_hourly_salaried_warning;
10377   --
10378   --
10379  if g_debug then
10380   hr_utility.set_location(' Leaving:'||l_proc, 30);
10381  end if;
10382 end update_emp_asg;
10383 -- ----------------------------------------------------------------------------
10384 -- |-------------------------< update_emp_asg >--NEW3-------------------------|
10385 -- ----------------------------------------------------------------------------
10386 --
10387 -- This is an overloaded procedure to include p_gsp_post_process_warning
10388 -- OUT parameter.
10389 --
10390 procedure update_emp_asg
10391   (p_validate                     in     boolean
10392   ,p_effective_date               in     date
10393   ,p_datetrack_update_mode        in     varchar2
10394   ,p_assignment_id                in     number
10395   ,p_object_version_number        in out nocopy number
10396   ,p_supervisor_id                in     number
10397   ,p_assignment_number            in     varchar2
10398   ,p_change_reason                in     varchar2
10399   ,p_assignment_status_type_id    in     number
10400   ,p_comments                     in     varchar2
10401   ,p_date_probation_end           in     date
10402   ,p_default_code_comb_id         in     number
10403   ,p_frequency                    in     varchar2
10404   ,p_internal_address_line        in     varchar2
10405   ,p_manager_flag                 in     varchar2
10406   ,p_normal_hours                 in     number
10407   ,p_perf_review_period           in     number
10408   ,p_perf_review_period_frequency in     varchar2
10409   ,p_probation_period             in     number
10410   ,p_probation_unit               in     varchar2
10411   ,p_projected_assignment_end     in     varchar2
10412   ,p_sal_review_period            in     number
10413   ,p_sal_review_period_frequency  in     varchar2
10414   ,p_set_of_books_id              in     number
10415   ,p_source_type                  in     varchar2
10416   ,p_time_normal_finish           in     varchar2
10417   ,p_time_normal_start            in     varchar2
10418   ,p_bargaining_unit_code         in     varchar2
10419   ,p_labour_union_member_flag     in     varchar2
10420   ,p_hourly_salaried_code         in     varchar2
10421   ,p_ass_attribute_category       in     varchar2
10422   ,p_ass_attribute1               in     varchar2
10423   ,p_ass_attribute2               in     varchar2
10424   ,p_ass_attribute3               in     varchar2
10425   ,p_ass_attribute4               in     varchar2
10426   ,p_ass_attribute5               in     varchar2
10427   ,p_ass_attribute6               in     varchar2
10428   ,p_ass_attribute7               in     varchar2
10429   ,p_ass_attribute8               in     varchar2
10430   ,p_ass_attribute9               in     varchar2
10431   ,p_ass_attribute10              in     varchar2
10432   ,p_ass_attribute11              in     varchar2
10433   ,p_ass_attribute12              in     varchar2
10434   ,p_ass_attribute13              in     varchar2
10435   ,p_ass_attribute14              in     varchar2
10436   ,p_ass_attribute15              in     varchar2
10437   ,p_ass_attribute16              in     varchar2
10438   ,p_ass_attribute17              in     varchar2
10439   ,p_ass_attribute18              in     varchar2
10440   ,p_ass_attribute19              in     varchar2
10441   ,p_ass_attribute20              in     varchar2
10442   ,p_ass_attribute21              in     varchar2
10443   ,p_ass_attribute22              in     varchar2
10444   ,p_ass_attribute23              in     varchar2
10445   ,p_ass_attribute24              in     varchar2
10446   ,p_ass_attribute25              in     varchar2
10447   ,p_ass_attribute26              in     varchar2
10448   ,p_ass_attribute27              in     varchar2
10449   ,p_ass_attribute28              in     varchar2
10450   ,p_ass_attribute29              in     varchar2
10451   ,p_ass_attribute30              in     varchar2
10452   ,p_title                        in     varchar2
10453   ,p_segment1                     in     varchar2
10454   ,p_segment2                     in     varchar2
10455   ,p_segment3                     in     varchar2
10456   ,p_segment4                     in     varchar2
10457   ,p_segment5                     in     varchar2
10458   ,p_segment6                     in     varchar2
10459   ,p_segment7                     in     varchar2
10460   ,p_segment8                     in     varchar2
10461   ,p_segment9                     in     varchar2
10462   ,p_segment10                    in     varchar2
10463   ,p_segment11                    in     varchar2
10464   ,p_segment12                    in     varchar2
10465   ,p_segment13                    in     varchar2
10466   ,p_segment14                    in     varchar2
10467   ,p_segment15                    in     varchar2
10468   ,p_segment16                    in     varchar2
10469   ,p_segment17                    in     varchar2
10470   ,p_segment18                    in     varchar2
10471   ,p_segment19                    in     varchar2
10472   ,p_segment20                    in     varchar2
10473   ,p_segment21                    in     varchar2
10474   ,p_segment22                    in     varchar2
10475   ,p_segment23                    in     varchar2
10476   ,p_segment24                    in     varchar2
10477   ,p_segment25                    in     varchar2
10478   ,p_segment26                    in     varchar2
10479   ,p_segment27                    in     varchar2
10480   ,p_segment28                    in     varchar2
10481   ,p_segment29                    in     varchar2
10482   ,p_segment30                    in     varchar2
10483 -- Bug fix for 944911
10484 -- p_concatenated_segments has been changed from in out to out
10485 -- Added new param p_concat_segments as in param
10486   ,p_concat_segments              in     varchar2
10487   ,p_contract_id                  in     number
10488   ,p_establishment_id             in     number
10489   ,p_collective_agreement_id      in     number
10490   ,p_cagr_id_flex_num             in     number
10491   ,p_cag_segment1                 in     varchar2
10492   ,p_cag_segment2                 in     varchar2
10493   ,p_cag_segment3                 in     varchar2
10494   ,p_cag_segment4                 in     varchar2
10495   ,p_cag_segment5                 in     varchar2
10496   ,p_cag_segment6                 in     varchar2
10497   ,p_cag_segment7                 in     varchar2
10498   ,p_cag_segment8                 in     varchar2
10499   ,p_cag_segment9                 in     varchar2
10500   ,p_cag_segment10                in     varchar2
10501   ,p_cag_segment11                in     varchar2
10502   ,p_cag_segment12                in     varchar2
10503   ,p_cag_segment13                in     varchar2
10504   ,p_cag_segment14                in     varchar2
10505   ,p_cag_segment15                in     varchar2
10506   ,p_cag_segment16                in     varchar2
10507   ,p_cag_segment17                in     varchar2
10508   ,p_cag_segment18                in     varchar2
10509   ,p_cag_segment19                in     varchar2
10510   ,p_cag_segment20                in     varchar2
10511   ,p_notice_period		  in     number
10512   ,p_notice_period_uom	      	  in     varchar2
10513   ,p_employee_category	          in     varchar2
10514   ,p_work_at_home		  in     varchar2
10515   ,p_job_post_source_name	  in     varchar2
10516   ,p_supervisor_assignment_id     in     number
10517   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
10518   ,p_cagr_concatenated_segments      out nocopy varchar2
10519   ,p_concatenated_segments           out nocopy varchar2
10520   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
10521   ,p_comment_id                      out nocopy number
10522   ,p_effective_start_date            out nocopy date
10523   ,p_effective_end_date              out nocopy date
10524   ,p_no_managers_warning             out nocopy boolean
10525   ,p_other_manager_warning           out nocopy boolean
10526   ,p_hourly_salaried_warning         out nocopy boolean
10527   ,p_gsp_post_process_warning        out nocopy varchar2
10528   ) is
10529   --
10530   -- Declare cursors and local variables
10531   --
10532   -- Out variables
10533   --
10534   l_comment_id             per_all_assignments_f.comment_id%TYPE;
10535   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
10536   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
10537   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
10538   l_no_managers_warning    boolean;
10539   l_other_manager_warning  boolean;
10540   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
10541   := p_soft_coding_keyflex_id;  -- bug 2359997
10542   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
10543   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
10544   l_effective_date         date;
10545   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
10546   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
10547   l_organization_id        per_all_assignments_f.organization_id%type;
10548   l_location_id            per_all_assignments_f.location_id%type;
10549   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
10550   := p_cagr_grade_def_id;  -- bug 2359997
10551   l_cagr_id_flex_num       per_cagr_grades_def.id_flex_num%TYPE;
10552   l_cagr_concatenated_segments varchar2(2000);
10553   l_hourly_salaried_warning boolean;
10554   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
10555   --
10556   -- Internal working variables
10557   --
10558   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
10559   l_business_group_id          per_business_groups.business_group_id%TYPE;
10560   l_payroll_id_updated         boolean;
10561   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
10562   l_org_now_no_manager_warning boolean;
10563   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
10564   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
10565   l_proc                       varchar2(72) := g_package||'update_emp_asg';
10566   l_session_id                 number;
10567   l_unused_start_date          date;
10568   l_unused_end_date            date;
10569   l_old_asg_status per_assignment_status_types.per_system_status%type;
10570   l_new_asg_status per_assignment_status_types.per_system_status%type;
10571   --
10572   -- bug 2359997 new variables to indicate whether key flex id parameters
10573   -- enter the program with a value.
10574   --
10575   --l_scl_null_ind               number(1) := 0;
10576   l_cag_null_ind               number(1) := 0;
10577   --
10578   -- bug 2359997 new variables for derived values where key flex id is known.
10579   --
10580   l_scl_segment1               varchar2(60) := p_segment1;
10581   l_scl_segment2               varchar2(60) := p_segment2;
10582   l_scl_segment3               varchar2(60) := p_segment3;
10583   l_scl_segment4               varchar2(60) := p_segment4;
10584   l_scl_segment5               varchar2(60) := p_segment5;
10585   l_scl_segment6               varchar2(60) := p_segment6;
10586   l_scl_segment7               varchar2(60) := p_segment7;
10587   l_scl_segment8               varchar2(60) := p_segment8;
10588   l_scl_segment9               varchar2(60) := p_segment9;
10589   l_scl_segment10              varchar2(60) := p_segment10;
10590   l_scl_segment11              varchar2(60) := p_segment11;
10591   l_scl_segment12              varchar2(60) := p_segment12;
10592   l_scl_segment13              varchar2(60) := p_segment13;
10593   l_scl_segment14              varchar2(60) := p_segment14;
10594   l_scl_segment15              varchar2(60) := p_segment15;
10595   l_scl_segment16              varchar2(60) := p_segment16;
10596   l_scl_segment17              varchar2(60) := p_segment17;
10597   l_scl_segment18              varchar2(60) := p_segment18;
10598   l_scl_segment19              varchar2(60) := p_segment19;
10599   l_scl_segment20              varchar2(60) := p_segment20;
10600   l_scl_segment21              varchar2(60) := p_segment21;
10601   l_scl_segment22              varchar2(60) := p_segment22;
10602   l_scl_segment23              varchar2(60) := p_segment23;
10603   l_scl_segment24              varchar2(60) := p_segment24;
10604   l_scl_segment25              varchar2(60) := p_segment25;
10605   l_scl_segment26              varchar2(60) := p_segment26;
10606   l_scl_segment27              varchar2(60) := p_segment27;
10607   l_scl_segment28              varchar2(60) := p_segment28;
10608   l_scl_segment29              varchar2(60) := p_segment29;
10609   l_scl_segment30              varchar2(60) := p_segment30;
10610   --
10611   l_cag_segment1               varchar2(60) := p_cag_segment1;
10612   l_cag_segment2               varchar2(60) := p_cag_segment2;
10613   l_cag_segment3               varchar2(60) := p_cag_segment3;
10614   l_cag_segment4               varchar2(60) := p_cag_segment4;
10615   l_cag_segment5               varchar2(60) := p_cag_segment5;
10616   l_cag_segment6               varchar2(60) := p_cag_segment6;
10617   l_cag_segment7               varchar2(60) := p_cag_segment7;
10618   l_cag_segment8               varchar2(60) := p_cag_segment8;
10619   l_cag_segment9               varchar2(60) := p_cag_segment9;
10620   l_cag_segment10              varchar2(60) := p_cag_segment10;
10621   l_cag_segment11              varchar2(60) := p_cag_segment11;
10622   l_cag_segment12              varchar2(60) := p_cag_segment12;
10623   l_cag_segment13              varchar2(60) := p_cag_segment13;
10624   l_cag_segment14              varchar2(60) := p_cag_segment14;
10625   l_cag_segment15              varchar2(60) := p_cag_segment15;
10626   l_cag_segment16              varchar2(60) := p_cag_segment16;
10627   l_cag_segment17              varchar2(60) := p_cag_segment17;
10628   l_cag_segment18              varchar2(60) := p_cag_segment18;
10629   l_cag_segment19              varchar2(60) := p_cag_segment19;
10630   l_cag_segment20              varchar2(60) := p_cag_segment20;
10631   --
10632   lv_object_version_number     number := p_object_version_number ;
10633   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
10634   lv_soft_coding_keyflex_id    number := p_soft_coding_keyflex_id ;
10635   --
10636   l_projected_assignment_end date;--fix for bug 6595592.
10637   cursor csr_old_asg_status is
10638   select ast.per_system_status
10639   from per_assignment_status_types ast,
10640        per_all_assignments_f asg
10641   where ast.assignment_status_type_id = asg.assignment_status_type_id
10642   and   asg.assignment_id = p_assignment_id
10643   and   l_effective_date between asg.effective_start_date
10644         and asg.effective_end_date;
10645   --
10646   cursor csr_new_asg_status is
10647   select ast.per_system_status
10648   from per_assignment_status_types ast
10649   where ast.assignment_status_type_id = p_assignment_status_type_id;
10650   --
10651   cursor csr_get_assignment_type is
10652     select asg.assignment_type
10653          , asg.business_group_id
10654          -- , asg.soft_coding_keyflex_id -- bug 2359997
10655          , asg.organization_id
10656          , asg.location_id
10657       from per_all_assignments_f asg
10658      where asg.assignment_id = p_assignment_id
10659        and l_effective_date  between asg.effective_start_date
10660                              and     asg.effective_end_date;
10661   --
10662 /* Added By Fs
10663   cursor csr_get_soft_coding_keyflex is  -- bug 2359997
10664     select asg.soft_coding_keyflex_id
10665       from per_all_assignments_f asg
10666      where asg.assignment_id = p_assignment_id
10667        and l_effective_date  between asg.effective_start_date
10668                              and     asg.effective_end_date;
10669   --
10670   cursor csr_scl_idsel is
10671     select plr.rule_mode                       id_flex_num
10672     from   pay_legislation_rules               plr,
10673            per_business_groups_perf            pgr
10674     where  plr.legislation_code                = pgr.legislation_code
10675     and    pgr.business_group_id               = l_business_group_id
10676     and    plr.rule_type                       = 'S'
10677     and    exists
10678           (select 1
10679            from   fnd_segment_attribute_values fsav
10680            where  fsav.id_flex_num             = plr.rule_mode
10681            and    fsav.application_id          = 800
10682            and    fsav.id_flex_code            = 'SCL'
10683            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
10684            and    fsav.attribute_value         = 'Y')
10685     and    exists
10686           (select 1
10687            from   pay_legislation_rules        plr2
10688            where  plr2.legislation_code        = plr.legislation_code
10689            and    plr2.rule_type               = 'SDL'
10690            and    plr2.rule_mode               = 'A') ;
10691   --
10692   -- bug 2359997 get hr_soft_coding_keyflex segment values where
10693   -- soft_coding_keyflex_id is known
10694   --
10695   cursor c_scl_segments is
10696      select segment1,
10697             segment2,
10698             segment3,
10699             segment4,
10700             segment5,
10701             segment6,
10702             segment7,
10703             segment8,
10704             segment9,
10705             segment10,
10706             segment11,
10707             segment12,
10708             segment13,
10709             segment14,
10710             segment15,
10711             segment16,
10712             segment17,
10713             segment18,
10714             segment19,
10715             segment20,
10716             segment21,
10717             segment22,
10718             segment23,
10719             segment24,
10720             segment25,
10721             segment26,
10722             segment27,
10723             segment28,
10724             segment29,
10725             segment30
10726      from   hr_soft_coding_keyflex
10727      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
10728   END */
10729   --
10730   -- bug 2359997 get per_cagr_grades_def segment values where
10731   -- cagr_grade_def_id is known
10732   --
10733   cursor c_cag_segments is
10734      select segment1,
10735             segment2,
10736             segment3,
10737             segment4,
10738             segment5,
10739             segment6,
10740             segment7,
10741             segment8,
10742             segment9,
10743             segment10,
10744             segment11,
10745             segment12,
10746             segment13,
10747             segment14,
10748             segment15,
10749             segment16,
10750             segment17,
10751             segment18,
10752             segment19,
10753             segment20
10754      from   per_cagr_grades_def
10755      where  cagr_grade_def_id = l_cagr_grade_def_id;
10756 --
10757 --
10758 begin
10759 --
10760  if g_debug then
10761   hr_utility.set_location('Entering:'|| l_proc, 5);
10762  end if;
10763  if g_debug then
10764   hr_utility.set_location('XXX'||l_proc||'/'||p_concat_segments,6);
10765  end if;
10766   --
10767   -- Truncate date and date_probation_end values,
10768   -- effectively removing time element.
10769   --
10770   l_effective_date     := trunc(p_effective_date);
10771   l_date_probation_end := trunc(p_date_probation_end);
10772   --
10773   l_object_version_number := p_object_version_number;
10774   --
10775   -- Bug 944911 - changed p_concatenated_segments to p_concat_segments
10776   --
10777   l_old_conc_segments:=p_concat_segments;
10778   --
10779   -- Issue a savepoint.
10780   --
10781   savepoint update_emp_asg;
10782   --
10783   --  bug 2359997 use cursor c_scl_segments to bring back segment values if
10784   --  l_soft_coding_keyflex_id has a value.
10785   --
10786 /* Added By FS
10787   if l_soft_coding_keyflex_id is not null
10788   then
10789      l_scl_null_ind := 1;
10790      open c_scl_segments;
10791      fetch c_scl_segments into l_scl_segment1,
10792                                l_scl_segment2,
10793                                l_scl_segment3,
10794                                l_scl_segment4,
10795                                l_scl_segment5,
10796                                l_scl_segment6,
10797                                l_scl_segment7,
10798                                l_scl_segment8,
10799                                l_scl_segment9,
10800                                l_scl_segment10,
10801                                l_scl_segment11,
10802                                l_scl_segment12,
10803                                l_scl_segment13,
10804                                l_scl_segment14,
10805                                l_scl_segment15,
10806                                l_scl_segment16,
10807                                l_scl_segment17,
10808                                l_scl_segment18,
10809                                l_scl_segment19,
10810                                l_scl_segment20,
10811                                l_scl_segment21,
10812                                l_scl_segment22,
10813                                l_scl_segment23,
10814                                l_scl_segment24,
10815                                l_scl_segment25,
10816                                l_scl_segment26,
10817                                l_scl_segment27,
10818                                l_scl_segment28,
10819                                l_scl_segment29,
10820                                l_scl_segment30;
10821     close c_scl_segments;
10822   else
10823     l_scl_null_ind := 0;
10824   end if;
10825 Added by FS */
10826   --
10827   -- if cagr_grade_def_id has a value then use it to get segment values using
10828   -- cursor cag_segments
10829   --
10830   if l_cagr_grade_def_id is not null
10831   then
10832     l_cag_null_ind := 1;
10833     open c_cag_segments;
10834       fetch c_cag_segments into l_cag_segment1,
10835                                 l_cag_segment2,
10836                                 l_cag_segment3,
10837                                 l_cag_segment4,
10838                                 l_cag_segment5,
10839                                 l_cag_segment6,
10840                                 l_cag_segment7,
10841                                 l_cag_segment8,
10842                                 l_cag_segment9,
10843                                 l_cag_segment10,
10844                                 l_cag_segment11,
10845                                 l_cag_segment12,
10846                                 l_cag_segment13,
10847                                 l_cag_segment14,
10848                                 l_cag_segment15,
10849                                 l_cag_segment16,
10850                                 l_cag_segment17,
10851                                 l_cag_segment18,
10852                                 l_cag_segment19,
10853                                 l_cag_segment20;
10854     close c_cag_segments;
10855   else
10856     l_cag_null_ind := 0;
10857   end if;
10858   --
10859   --
10860   begin
10861     --
10862     -- Start of API User Hook for the before hook of update_emp_asg
10863     --
10864     hr_assignment_bk2.update_emp_asg_b
10865       (p_effective_date               => l_effective_date
10866       ,p_datetrack_update_mode        => p_datetrack_update_mode
10867       ,p_assignment_id                => p_assignment_id
10868       ,p_object_version_number        => p_object_version_number
10869       ,p_supervisor_id                => p_supervisor_id
10870       ,p_assignment_number            => p_assignment_number
10871       ,p_change_reason                => p_change_reason
10872       ,p_assignment_status_type_id    => p_assignment_status_type_id
10873       ,p_comments                     => p_comments
10874       ,p_date_probation_end           => l_date_probation_end
10875       ,p_default_code_comb_id         => p_default_code_comb_id
10876       ,p_frequency                    => p_frequency
10877       ,p_internal_address_line        => p_internal_address_line
10878       ,p_manager_flag                 => p_manager_flag
10879       ,p_normal_hours                 => p_normal_hours
10880       ,p_perf_review_period           => p_perf_review_period
10881       ,p_perf_review_period_frequency => p_perf_review_period_frequency
10882       ,p_probation_period             => p_probation_period
10883       ,p_probation_unit               => p_probation_unit
10884       ,p_projected_assignment_end     => p_projected_assignment_end
10885       ,p_sal_review_period            => p_sal_review_period
10886       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
10887       ,p_set_of_books_id              => p_set_of_books_id
10888       ,p_source_type                  => p_source_type
10889       ,p_time_normal_finish           => p_time_normal_finish
10890       ,p_time_normal_start            => p_time_normal_start
10891       ,p_bargaining_unit_code         => p_bargaining_unit_code
10892       ,p_labour_union_member_flag     => p_labour_union_member_flag
10893       ,p_hourly_salaried_code         => p_hourly_salaried_code
10894       ,p_ass_attribute_category       => p_ass_attribute_category
10895       ,p_ass_attribute1               => p_ass_attribute1
10896       ,p_ass_attribute2               => p_ass_attribute2
10897       ,p_ass_attribute3               => p_ass_attribute3
10898       ,p_ass_attribute4               => p_ass_attribute4
10899       ,p_ass_attribute5               => p_ass_attribute5
10900       ,p_ass_attribute6               => p_ass_attribute6
10901       ,p_ass_attribute7               => p_ass_attribute7
10902       ,p_ass_attribute8               => p_ass_attribute8
10903       ,p_ass_attribute9               => p_ass_attribute9
10904       ,p_ass_attribute10              => p_ass_attribute10
10905       ,p_ass_attribute11              => p_ass_attribute11
10906       ,p_ass_attribute12              => p_ass_attribute12
10907       ,p_ass_attribute13              => p_ass_attribute13
10908       ,p_ass_attribute14              => p_ass_attribute14
10909       ,p_ass_attribute15              => p_ass_attribute15
10910       ,p_ass_attribute16              => p_ass_attribute16
10911       ,p_ass_attribute17              => p_ass_attribute17
10912       ,p_ass_attribute18              => p_ass_attribute18
10913       ,p_ass_attribute19              => p_ass_attribute19
10914       ,p_ass_attribute20              => p_ass_attribute20
10915       ,p_ass_attribute21              => p_ass_attribute21
10916       ,p_ass_attribute22              => p_ass_attribute22
10917       ,p_ass_attribute23              => p_ass_attribute23
10918       ,p_ass_attribute24              => p_ass_attribute24
10919       ,p_ass_attribute25              => p_ass_attribute25
10920       ,p_ass_attribute26              => p_ass_attribute26
10921       ,p_ass_attribute27              => p_ass_attribute27
10922       ,p_ass_attribute28              => p_ass_attribute28
10923       ,p_ass_attribute29              => p_ass_attribute29
10924       ,p_ass_attribute30              => p_ass_attribute30
10925       ,p_title                        => p_title
10926       ,p_segment1                     => l_scl_segment1
10927       ,p_segment2                     => l_scl_segment2
10928       ,p_segment3                     => l_scl_segment3
10929       ,p_segment4                     => l_scl_segment4
10930       ,p_segment5                     => l_scl_segment5
10931       ,p_segment6                     => l_scl_segment6
10932       ,p_segment7                     => l_scl_segment7
10933       ,p_segment8                     => l_scl_segment8
10934       ,p_segment9                     => l_scl_segment9
10935       ,p_segment10                    => l_scl_segment10
10936       ,p_segment11                    => l_scl_segment11
10937       ,p_segment12                    => l_scl_segment12
10938       ,p_segment13                    => l_scl_segment13
10939       ,p_segment14                    => l_scl_segment14
10940       ,p_segment15                    => l_scl_segment15
10941       ,p_segment16                    => l_scl_segment16
10942       ,p_segment17                    => l_scl_segment17
10943       ,p_segment18                    => l_scl_segment18
10944       ,p_segment19                    => l_scl_segment19
10945       ,p_segment20                    => l_scl_segment20
10946       ,p_segment21                    => l_scl_segment21
10947       ,p_segment22                    => l_scl_segment22
10948       ,p_segment23                    => l_scl_segment23
10949       ,p_segment24                    => l_scl_segment24
10950       ,p_segment25                    => l_scl_segment25
10951       ,p_segment26                    => l_scl_segment26
10952       ,p_segment27                    => l_scl_segment27
10953       ,p_segment28                    => l_scl_segment28
10954       ,p_segment29                    => l_scl_segment29
10955       ,p_segment30                    => l_scl_segment30
10956       -- Bug 944911
10957       -- Amended p_concatendated_segments by p_concat_segments
10958       ,p_concat_segments              => l_old_conc_segments
10959       ,p_contract_id                  => p_contract_id
10960       ,p_establishment_id             => p_establishment_id
10961       ,p_collective_agreement_id      => p_collective_agreement_id
10962       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
10963       ,p_cag_segment1                 => l_cag_segment1
10964       ,p_cag_segment2                 => l_cag_segment2
10965       ,p_cag_segment3                 => l_cag_segment3
10966       ,p_cag_segment4                 => l_cag_segment4
10967       ,p_cag_segment5                 => l_cag_segment5
10968       ,p_cag_segment6                 => l_cag_segment6
10969       ,p_cag_segment7                 => l_cag_segment7
10970       ,p_cag_segment8                 => l_cag_segment8
10971       ,p_cag_segment9                 => l_cag_segment9
10972       ,p_cag_segment10                => l_cag_segment10
10973       ,p_cag_segment11                => l_cag_segment11
10974       ,p_cag_segment12                => l_cag_segment12
10975       ,p_cag_segment13                => l_cag_segment13
10976       ,p_cag_segment14                => l_cag_segment14
10977       ,p_cag_segment15                => l_cag_segment15
10978       ,p_cag_segment16                => l_cag_segment16
10979       ,p_cag_segment17                => l_cag_segment17
10980       ,p_cag_segment18                => l_cag_segment18
10981       ,p_cag_segment19                => l_cag_segment19
10982       ,p_cag_segment20                => l_cag_segment20
10983       ,p_notice_period		      => p_notice_period
10984       ,p_notice_period_uom	      => p_notice_period_uom
10985       ,p_employee_category	      => p_employee_category
10986       ,p_work_at_home		      => p_work_at_home
10987       ,p_job_post_source_name	      => p_job_post_source_name
10988       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
10989        );
10990   exception
10991     when hr_api.cannot_find_prog_unit then
10992       hr_api.cannot_find_prog_unit_error
10993         (p_module_name => 'UPDATE_EMP_ASG'
10994         ,p_hook_type   => 'BP'
10995         );
10996     --
10997     -- End of API User Hook for the before hook of update_emp_asg
10998     --
10999   end;
11000   --
11001  if g_debug then
11002   hr_utility.set_location(l_proc, 10);
11003  end if;
11004   --
11005   -- Validation in addition to Table Handlers
11006   --
11007   -- Get assignment type.
11008   --
11009   hr_api.mandatory_arg_error
11010     (p_api_name       => l_proc
11011     ,p_argument       => 'assignment_id'
11012     ,p_argument_value => p_assignment_id);
11013   --
11014   hr_api.mandatory_arg_error
11015     (p_api_name       => l_proc
11016     ,p_argument       => 'effective_date'
11017     ,p_argument_value => l_effective_date);
11018   --
11019   open  csr_get_assignment_type;
11020   fetch csr_get_assignment_type
11021    into l_assignment_type
11022       , l_business_group_id
11023       -- , l_soft_coding_keyflex_id  -- bug 2359997
11024       , l_organization_id
11025       , l_location_id;
11026   --
11027   if csr_get_assignment_type%NOTFOUND then
11028     close csr_get_assignment_type;
11029     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
11030     hr_utility.raise_error;
11031   end if;
11032   --
11033   close csr_get_assignment_type;
11034   --
11035  if g_debug then
11036   hr_utility.set_location(l_proc, 20);
11037  end if;
11038   --
11039   if l_assignment_type <> 'E' then
11040     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
11041     hr_utility.raise_error;
11042   end if;
11043   --
11044  if g_debug then
11045   hr_utility.set_location(l_proc, 21);
11046  end if;
11047   --
11048   --added validation for bug 1867720
11049   --
11050   if p_assignment_status_type_id <> hr_api.g_number then
11051     open csr_old_asg_status;
11052     fetch csr_old_asg_status into l_old_asg_status;
11053     close csr_old_asg_status;
11054     --
11055     open csr_new_asg_status;
11056     fetch csr_new_asg_status into l_new_asg_status;
11057       if csr_new_asg_status%notfound
11058         OR (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status)
11059       then
11060       fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
11061       fnd_message.set_token('SYSTYPE',l_old_asg_status);
11062       fnd_message.raise_error;
11063     end if;
11064     close csr_new_asg_status;
11065   end if;
11066   --
11067  if g_debug then
11068   hr_utility.set_location(l_proc, 21);
11069  end if;
11070   --
11071   -- insert the profile options and effective date for the flexfield
11072   -- validation to work
11073   --
11074   if g_debug then
11075    hr_utility.set_location('EMP Asg B Profile:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11076    hr_utility.set_location('EMP Asg l_organization_id:' || l_organization_id, 13163);
11077   end if;
11078   hr_kflex_utility.set_profiles
11079   (p_business_group_id => l_business_group_id
11080   ,p_assignment_id     => p_assignment_id
11081   ,p_organization_id   => NVL(per_qh_maintain_update.p_qh_organization_id,l_organization_id)  -- Fix For Bug # 8238220
11082   ,p_location_id       => l_location_id);
11083   --
11084   per_qh_maintain_update.p_qh_organization_id := NULL;   --- Added For Bug # 8238220
11085   hr_kflex_utility.set_session_date
11086   (p_effective_date => l_effective_date
11087   ,p_session_id     => l_session_id);
11088   if g_debug then
11089       hr_utility.set_location('EMP Asg A Profile:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11090   end if;
11091   --
11092   -- Bug 944911
11093   -- Added to next 2 ifs check for p_concatenated_segments also
11094   --
11095     --
11096   -- Update or select the soft_coding_keyflex_id
11097   --
11098 /* Added By Fs
11099   if l_scl_null_ind = 0 -- bug 2359997 added this if statement
11100                         -- soft coding keyflex id came in null
11101   then
11102      open csr_get_soft_coding_keyflex;  -- bug 2359997 get soft coding keyflex
11103        fetch csr_get_soft_coding_keyflex
11104         into l_soft_coding_keyflex_id;
11105      --
11106      if csr_get_soft_coding_keyflex%NOTFOUND then
11107        close csr_get_soft_coding_keyflex;
11108        hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
11109        hr_utility.raise_error;
11110      end if;
11111      --
11112      close csr_get_soft_coding_keyflex;
11113      --
11114     -- Start of Fix for   Bug 2548555
11115      --
11116      if   nvl(l_scl_segment1,'x') <> hr_api.g_varchar2
11117        or nvl(l_scl_segment2,'x') <> hr_api.g_varchar2
11118        or nvl(l_scl_segment3,'x') <> hr_api.g_varchar2
11119        or nvl(l_scl_segment4,'x') <> hr_api.g_varchar2
11120        or nvl(l_scl_segment5,'x') <> hr_api.g_varchar2
11121        or nvl(l_scl_segment6,'x') <> hr_api.g_varchar2
11122        or nvl(l_scl_segment7,'x') <> hr_api.g_varchar2
11123        or nvl(l_scl_segment8,'x') <> hr_api.g_varchar2
11124        or nvl(l_scl_segment9,'x') <> hr_api.g_varchar2
11125        or nvl(l_scl_segment10,'x') <> hr_api.g_varchar2
11126        or nvl(l_scl_segment11,'x') <> hr_api.g_varchar2
11127        or nvl(l_scl_segment12,'x') <> hr_api.g_varchar2
11128        or nvl(l_scl_segment13,'x') <> hr_api.g_varchar2
11129        or nvl(l_scl_segment14,'x') <> hr_api.g_varchar2
11130        or nvl(l_scl_segment15,'x') <> hr_api.g_varchar2
11131        or nvl(l_scl_segment16,'x') <> hr_api.g_varchar2
11132        or nvl(l_scl_segment17,'x') <> hr_api.g_varchar2
11133        or nvl(l_scl_segment18,'x') <> hr_api.g_varchar2
11134        or nvl(l_scl_segment19,'x') <> hr_api.g_varchar2
11135        or nvl(l_scl_segment20,'x') <> hr_api.g_varchar2
11136        or nvl(l_scl_segment21,'x') <> hr_api.g_varchar2
11137        or nvl(l_scl_segment22,'x') <> hr_api.g_varchar2
11138        or nvl(l_scl_segment23,'x') <> hr_api.g_varchar2
11139        or nvl(l_scl_segment24,'x') <> hr_api.g_varchar2
11140        or nvl(l_scl_segment25,'x') <> hr_api.g_varchar2
11141        or nvl(l_scl_segment26,'x') <> hr_api.g_varchar2
11142        or nvl(l_scl_segment27,'x') <> hr_api.g_varchar2
11143        or nvl(l_scl_segment28,'x') <> hr_api.g_varchar2
11144        or nvl(l_scl_segment29,'x') <> hr_api.g_varchar2
11145        or nvl(l_scl_segment30,'x') <> hr_api.g_varchar2
11146        -- bug 944911
11147        -- changed p_concatenated_segments to p_concat_segments
11148        or nvl(p_concat_segments,'x') <> hr_api.g_varchar2
11149  --
11150  -- End of Fix for Bug 2548555
11151  --
11152     then
11153        open csr_scl_idsel;
11154        fetch csr_scl_idsel into l_flex_num;
11155        --
11156        if csr_scl_idsel%NOTFOUND
11157        then
11158          close csr_scl_idsel;
11159          if   l_scl_segment1 is not null
11160            or l_scl_segment2 is not null
11161            or l_scl_segment3 is not null
11162            or l_scl_segment4 is not null
11163            or l_scl_segment5 is not null
11164            or l_scl_segment6 is not null
11165            or l_scl_segment7 is not null
11166            or l_scl_segment8 is not null
11167            or l_scl_segment9 is not null
11168            or l_scl_segment10 is not null
11169            or l_scl_segment11 is not null
11170            or l_scl_segment12 is not null
11171            or l_scl_segment13 is not null
11172            or l_scl_segment14 is not null
11173            or l_scl_segment15 is not null
11174            or l_scl_segment16 is not null
11175            or l_scl_segment17 is not null
11176            or l_scl_segment18 is not null
11177            or l_scl_segment19 is not null
11178            or l_scl_segment20 is not null
11179            or l_scl_segment21 is not null
11180            or l_scl_segment22 is not null
11181            or l_scl_segment23 is not null
11182            or l_scl_segment24 is not null
11183            or l_scl_segment25 is not null
11184            or l_scl_segment26 is not null
11185            or l_scl_segment27 is not null
11186            or l_scl_segment28 is not null
11187            or l_scl_segment29 is not null
11188            or l_scl_segment30 is not null
11189            or p_concat_segments is not null
11190          then
11191             --
11192             hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
11193             hr_utility.set_message_token('PROCEDURE', l_proc);
11194             hr_utility.set_message_token('STEP','5');
11195             hr_utility.raise_error;
11196          end if;
11197       else -- csr_scl_idsel is found
11198          close csr_scl_idsel;
11199          --
11200          -- Process Logic
11201          --
11202          --
11203          -- Update or select the soft_coding_keyflex_id
11204          --
11205          hr_kflex_utility.upd_or_sel_keyflex_comb
11206            (p_appl_short_name        => 'PER'
11207            ,p_flex_code              => 'SCL'
11208            ,p_flex_num               => l_flex_num
11209            ,p_segment1               => l_scl_segment1
11210            ,p_segment2               => l_scl_segment2
11211            ,p_segment3               => l_scl_segment3
11212            ,p_segment4               => l_scl_segment4
11213            ,p_segment5               => l_scl_segment5
11214            ,p_segment6               => l_scl_segment6
11215            ,p_segment7               => l_scl_segment7
11216            ,p_segment8               => l_scl_segment8
11217            ,p_segment9               => l_scl_segment9
11218            ,p_segment10              => l_scl_segment10
11219            ,p_segment11              => l_scl_segment11
11220            ,p_segment12              => l_scl_segment12
11221            ,p_segment13              => l_scl_segment13
11222            ,p_segment14              => l_scl_segment14
11223            ,p_segment15              => l_scl_segment15
11224            ,p_segment16              => l_scl_segment16
11225            ,p_segment17              => l_scl_segment17
11226            ,p_segment18              => l_scl_segment18
11227            ,p_segment19              => l_scl_segment19
11228            ,p_segment20              => l_scl_segment20
11229            ,p_segment21              => l_scl_segment21
11230            ,p_segment22              => l_scl_segment22
11231            ,p_segment23              => l_scl_segment23
11232            ,p_segment24              => l_scl_segment24
11233            ,p_segment25              => l_scl_segment25
11234            ,p_segment26              => l_scl_segment26
11235            ,p_segment27              => l_scl_segment27
11236            ,p_segment28              => l_scl_segment28
11237            ,p_segment29              => l_scl_segment29
11238            ,p_segment30              => l_scl_segment30
11239            ,p_concat_segments_in     => l_old_conc_segments
11240            ,p_ccid                   => l_soft_coding_keyflex_id
11241            ,p_concat_segments_out    => l_concatenated_segments
11242            );
11243           --
11244           -- update the combinations column
11245           --
11246           update_scl_concat_segs
11247           (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
11248           ,p_concatenated_segments   => l_concatenated_segments
11249           );
11250        --
11251        end if; -- csr_scl_idsel%NOTFOUND
11252     --
11253     end if;  -- l_scl_segment1 <> hr_api.g_varchar2
11254   --
11255   end if; -- l_soft_coding_key_flex_id is null
11256   --
11257 Added By FS */
11258 
11259 
11260 --
11261 -- Start of fix for Bug 2622747
11262 --
11263  if g_debug then
11264    hr_utility.set_location('EMP Asg B V_SCL:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11265  end if;
11266   validate_SCL (
11267    p_validate                     => FALSE --Changed from p_validate to false for fix of #3180527
11268   ,p_assignment_id                => p_assignment_id
11269   ,p_effective_date               => l_effective_date
11270   ,p_business_group_id            => l_business_group_id
11271   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
11272   ,p_concatenated_segments        => l_concatenated_segments
11273   ,p_concat_segments              => NULL
11274   ,p_segment1                     => l_scl_segment1
11275   ,p_segment2                     => l_scl_segment2
11276   ,p_segment3                     => l_scl_segment3
11277   ,p_segment4                     => l_scl_segment4
11278   ,p_segment5                     => l_scl_segment5
11279   ,p_segment6                     => l_scl_segment6
11280   ,p_segment7                     => l_scl_segment7
11281   ,p_segment8                     => l_scl_segment8
11282   ,p_segment9                     => l_scl_segment9
11283   ,p_segment10                    => l_scl_segment10
11284   ,p_segment11                    => l_scl_segment11
11285   ,p_segment12                    => l_scl_segment12
11286   ,p_segment13                    => l_scl_segment13
11287   ,p_segment14                    => l_scl_segment14
11288   ,p_segment15                    => l_scl_segment15
11289   ,p_segment16                    => l_scl_segment16
11290   ,p_segment17                    => l_scl_segment17
11291   ,p_segment18                    => l_scl_segment18
11292   ,p_segment19                    => l_scl_segment19
11293   ,p_segment20                    => l_scl_segment20
11294   ,p_segment21                    => l_scl_segment21
11295   ,p_segment22                    => l_scl_segment22
11296   ,p_segment23                    => l_scl_segment23
11297   ,p_segment24                    => l_scl_segment24
11298   ,p_segment25                    => l_scl_segment25
11299   ,p_segment26                    => l_scl_segment26
11300   ,p_segment27                    => l_scl_segment27
11301   ,p_segment28                    => l_scl_segment28
11302   ,p_segment29                    => l_scl_segment29
11303   ,p_segment30                    => l_scl_segment30
11304   );
11305 --End of fix for Bug 2622747
11306   --
11307   if g_debug then
11308     hr_utility.set_location('EMP Asg A V_SCL:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11309   end if;
11310  if g_debug then
11311   hr_utility.set_location(l_proc, 23);
11312  end if;
11313   --
11314   --
11315   -- Update or select the cagr_grade_def_id
11316   --
11317   -- need to call the lck procedure early, to fetch the
11318   -- old value of cagr_id_flex_num
11319   -- before passing it into the hr_cgd_upd.upd_or_sel function.
11320   -- This is because the user may be updating a grade definition,
11321   -- but not changing
11322   -- or specifying the cagr_id_flex_num (ie the grade structure).
11323   -- Also, need to fetch the old cagr_grade_def_id, as
11324   -- the user may be updating some
11325   -- segments, and not changing others.
11326   -- Passing cagr_grade_id into the hr_cgd_upd.upd_or_sel
11327   -- function allows that function to derive the old values.
11328   --
11329   l_cagr_id_flex_num  := p_cagr_id_flex_num;
11330   --
11331   if (p_cagr_id_flex_num  = hr_api.g_number)
11332   then
11333      per_asg_shd.lck
11334       (p_effective_date          => l_effective_date,
11335        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
11336        p_datetrack_mode          => p_datetrack_update_mode,
11337        p_assignment_id           => p_assignment_id,
11338        p_object_version_number   => p_object_version_number,
11339        p_validation_start_date   => l_unused_start_date,
11340        p_validation_end_date     => l_unused_end_date
11341        );
11342      l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
11343      -- l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
11344      -- commented out for bug 2359997
11345   end if;
11346   --
11347   --
11348   -- Bug 4003788   added the check for the cagr_id_flex_num also
11349   if l_cag_null_ind = 0  and l_cagr_id_flex_num is not null -- bug 2359997
11350   then
11351      l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
11352      --
11353      hr_cgd_upd.upd_or_sel
11354      (p_segment1               => l_cag_segment1
11355      ,p_segment2               => l_cag_segment2
11356      ,p_segment3               => l_cag_segment3
11357      ,p_segment4               => l_cag_segment4
11358      ,p_segment5               => l_cag_segment5
11359      ,p_segment6               => l_cag_segment6
11360      ,p_segment7               => l_cag_segment7
11361      ,p_segment8               => l_cag_segment8
11362      ,p_segment9               => l_cag_segment9
11363      ,p_segment10              => l_cag_segment10
11364      ,p_segment11              => l_cag_segment11
11365      ,p_segment12              => l_cag_segment12
11366      ,p_segment13              => l_cag_segment13
11367      ,p_segment14              => l_cag_segment14
11368      ,p_segment15              => l_cag_segment15
11369      ,p_segment16              => l_cag_segment16
11370      ,p_segment17              => l_cag_segment17
11371      ,p_segment18              => l_cag_segment18
11372      ,p_segment19              => l_cag_segment19
11373      ,p_segment20              => l_cag_segment20
11374      ,p_id_flex_num            => l_cagr_id_flex_num
11375      ,p_business_group_id      => l_business_group_id
11376      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
11377      ,p_concatenated_segments  => l_cagr_concatenated_segments
11378       );
11379      --
11380  if g_debug then
11381      hr_utility.set_location(l_proc, 24);
11382  end if;
11383      --
11384   end if; --  l_cagr_grade_def_id is null
11385   --
11386  if g_debug then
11387   hr_utility.set_location(l_proc, 25);
11388  end if;
11389 
11390   -- fix for bug 6595592 starts here.
11391     if (p_projected_assignment_end = to_char(hr_api.g_date) OR p_projected_assignment_end = hr_api.g_varchar2) then   --fix for 6862763
11392      --l_projected_assignment_end :=hr_api.g_date; -- commented for bug#14002201
11393      --l_projected_assignment_end :=hr_api.g_eot;   -- added for bug#14002201
11394 
11395      l_projected_assignment_end := null; -- added for bug#14470849
11396 
11397     else
11398      l_projected_assignment_end :=p_projected_assignment_end;
11399     end if;
11400  -- fix for bug 6595592 ends here.
11401   --
11402   --
11403   -- Update assignment.
11404   --
11405   if g_debug then
11406     hr_utility.set_location('EMP Asg B UPD:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11407   end if;
11408   per_asg_upd.upd
11409     (p_assignment_id                => p_assignment_id
11410     ,p_effective_start_date         => l_effective_start_date
11411     ,p_effective_end_date           => l_effective_end_date
11412     ,p_business_group_id            => l_business_group_id
11413     ,p_assignment_status_type_id    => p_assignment_status_type_id
11414     ,p_supervisor_id                => p_supervisor_id
11415     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
11416     ,p_assignment_number            => p_assignment_number
11417     ,p_change_reason                => p_change_reason
11418     ,p_comment_id                   => l_comment_id
11419     ,p_comments                     => p_comments
11420     ,p_date_probation_end           => l_date_probation_end
11421     ,p_default_code_comb_id         => p_default_code_comb_id
11422     ,p_frequency                    => p_frequency
11423     ,p_internal_address_line        => p_internal_address_line
11424     ,p_manager_flag                 => p_manager_flag
11425     ,p_normal_hours                 => p_normal_hours
11426     ,p_perf_review_period           => p_perf_review_period
11427     ,p_perf_review_period_frequency => p_perf_review_period_frequency
11428     ,p_probation_period             => p_probation_period
11429     ,p_probation_unit               => p_probation_unit
11430     ,p_projected_assignment_end     => l_projected_assignment_end -- fix for bug 6595592.
11431     ,p_sal_review_period            => p_sal_review_period
11432     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
11433     ,p_set_of_books_id              => p_set_of_books_id
11434     ,p_source_type                  => p_source_type
11435     ,p_time_normal_finish           => p_time_normal_finish
11436     ,p_time_normal_start            => p_time_normal_start
11437     ,p_bargaining_unit_code         => p_bargaining_unit_code
11438     ,p_labour_union_member_flag     => p_labour_union_member_flag
11439     ,p_hourly_salaried_code         => p_hourly_salaried_code
11440     ,p_ass_attribute_category       => p_ass_attribute_category
11441     ,p_ass_attribute1               => p_ass_attribute1
11442     ,p_ass_attribute2               => p_ass_attribute2
11443     ,p_ass_attribute3               => p_ass_attribute3
11444     ,p_ass_attribute4               => p_ass_attribute4
11445     ,p_ass_attribute5               => p_ass_attribute5
11446     ,p_ass_attribute6               => p_ass_attribute6
11447     ,p_ass_attribute7               => p_ass_attribute7
11448     ,p_ass_attribute8               => p_ass_attribute8
11449     ,p_ass_attribute9               => p_ass_attribute9
11450     ,p_ass_attribute10              => p_ass_attribute10
11451     ,p_ass_attribute11              => p_ass_attribute11
11452     ,p_ass_attribute12              => p_ass_attribute12
11453     ,p_ass_attribute13              => p_ass_attribute13
11454     ,p_ass_attribute14              => p_ass_attribute14
11455     ,p_ass_attribute15              => p_ass_attribute15
11456     ,p_ass_attribute16              => p_ass_attribute16
11457     ,p_ass_attribute17              => p_ass_attribute17
11458     ,p_ass_attribute18              => p_ass_attribute18
11459     ,p_ass_attribute19              => p_ass_attribute19
11460     ,p_ass_attribute20              => p_ass_attribute20
11461     ,p_ass_attribute21              => p_ass_attribute21
11462     ,p_ass_attribute22              => p_ass_attribute22
11463     ,p_ass_attribute23              => p_ass_attribute23
11464     ,p_ass_attribute24              => p_ass_attribute24
11465     ,p_ass_attribute25              => p_ass_attribute25
11466     ,p_ass_attribute26              => p_ass_attribute26
11467     ,p_ass_attribute27              => p_ass_attribute27
11468     ,p_ass_attribute28              => p_ass_attribute28
11469     ,p_ass_attribute29              => p_ass_attribute29
11470     ,p_ass_attribute30              => p_ass_attribute30
11471     ,p_notice_period		    => p_notice_period
11472     ,p_notice_period_uom	    => p_notice_period_uom
11473     ,p_employee_category	    => p_employee_category
11474     ,p_work_at_home		    => p_work_at_home
11475     ,p_job_post_source_name	    => p_job_post_source_name
11476     ,p_title                        => p_title
11477     ,p_payroll_id_updated           => l_payroll_id_updated
11478     ,p_other_manager_warning        => l_other_manager_warning
11479     ,p_no_managers_warning          => l_no_managers_warning
11480     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
11481     ,p_validation_start_date        => l_validation_start_date
11482     ,p_validation_end_date          => l_validation_end_date
11483     ,p_object_version_number        => l_object_version_number
11484     ,p_effective_date               => l_effective_date
11485     ,p_datetrack_mode               => p_datetrack_update_mode
11486     ,p_contract_id                  => p_contract_id
11487     ,p_establishment_id             => p_establishment_id
11488     ,p_collective_agreement_id      => p_collective_agreement_id
11489     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
11490     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
11491     ,p_validate                     => FALSE
11492     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
11493     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
11494     );
11495   --
11496   if g_debug then
11497      hr_utility.set_location('EMP Asg A UPD:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11498   end if;
11499  if g_debug then
11500   hr_utility.set_location(l_proc, 25);
11501  end if;
11502   --
11503  /* auto fte calculation bug#14700032 code changes starts */
11504 
11505   hr_assignment_internal.auto_calc_fte
11506               (p_assignment_id => p_assignment_id,
11507                p_effective_start_date => l_effective_start_date
11508 	       );
11509     hr_utility.set_location(l_proc|| ' passed  hr_assignment_internal.auto_calc_fte ', 281);
11510 
11511   /* auto fte calculation bug#14700032 code changes ends */
11512   --
11513   begin
11514     --
11515     -- Start of API User Hook for the after hook of update_emp_asg
11516     --
11517     hr_assignment_bk2.update_emp_asg_a
11518       (p_effective_date               => l_effective_date
11519       ,p_datetrack_update_mode        => p_datetrack_update_mode
11520       ,p_assignment_id                => p_assignment_id
11521       ,p_object_version_number        => p_object_version_number
11522       ,p_supervisor_id                => p_supervisor_id
11523       ,p_assignment_number            => p_assignment_number
11524       ,p_change_reason                => p_change_reason
11525       ,p_assignment_status_type_id    => p_assignment_status_type_id
11526       ,p_comments                     => p_comments
11527       ,p_date_probation_end           => l_date_probation_end
11528       ,p_default_code_comb_id         => p_default_code_comb_id
11529       ,p_frequency                    => p_frequency
11530       ,p_internal_address_line        => p_internal_address_line
11531       ,p_manager_flag                 => p_manager_flag
11532       ,p_normal_hours                 => p_normal_hours
11533       ,p_perf_review_period           => p_perf_review_period
11534       ,p_perf_review_period_frequency => p_perf_review_period_frequency
11535       ,p_probation_period             => p_probation_period
11536       ,p_probation_unit               => p_probation_unit
11537       ,p_projected_assignment_end     => p_projected_assignment_end
11538       ,p_sal_review_period            => p_sal_review_period
11539       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
11540       ,p_set_of_books_id              => p_set_of_books_id
11541       ,p_source_type                  => p_source_type
11542       ,p_time_normal_finish           => p_time_normal_finish
11543       ,p_time_normal_start            => p_time_normal_start
11544       ,p_bargaining_unit_code         => p_bargaining_unit_code
11545       ,p_labour_union_member_flag     => p_labour_union_member_flag
11546       ,p_hourly_salaried_code         => p_hourly_salaried_code
11547       ,p_ass_attribute_category       => p_ass_attribute_category
11548       ,p_ass_attribute1               => p_ass_attribute1
11549       ,p_ass_attribute2               => p_ass_attribute2
11550       ,p_ass_attribute3               => p_ass_attribute3
11551       ,p_ass_attribute4               => p_ass_attribute4
11552       ,p_ass_attribute5               => p_ass_attribute5
11553       ,p_ass_attribute6               => p_ass_attribute6
11554       ,p_ass_attribute7               => p_ass_attribute7
11555       ,p_ass_attribute8               => p_ass_attribute8
11556       ,p_ass_attribute9               => p_ass_attribute9
11557       ,p_ass_attribute10              => p_ass_attribute10
11558       ,p_ass_attribute11              => p_ass_attribute11
11559       ,p_ass_attribute12              => p_ass_attribute12
11560       ,p_ass_attribute13              => p_ass_attribute13
11561       ,p_ass_attribute14              => p_ass_attribute14
11562       ,p_ass_attribute15              => p_ass_attribute15
11563       ,p_ass_attribute16              => p_ass_attribute16
11564       ,p_ass_attribute17              => p_ass_attribute17
11565       ,p_ass_attribute18              => p_ass_attribute18
11566       ,p_ass_attribute19              => p_ass_attribute19
11567       ,p_ass_attribute20              => p_ass_attribute20
11568       ,p_ass_attribute21              => p_ass_attribute21
11569       ,p_ass_attribute22              => p_ass_attribute22
11570       ,p_ass_attribute23              => p_ass_attribute23
11571       ,p_ass_attribute24              => p_ass_attribute24
11572       ,p_ass_attribute25              => p_ass_attribute25
11573       ,p_ass_attribute26              => p_ass_attribute26
11574       ,p_ass_attribute27              => p_ass_attribute27
11575       ,p_ass_attribute28              => p_ass_attribute28
11576       ,p_ass_attribute29              => p_ass_attribute29
11577       ,p_ass_attribute30              => p_ass_attribute30
11578       ,p_title                        => p_title
11579       ,p_segment1                     => l_scl_segment1
11580       ,p_segment2                     => l_scl_segment2
11581       ,p_segment3                     => l_scl_segment3
11582       ,p_segment4                     => l_scl_segment4
11583       ,p_segment5                     => l_scl_segment5
11584       ,p_segment6                     => l_scl_segment6
11585       ,p_segment7                     => l_scl_segment7
11586       ,p_segment8                     => l_scl_segment8
11587       ,p_segment9                     => l_scl_segment9
11588       ,p_segment10                    => l_scl_segment10
11589       ,p_segment11                    => l_scl_segment11
11590       ,p_segment12                    => l_scl_segment12
11591       ,p_segment13                    => l_scl_segment13
11592       ,p_segment14                    => l_scl_segment14
11593       ,p_segment15                    => l_scl_segment15
11594       ,p_segment16                    => l_scl_segment16
11595       ,p_segment17                    => l_scl_segment17
11596       ,p_segment18                    => l_scl_segment18
11597       ,p_segment19                    => l_scl_segment19
11598       ,p_segment20                    => l_scl_segment20
11599       ,p_segment21                    => l_scl_segment21
11600       ,p_segment22                    => l_scl_segment22
11601       ,p_segment23                    => l_scl_segment23
11602       ,p_segment24                    => l_scl_segment24
11603       ,p_segment25                    => l_scl_segment25
11604       ,p_segment26                    => l_scl_segment26
11605       ,p_segment27                    => l_scl_segment27
11606       ,p_segment28                    => l_scl_segment28
11607       ,p_segment29                    => l_scl_segment29
11608       ,p_segment30                    => l_scl_segment30
11609       ,p_concatenated_segments        => l_concatenated_segments
11610       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
11611       ,p_comment_id                   => l_comment_id
11612       ,p_effective_start_date         => l_effective_start_date
11613       ,p_effective_end_date           => l_effective_end_date
11614       ,p_no_managers_warning          => l_no_managers_warning
11615       ,p_other_manager_warning        => l_other_manager_warning
11616       -- Bug 944911
11617       -- Added the new input param
11618       ,p_concat_segments              => l_old_conc_segments
11619       ,p_contract_id                  => p_contract_id
11620       ,p_establishment_id             => p_establishment_id
11621       ,p_collective_agreement_id      => p_collective_agreement_id
11622       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
11623       ,p_cag_segment1                 => l_cag_segment1
11624       ,p_cag_segment2                 => l_cag_segment2
11625       ,p_cag_segment3                 => l_cag_segment3
11626       ,p_cag_segment4                 => l_cag_segment4
11627       ,p_cag_segment5                 => l_cag_segment5
11628       ,p_cag_segment6                 => l_cag_segment6
11629       ,p_cag_segment7                 => l_cag_segment7
11630       ,p_cag_segment8                 => l_cag_segment8
11631       ,p_cag_segment9                 => l_cag_segment9
11632       ,p_cag_segment10                => l_cag_segment10
11633       ,p_cag_segment11                => l_cag_segment11
11634       ,p_cag_segment12                => l_cag_segment12
11635       ,p_cag_segment13                => l_cag_segment13
11636       ,p_cag_segment14                => l_cag_segment14
11637       ,p_cag_segment15                => l_cag_segment15
11638       ,p_cag_segment16                => l_cag_segment16
11639       ,p_cag_segment17                => l_cag_segment17
11640       ,p_cag_segment18                => l_cag_segment18
11641       ,p_cag_segment19                => l_cag_segment19
11642       ,p_cag_segment20                => l_cag_segment20
11643       ,p_notice_period		      => p_notice_period
11644       ,p_notice_period_uom	      => p_notice_period_uom
11645       ,p_employee_category	      => p_employee_category
11646       ,p_work_at_home		      => p_work_at_home
11647       ,p_job_post_source_name	      => p_job_post_source_name
11648       ,p_cagr_grade_def_id            => l_cagr_grade_def_id
11649       ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
11650       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
11651       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
11652       );
11653   exception
11654     when hr_api.cannot_find_prog_unit then
11655       hr_api.cannot_find_prog_unit_error
11656         (p_module_name => 'UPDATE_EMP_ASG'
11657         ,p_hook_type   => 'AP'
11658         );
11659     --
11660     -- End of API User Hook for the after hook of update_emp_asg
11661     --
11662   end;
11663 
11664   --
11665   -- call pqh post process procedure -- bug 2999562
11666   --
11667   pqh_gsp_post_process.call_pp_from_assignments(
11668       p_effective_date    => p_effective_date
11669      ,p_assignment_id     => p_assignment_id
11670      ,p_date_track_mode   => p_datetrack_update_mode
11671      ,p_warning_mesg      => l_gsp_post_process_warning
11672   );
11673 
11674   --
11675   -- When in validation only mode raise the Validate_Enabled exception
11676   --
11677   if p_validate then
11678     raise hr_api.validate_enabled;
11679   end if;
11680   --
11681   -- Set all output arguments
11682   --
11683   p_object_version_number  := l_object_version_number;
11684   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
11685   p_comment_id             := l_comment_id;
11686   p_effective_start_date   := l_effective_start_date;
11687   p_effective_end_date     := l_effective_end_date;
11688   p_concatenated_segments  := l_concatenated_segments;
11689   p_no_managers_warning    := l_no_managers_warning;
11690   p_other_manager_warning  := l_other_manager_warning;
11691   p_cagr_grade_def_id          := l_cagr_grade_def_id;
11692   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
11693   p_hourly_salaried_warning    := l_hourly_salaried_warning;
11694   p_gsp_post_process_warning   := l_gsp_post_process_warning; -- bug 2999562
11695   --
11696   -- remove data from the session table
11697   hr_kflex_utility.unset_session_date
11698     (p_session_id     => l_session_id);
11699   --
11700  if g_debug then
11701   hr_utility.set_location(' Leaving:'||l_proc, 30);
11702   hr_utility.set_location('EMP Asg Leaving:' || fnd_profile.value('PER_ORGANIZATION_ID'), 13163);
11703  end if;
11704 exception
11705   when hr_api.validate_enabled then
11706     --
11707     -- As the Validate_Enabled exception has been raised
11708     -- we must rollback to the savepoint
11709     --
11710     ROLLBACK TO update_emp_asg;
11711     --
11712     -- Only set output warning arguments
11713     -- (Any key or derived arguments must be set to null
11714     -- when validation only mode is being used.)
11715     --
11716     p_object_version_number  := p_object_version_number;
11717     p_comment_id             := null;
11718     p_effective_start_date   := null;
11719     p_effective_end_date     := null;
11720     p_concatenated_segments  := l_old_conc_segments;
11721     p_no_managers_warning    := l_no_managers_warning;
11722     p_other_manager_warning  := l_other_manager_warning;
11723     p_cagr_concatenated_segments := null;
11724     p_hourly_salaried_warning    := l_hourly_salaried_warning;
11725     p_soft_coding_keyflex_id     := l_soft_coding_keyflex_id;
11726     p_gsp_post_process_warning   := l_gsp_post_process_warning; -- bug 2999562
11727     --
11728     -- bug 2359997 only re-set to null if key flex ids came in as null.
11729     --
11730     --
11731     if l_cag_null_ind = 0
11732     then
11733        p_cagr_grade_def_id       := null;
11734     end if;
11735     --
11736   when others then
11737     --
11738     -- A validation or unexpected error has occurred
11739     --
11740     -- Added as part of fix to bug 632479
11741     --
11742     p_object_version_number      := lv_object_version_number ;
11743     p_cagr_grade_def_id          := lv_cagr_grade_def_id ;
11744     p_soft_coding_keyflex_id     := lv_soft_coding_keyflex_id ;
11745 
11746     p_cagr_concatenated_segments     := null;
11747     p_concatenated_segments          := null;
11748     p_comment_id                     := null;
11749     p_effective_start_date           := null;
11750     p_effective_end_date             := null;
11751     p_no_managers_warning            := null;
11752     p_other_manager_warning          := null;
11753     p_hourly_salaried_warning        := null;
11754     p_gsp_post_process_warning       := null;
11755 
11756     ROLLBACK TO update_emp_asg;
11757     raise;
11758     --
11759     -- End of fix.
11760     --
11761 end update_emp_asg;
11762 --
11763 -- ----------------------------------------------------------------------------
11764 -- |--------------------------< update_cwk_asg >-------------------------------|
11765 -- ----------------------------------------------------------------------------
11766 --
11767 procedure update_cwk_asg
11768   (p_validate                     in     boolean
11769   ,p_effective_date               in     date
11770   ,p_datetrack_update_mode        in     varchar2
11771   ,p_assignment_id                in     number
11772   ,p_object_version_number        in out nocopy number
11773   ,p_assignment_category          in     varchar2
11774   ,p_assignment_number            in     varchar2
11775   ,p_change_reason                in     varchar2
11776   ,p_comments                     in     varchar2
11777   ,p_default_code_comb_id         in     number
11778   ,p_establishment_id             in     number
11779   ,p_frequency                    in     varchar2
11780   ,p_internal_address_line        in     varchar2
11781   ,p_labour_union_member_flag     in     varchar2
11782   ,p_manager_flag                 in     varchar2
11783   ,p_normal_hours                 in     number
11784   ,p_project_title		  in     varchar2
11785   ,p_set_of_books_id              in     number
11786   ,p_source_type                  in     varchar2
11787   ,p_supervisor_id                in     number
11788   ,p_time_normal_finish           in     varchar2
11789   ,p_time_normal_start            in     varchar2
11790   ,p_title                        in     varchar2
11791   ,p_vendor_assignment_number     in     varchar2
11792   ,p_vendor_employee_number       in     varchar2
11793   ,p_vendor_id                    in     number
11794   ,p_vendor_site_id               in     number
11795   ,p_po_header_id                 in     number
11796   ,p_po_line_id                   in     number
11797   ,p_projected_assignment_end     in     date
11798   ,p_assignment_status_type_id    in     number
11799   ,p_concat_segments              in     varchar2
11800   ,p_attribute_category           in     varchar2
11801   ,p_attribute1                   in     varchar2
11802   ,p_attribute2                   in     varchar2
11803   ,p_attribute3                   in     varchar2
11804   ,p_attribute4                   in     varchar2
11805   ,p_attribute5                   in     varchar2
11806   ,p_attribute6                   in     varchar2
11807   ,p_attribute7                   in     varchar2
11808   ,p_attribute8                   in     varchar2
11809   ,p_attribute9                   in     varchar2
11810   ,p_attribute10                  in     varchar2
11811   ,p_attribute11                  in     varchar2
11812   ,p_attribute12                  in     varchar2
11813   ,p_attribute13                  in     varchar2
11814   ,p_attribute14                  in     varchar2
11815   ,p_attribute15                  in     varchar2
11816   ,p_attribute16                  in     varchar2
11817   ,p_attribute17                  in     varchar2
11818   ,p_attribute18                  in     varchar2
11819   ,p_attribute19                  in     varchar2
11820   ,p_attribute20                  in     varchar2
11821   ,p_attribute21                  in     varchar2
11822   ,p_attribute22                  in     varchar2
11823   ,p_attribute23                  in     varchar2
11824   ,p_attribute24                  in     varchar2
11825   ,p_attribute25                  in     varchar2
11826   ,p_attribute26                  in     varchar2
11827   ,p_attribute27                  in     varchar2
11828   ,p_attribute28                  in     varchar2
11829   ,p_attribute29                  in     varchar2
11830   ,p_attribute30                  in     varchar2
11831   ,p_scl_segment1                 in     varchar2
11832   ,p_scl_segment2                 in     varchar2
11833   ,p_scl_segment3                 in     varchar2
11834   ,p_scl_segment4                 in     varchar2
11835   ,p_scl_segment5                 in     varchar2
11836   ,p_scl_segment6                 in     varchar2
11837   ,p_scl_segment7                 in     varchar2
11838   ,p_scl_segment8                 in     varchar2
11839   ,p_scl_segment9                 in     varchar2
11840   ,p_scl_segment10                in     varchar2
11841   ,p_scl_segment11                in     varchar2
11842   ,p_scl_segment12                in     varchar2
11843   ,p_scl_segment13                in     varchar2
11844   ,p_scl_segment14                in     varchar2
11845   ,p_scl_segment15                in     varchar2
11846   ,p_scl_segment16                in     varchar2
11847   ,p_scl_segment17                in     varchar2
11848   ,p_scl_segment18                in     varchar2
11849   ,p_scl_segment19                in     varchar2
11850   ,p_scl_segment20                in     varchar2
11851   ,p_scl_segment21                in     varchar2
11852   ,p_scl_segment22                in     varchar2
11853   ,p_scl_segment23                in     varchar2
11854   ,p_scl_segment24                in     varchar2
11855   ,p_scl_segment25                in     varchar2
11856   ,p_scl_segment26                in     varchar2
11857   ,p_scl_segment27                in     varchar2
11858   ,p_scl_segment28                in     varchar2
11859   ,p_scl_segment29                in     varchar2
11860   ,p_scl_segment30                in     varchar2
11861   ,p_supervisor_assignment_id     in     number
11862   ,p_org_now_no_manager_warning      out nocopy boolean
11863   ,p_effective_start_date            out nocopy date
11864   ,p_effective_end_date              out nocopy date
11865   ,p_comment_id                      out nocopy number
11866   ,p_no_managers_warning             out nocopy boolean
11867   ,p_other_manager_warning           out nocopy boolean
11868   ,p_soft_coding_keyflex_id          out nocopy number
11869   ,p_concatenated_segments           out nocopy varchar2
11870   ,p_hourly_salaried_warning         out nocopy boolean) IS
11871   --
11872   -- Declare cursors and local variables
11873   --
11874   -- Out variables
11875   --
11876   l_org_now_no_manager_warning BOOLEAN;
11877   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
11878   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
11879   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
11880   l_no_managers_warning        BOOLEAN;
11881   l_other_manager_warning      BOOLEAN;
11882   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
11883   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
11884   l_concatenated_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
11885   l_old_conc_segments          hr_soft_coding_keyflex.concatenated_segments%TYPE;
11886   l_hourly_salaried_warning    BOOLEAN;
11887   l_session_id                 NUMBER;
11888   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
11889   l_payroll_id_updated         BOOLEAN;
11890   --
11891   -- Internal working variables
11892   --
11893   l_proc                       VARCHAR2(72) := g_package||'update_cwk_asg';
11894   l_effective_date             DATE;
11895   l_projected_assignment_end   DATE;
11896   l_organization_id            per_all_assignments_f.organization_id%TYPE;
11897   l_business_group_id          per_business_groups.business_group_id%TYPE;
11898   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
11899   l_location_id                per_all_assignments_f.location_id%TYPE;
11900   l_old_asg_status             per_assignment_status_types.per_system_status%TYPE;
11901   l_new_asg_status             per_assignment_status_types.per_system_status%TYPE;
11902   l_cagr_grade_def_id          NUMBER;
11903   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
11904   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
11905   l_po_header_id               NUMBER := p_po_header_id;
11906   l_vendor_id                  NUMBER := p_vendor_id;
11907   --
11908   /*
11909   l_old_conc_segments          hr_soft_coding_keyflex.concatenated_segments%TYPE;
11910   l_date_probation_end         per_all_assignments_f.date_probation_end%TYPE;
11911   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
11912   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
11913   l_unused_start_date          date;
11914   l_unused_end_date            date;
11915   */
11916   --
11917   lv_object_version_number     number := p_object_version_number ;
11918   --
11919   cursor csr_old_asg_status is
11920     select ast.per_system_status
11921     from   per_assignment_status_types ast,
11922            per_all_assignments_f asg
11923     where  ast.assignment_status_type_id = asg.assignment_status_type_id
11924     and    asg.assignment_id             = p_assignment_id
11925     and    l_effective_date between asg.effective_start_date and asg.effective_end_date;
11926   --
11927   cursor csr_new_asg_status is
11928     select ast.per_system_status
11929     from   per_assignment_status_types ast
11930     where  ast.assignment_status_type_id = p_assignment_status_type_id;
11931   --
11932   cursor csr_get_assignment_type is
11933     select asg.assignment_type
11934          , asg.business_group_id
11935          , asg.soft_coding_keyflex_id
11936          , asg.organization_id
11937          , asg.location_id
11938       from per_all_assignments_f asg
11939      where asg.assignment_id = p_assignment_id
11940        and l_effective_date  between asg.effective_start_date
11941                              and     asg.effective_end_date;
11942   --
11943   cursor csr_scl_idsel is
11944     select plr.rule_mode            id_flex_num
11945     from   pay_legislation_rules    plr,
11946            per_business_groups_perf pgr
11947     where  plr.legislation_code  = pgr.legislation_code
11948     and    pgr.business_group_id = l_business_group_id
11949     and    plr.rule_type         = 'CWK_S'
11950     and    exists
11951           (select 1
11952            from   fnd_segment_attribute_values fsav
11953            where  to_char(fsav.id_flex_num)    = plr.rule_mode  --Fix For Bug 12813119
11954            and    fsav.application_id          = 800
11955            and    fsav.id_flex_code            = 'SCL'
11956            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
11957            and    fsav.attribute_value         = 'Y')
11958     and    exists
11959           (select 1
11960            from   pay_legislation_rules        plr2
11961            where  plr2.legislation_code        = plr.legislation_code
11962            and    plr2.rule_type               = 'CWK_SDL'
11963            and    plr2.rule_mode               = 'A') ;
11964 
11965 	      --start code for bug 6961562
11966 		l_installed          boolean;
11967 		l_po_installed      VARCHAR2(1);
11968 		l_industry           VARCHAR2(1);
11969 		l_vendor_id_1      number default null;
11970 		l_vendor_site_id_1      number default null;
11971 
11972 		cursor po_cwk is
11973 		select vendor_id,vendor_site_id from
11974 		per_all_assignments_f paf
11975 		where paf.assignment_id = p_assignment_id
11976 		and nvl(l_effective_date,sysdate) between paf.effective_start_date
11977 		and paf.effective_end_date;
11978 	     --end code for bug 6961562
11979 
11980   --
11981 BEGIN
11982   --
11983  if g_debug then
11984   hr_utility.set_location('Entering:'|| l_proc, 5);
11985  end if;
11986   --
11987   -- Truncate date and date_probation_end values, effectively removing time element.
11988   --
11989   l_effective_date     := trunc(p_effective_date);
11990   l_projected_assignment_end := trunc(p_projected_assignment_end);
11991   --
11992   l_object_version_number := p_object_version_number;
11993   --
11994   -- Bug 944911 - changed p_concatenated_segments to p_concat_segments
11995   --
11996   l_old_conc_segments := p_concat_segments;
11997   --
11998   -- Issue a savepoint.
11999   --
12000   SAVEPOINT update_cwk_asg;
12001   --
12002   BEGIN
12003     --
12004     -- Start of API User Hook for the before hook of update_emp_asg
12005     --
12006     hr_assignment_bkm.update_cwk_asg_b
12007       (p_effective_date               => l_effective_date
12008       ,p_datetrack_update_mode        => p_datetrack_update_mode
12009       ,p_assignment_id                => p_assignment_id
12010       ,p_object_version_number        => p_object_version_number
12011       ,p_assignment_category		  => p_assignment_category
12012       ,p_assignment_number            => p_assignment_number
12013       ,p_change_reason                => p_change_reason
12014       ,p_comments                     => p_comments
12015       ,p_default_code_comb_id         => p_default_code_comb_id
12016       ,p_establishment_id             => p_establishment_id
12017       ,p_frequency                    => p_frequency
12018       ,p_internal_address_line        => p_internal_address_line
12019       ,p_labour_union_member_flag     => p_labour_union_member_flag
12020       ,p_manager_flag                 => p_manager_flag
12021       ,p_normal_hours                 => p_normal_hours
12022       ,p_project_title				  => p_project_title
12023       ,p_set_of_books_id              => p_set_of_books_id
12024       ,p_source_type                  => p_source_type
12025       ,p_supervisor_id                => p_supervisor_id
12026       ,p_time_normal_finish           => p_time_normal_finish
12027       ,p_time_normal_start            => p_time_normal_start
12028       ,p_title                        => p_title
12029       ,p_vendor_assignment_number     => p_vendor_assignment_number
12030       ,p_vendor_employee_number       => p_vendor_employee_number
12031       ,p_vendor_id                    => p_vendor_id
12032       ,p_vendor_site_id               => p_vendor_site_id
12033       ,p_po_header_id                 => p_po_header_id
12034       ,p_po_line_id                   => p_po_line_id
12035       ,p_projected_assignment_end     => l_projected_assignment_end
12036       ,p_assignment_status_type_id    => p_assignment_status_type_id
12037       ,p_attribute_category           => p_attribute_category
12038       ,p_attribute1                   => p_attribute1
12039       ,p_attribute2                   => p_attribute2
12040       ,p_attribute3                   => p_attribute3
12041       ,p_attribute4                   => p_attribute4
12042       ,p_attribute5                   => p_attribute5
12043       ,p_attribute6                   => p_attribute6
12044       ,p_attribute7                   => p_attribute7
12045       ,p_attribute8                   => p_attribute8
12046       ,p_attribute9                   => p_attribute9
12047       ,p_attribute10                  => p_attribute10
12048       ,p_attribute11                  => p_attribute11
12049       ,p_attribute12                  => p_attribute12
12050       ,p_attribute13                  => p_attribute13
12051       ,p_attribute14                  => p_attribute14
12052       ,p_attribute15                  => p_attribute15
12053       ,p_attribute16                  => p_attribute16
12054       ,p_attribute17                  => p_attribute17
12055       ,p_attribute18                  => p_attribute18
12056       ,p_attribute19                  => p_attribute19
12057       ,p_attribute20                  => p_attribute20
12058       ,p_attribute21                  => p_attribute21
12059       ,p_attribute22                  => p_attribute22
12060       ,p_attribute23                  => p_attribute23
12061       ,p_attribute24                  => p_attribute24
12062       ,p_attribute25                  => p_attribute25
12063       ,p_attribute26                  => p_attribute26
12064       ,p_attribute27                  => p_attribute27
12065       ,p_attribute28                  => p_attribute28
12066       ,p_attribute29                  => p_attribute29
12067       ,p_attribute30                  => p_attribute30
12068       ,p_scl_segment1                 => p_scl_segment1
12069       ,p_scl_segment2                 => p_scl_segment2
12070       ,p_scl_segment3                 => p_scl_segment3
12071       ,p_scl_segment4                 => p_scl_segment4
12072       ,p_scl_segment5                 => p_scl_segment5
12073       ,p_scl_segment6                 => p_scl_segment6
12074       ,p_scl_segment7                 => p_scl_segment7
12075       ,p_scl_segment8                 => p_scl_segment8
12076       ,p_scl_segment9                 => p_scl_segment9
12077       ,p_scl_segment10                => p_scl_segment10
12078       ,p_scl_segment11                => p_scl_segment11
12079       ,p_scl_segment12                => p_scl_segment12
12080       ,p_scl_segment13                => p_scl_segment13
12081       ,p_scl_segment14                => p_scl_segment14
12082       ,p_scl_segment15                => p_scl_segment15
12083       ,p_scl_segment16                => p_scl_segment16
12084       ,p_scl_segment17                => p_scl_segment17
12085       ,p_scl_segment18                => p_scl_segment18
12086       ,p_scl_segment19                => p_scl_segment19
12087       ,p_scl_segment20                => p_scl_segment20
12088       ,p_scl_segment21                => p_scl_segment21
12089       ,p_scl_segment22                => p_scl_segment22
12090       ,p_scl_segment23                => p_scl_segment23
12091       ,p_scl_segment24                => p_scl_segment24
12092       ,p_scl_segment25                => p_scl_segment25
12093       ,p_scl_segment26                => p_scl_segment26
12094       ,p_scl_segment27                => p_scl_segment27
12095       ,p_scl_segment28                => p_scl_segment28
12096       ,p_scl_segment29                => p_scl_segment29
12097       ,p_scl_segment30                => p_scl_segment30
12098       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
12099       );
12100     --
12101   EXCEPTION
12102     --
12103     WHEN hr_api.cannot_find_prog_unit THEN
12104 	  --
12105       hr_api.cannot_find_prog_unit_error
12106         (p_module_name => 'UPDATE_CWK_ASG'
12107         ,p_hook_type   => 'BP'
12108         );
12109       --
12110       -- End of API User Hook for the before hook of update_emp_asg
12111       --
12112   END;
12113   --
12114  if g_debug then
12115   hr_utility.set_location(l_proc, 10);
12116  end if;
12117   --
12118   -- Validation in addition to Table Handlers
12119   --
12120   -- Get assignment type.
12121   --
12122   hr_api.mandatory_arg_error
12123     (p_api_name       => l_proc
12124     ,p_argument       => 'assignment_id'
12125     ,p_argument_value => p_assignment_id);
12126   --
12127   hr_api.mandatory_arg_error
12128     (p_api_name       => l_proc
12129     ,p_argument       => 'effective_date'
12130     ,p_argument_value => l_effective_date);
12131   --
12132   OPEN  csr_get_assignment_type;
12133   FETCH csr_get_assignment_type
12134    INTO l_assignment_type
12135       , l_business_group_id
12136       , l_soft_coding_keyflex_id
12137       , l_organization_id
12138       , l_location_id;
12139   --
12140   IF csr_get_assignment_type%NOTFOUND THEN
12141     --
12142     CLOSE csr_get_assignment_type;
12143 	--
12144     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
12145     hr_utility.raise_error;
12146 	--
12147   END IF;
12148   --
12149   CLOSE csr_get_assignment_type;
12150   --
12151  if g_debug then
12152   hr_utility.set_location(l_proc, 20);
12153  end if;
12154   --
12155   IF l_assignment_type <> 'C' THEN
12156     --
12157 	hr_utility.set_message(801,'HR_289575_ASG_ASG_NOT_EMP');
12158     hr_utility.raise_error;
12159 	--
12160   END IF;
12161   --
12162  if g_debug then
12163   hr_utility.set_location(l_proc, 21);
12164  end if;
12165   --
12166   --added validation for bug 1867720
12167   --
12168   IF p_assignment_status_type_id <> hr_api.g_number THEN
12169     --
12170     OPEN csr_old_asg_status;
12171     FETCH csr_old_asg_status INTO l_old_asg_status;
12172     CLOSE csr_old_asg_status;
12173     --
12174     OPEN csr_new_asg_status;
12175     FETCH csr_new_asg_status INTO l_new_asg_status;
12176 	--
12177     IF csr_new_asg_status%notfound OR
12178 	  (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status) THEN
12179 	  --
12180       fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
12181       fnd_message.set_token('SYSTYPE',l_old_asg_status);
12182       fnd_message.raise_error;
12183 	  --
12184     END IF;
12185 	--
12186     CLOSE csr_new_asg_status;
12187 	--
12188   END IF;
12189   --
12190   -- insert the profile options and effective date for the flexfield
12191   -- validation to work
12192   --
12193   hr_kflex_utility.set_profiles
12194     (p_business_group_id => l_business_group_id
12195     ,p_assignment_id     => p_assignment_id
12196     ,p_organization_id   => l_organization_id
12197     ,p_location_id       => l_location_id);
12198   --
12199   hr_kflex_utility.set_session_date
12200     (p_effective_date => l_effective_date
12201     ,p_session_id     => l_session_id);
12202   --
12203   -- Bug 944911
12204   -- Added to next 2 ifs check for p_concatenated_segments also
12205   --
12206   if   p_scl_segment1 <> hr_api.g_varchar2
12207     or p_scl_segment2 <> hr_api.g_varchar2
12208     or p_scl_segment3 <> hr_api.g_varchar2
12209     or p_scl_segment4 <> hr_api.g_varchar2
12210     or p_scl_segment5 <> hr_api.g_varchar2
12211     or p_scl_segment6 <> hr_api.g_varchar2
12212     or p_scl_segment7 <> hr_api.g_varchar2
12213     or p_scl_segment8 <> hr_api.g_varchar2
12214     or p_scl_segment9 <> hr_api.g_varchar2
12215     or p_scl_segment10 <> hr_api.g_varchar2
12216     or p_scl_segment11 <> hr_api.g_varchar2
12217     or p_scl_segment12 <> hr_api.g_varchar2
12218     or p_scl_segment13 <> hr_api.g_varchar2
12219     or p_scl_segment14 <> hr_api.g_varchar2
12220     or p_scl_segment15 <> hr_api.g_varchar2
12221     or p_scl_segment16 <> hr_api.g_varchar2
12222     or p_scl_segment17 <> hr_api.g_varchar2
12223     or p_scl_segment18 <> hr_api.g_varchar2
12224     or p_scl_segment19 <> hr_api.g_varchar2
12225     or p_scl_segment20 <> hr_api.g_varchar2
12226     or p_scl_segment21 <> hr_api.g_varchar2
12227     or p_scl_segment22 <> hr_api.g_varchar2
12228     or p_scl_segment23 <> hr_api.g_varchar2
12229     or p_scl_segment24 <> hr_api.g_varchar2
12230     or p_scl_segment25 <> hr_api.g_varchar2
12231     or p_scl_segment26 <> hr_api.g_varchar2
12232     or p_scl_segment27 <> hr_api.g_varchar2
12233     or p_scl_segment28 <> hr_api.g_varchar2
12234     or p_scl_segment29 <> hr_api.g_varchar2
12235     or p_scl_segment30 <> hr_api.g_varchar2
12236     -- bug 944911
12237     -- changed p_concatenated_segments to p_concat_segments
12238     or p_concat_segments <> hr_api.g_varchar2 then
12239     --
12240     OPEN csr_scl_idsel;
12241     FETCH csr_scl_idsel INTO l_flex_num;
12242     --
12243     IF csr_scl_idsel%NOTFOUND THEN
12244 	  --
12245       CLOSE csr_scl_idsel;
12246 	  --
12247       if   p_scl_segment1 is not null
12248         or p_scl_segment2 is not null
12249         or p_scl_segment3 is not null
12250         or p_scl_segment4 is not null
12251         or p_scl_segment5 is not null
12252         or p_scl_segment6 is not null
12253         or p_scl_segment7 is not null
12254         or p_scl_segment8 is not null
12255         or p_scl_segment9 is not null
12256         or p_scl_segment10 is not null
12257         or p_scl_segment11 is not null
12258         or p_scl_segment12 is not null
12259         or p_scl_segment13 is not null
12260         or p_scl_segment14 is not null
12261         or p_scl_segment15 is not null
12262         or p_scl_segment16 is not null
12263         or p_scl_segment17 is not null
12264         or p_scl_segment18 is not null
12265         or p_scl_segment19 is not null
12266         or p_scl_segment20 is not null
12267         or p_scl_segment21 is not null
12268         or p_scl_segment22 is not null
12269         or p_scl_segment23 is not null
12270         or p_scl_segment24 is not null
12271         or p_scl_segment25 is not null
12272         or p_scl_segment26 is not null
12273         or p_scl_segment27 is not null
12274         or p_scl_segment28 is not null
12275         or p_scl_segment29 is not null
12276         or p_scl_segment30 is not null
12277         or p_concat_segments is not null then
12278         --
12279         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
12280         hr_utility.set_message_token('PROCEDURE', l_proc);
12281         hr_utility.set_message_token('STEP','5');
12282         hr_utility.raise_error;
12283 		--
12284       END IF;
12285 	  --
12286     ELSE
12287 	  --
12288       CLOSE csr_scl_idsel;
12289       --
12290       -- Process Logic
12291       --
12292       -- Update or select the soft_coding_keyflex_id
12293       --
12294       hr_kflex_utility.upd_or_sel_keyflex_comb
12295       (p_appl_short_name        => 'PER'
12296       ,p_flex_code              => 'SCL'
12297       ,p_flex_num               => l_flex_num
12298       ,p_segment1               => p_scl_segment1
12299       ,p_segment2               => p_scl_segment2
12300       ,p_segment3               => p_scl_segment3
12301       ,p_segment4               => p_scl_segment4
12302       ,p_segment5               => p_scl_segment5
12303       ,p_segment6               => p_scl_segment6
12304       ,p_segment7               => p_scl_segment7
12305       ,p_segment8               => p_scl_segment8
12306       ,p_segment9               => p_scl_segment9
12307       ,p_segment10              => p_scl_segment10
12308       ,p_segment11              => p_scl_segment11
12309       ,p_segment12              => p_scl_segment12
12310       ,p_segment13              => p_scl_segment13
12311       ,p_segment14              => p_scl_segment14
12312       ,p_segment15              => p_scl_segment15
12313       ,p_segment16              => p_scl_segment16
12314       ,p_segment17              => p_scl_segment17
12315       ,p_segment18              => p_scl_segment18
12316       ,p_segment19              => p_scl_segment19
12317       ,p_segment20              => p_scl_segment20
12318       ,p_segment21              => p_scl_segment21
12319       ,p_segment22              => p_scl_segment22
12320       ,p_segment23              => p_scl_segment23
12321       ,p_segment24              => p_scl_segment24
12322       ,p_segment25              => p_scl_segment25
12323       ,p_segment26              => p_scl_segment26
12324       ,p_segment27              => p_scl_segment27
12325       ,p_segment28              => p_scl_segment28
12326       ,p_segment29              => p_scl_segment29
12327       ,p_segment30              => p_scl_segment30
12328       ,p_concat_segments_in     => l_old_conc_segments
12329       ,p_ccid                   => l_soft_coding_keyflex_id
12330       ,p_concat_segments_out    => l_concatenated_segments
12331       );
12332       --
12333       -- update the combinations column
12334       --
12335       update_scl_concat_segs
12336         (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
12337         ,p_concatenated_segments   => l_concatenated_segments);
12338       --
12339     END IF;
12340   --
12341   END IF;
12342 
12343  if g_debug then
12344   hr_utility.set_location(l_proc, 22);
12345  end if;
12346 
12347   --
12348   -- Default the PO Header if the line is passed in and the
12349   -- header is not.
12350   --
12351   IF p_po_line_id IS NOT NULL AND l_po_header_id IS NULL THEN
12352 
12353     l_po_header_id := get_po_for_line
12354       (p_po_line_id => p_po_line_id);
12355 
12356   END IF;
12357 
12358   --
12359   -- Default the Supplier if the Site is entered and Supplier is not.
12360   --
12361   IF p_vendor_site_id IS NOT NULL AND l_vendor_id IS NULL THEN
12362 
12363     l_vendor_id := get_supplier_for_site
12364       (p_vendor_site_id => p_vendor_site_id);
12365 
12366   END IF;
12367 
12368 
12369    --start code for bug 6961562
12370   -- PO
12371   l_installed := fnd_installation.get(appl_id => 210
12372 		,dep_appl_id => 210
12373           ,status => l_po_installed
12374           ,industry => l_industry);
12375 
12376   if l_po_installed <> 'N' then
12377     open po_cwk;
12378     fetch po_cwk into l_vendor_id_1,l_vendor_site_id_1;
12379     if po_cwk%found then
12380     if (l_vendor_id_1 <> p_vendor_id)
12381     or (l_vendor_site_id_1 <> p_vendor_site_id) then
12382 	PO_HR_INTERFACE_PVT.is_Supplier_Updatable( p_assignment_id => p_assignment_id,
12383                                                p_effective_date => l_effective_date );
12384         end if;
12385      end if;
12386      close po_cwk;
12387   end if;
12388   --end code for bug 6961562
12389 
12390 
12391  if g_debug then
12392   hr_utility.set_location(l_proc, 23);
12393  end if;
12394 
12395   /*
12396   --
12397  if g_debug then
12398   hr_utility.set_location(l_proc, 24);
12399  end if;
12400   --
12401   -- Update or select the cagr_grade_def_id
12402   --
12403   -- need to call the lck procedure early, to fetch the old value of cagr_id_flex_num
12404   -- before passing it into the hr_cgd_upd.upd_or_sel function.
12405   -- This is because the user may be updating a grade definition, but not changing
12406   -- or specifying the cagr_id_flex_num (ie the grade structure).
12407   -- Also, need to fetch the old cagr_grade_def_id, as the user may be updating some
12408   -- segments, and not changing others. Passing cagr_grade_id into the hr_cgd_upd.upd_or_sel
12409   -- function allows that function to derive the old values.
12410   --
12411   l_cagr_id_flex_num  := p_cagr_id_flex_num;
12412    --
12413   If (p_cagr_id_flex_num  = hr_api.g_number) THEN
12414     --
12415     per_asg_shd.lck
12416       (p_effective_date          => l_effective_date,
12417        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
12418        p_datetrack_mode          => p_datetrack_update_mode,
12419        p_assignment_id           => p_assignment_id,
12420        p_object_version_number   => p_object_version_number,
12421        p_validation_start_date   => l_unused_start_date,
12422        p_validation_end_date     => l_unused_end_date
12423        );
12424 	--
12425     l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
12426     l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
12427 	--
12428   End if;
12429   --
12430   hr_cgd_upd.upd_or_sel
12431     (p_segment1               => p_cag_segment1
12432     ,p_segment2               => p_cag_segment2
12433     ,p_segment3               => p_cag_segment3
12434     ,p_segment4               => p_cag_segment4
12435     ,p_segment5               => p_cag_segment5
12436     ,p_segment6               => p_cag_segment6
12437     ,p_segment7               => p_cag_segment7
12438     ,p_segment8               => p_cag_segment8
12439     ,p_segment9               => p_cag_segment9
12440     ,p_segment10              => p_cag_segment10
12441     ,p_segment11              => p_cag_segment11
12442     ,p_segment12              => p_cag_segment12
12443     ,p_segment13              => p_cag_segment13
12444     ,p_segment14              => p_cag_segment14
12445     ,p_segment15              => p_cag_segment15
12446     ,p_segment16              => p_cag_segment16
12447     ,p_segment17              => p_cag_segment17
12448     ,p_segment18              => p_cag_segment18
12449     ,p_segment19              => p_cag_segment19
12450     ,p_segment20              => p_cag_segment20
12451     ,p_id_flex_num            => l_cagr_id_flex_num
12452     ,p_business_group_id      => l_business_group_id
12453     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
12454     ,p_concatenated_segments  => l_cagr_concatenated_segments);
12455   --
12456   */
12457  if g_debug then
12458   hr_utility.set_location(l_proc, 25);
12459  end if;
12460   --
12461   -- Update assignment.
12462   --
12463   per_asg_upd.upd
12464     (p_assignment_id                => p_assignment_id
12465     ,p_effective_start_date         => l_effective_start_date
12466     ,p_effective_end_date           => l_effective_end_date
12467     ,p_business_group_id            => l_business_group_id
12468     ,p_assignment_status_type_id    => p_assignment_status_type_id
12469     ,p_supervisor_id                => p_supervisor_id
12470     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
12471     ,p_assignment_number            => p_assignment_number
12472     ,p_employment_category          => p_assignment_category
12473     ,p_change_reason                => p_change_reason
12474     ,p_comment_id                   => l_comment_id
12475     ,p_comments                     => p_comments
12476     --,p_date_probation_end           => l_date_probation_end
12477     ,p_default_code_comb_id         => p_default_code_comb_id
12478     ,p_frequency                    => p_frequency
12479     ,p_internal_address_line        => p_internal_address_line
12480     ,p_manager_flag                 => p_manager_flag
12481     ,p_normal_hours                 => p_normal_hours
12482     ,p_project_title                => p_project_title
12483     --,p_perf_review_period           => p_perf_review_period
12484     --,p_perf_review_period_frequency => p_perf_review_period_frequency
12485     --,p_probation_period             => p_probation_period
12486     --,p_probation_unit               => p_probation_unit
12487     --,p_sal_review_period            => p_sal_review_period
12488     --,p_sal_review_period_frequency  => p_sal_review_period_frequency
12489     ,p_set_of_books_id              => p_set_of_books_id
12490     ,p_source_type                  => p_source_type
12491     ,p_time_normal_finish           => p_time_normal_finish
12492     ,p_time_normal_start            => p_time_normal_start
12493     --,p_bargaining_unit_code         => p_bargaining_unit_code
12494     ,p_labour_union_member_flag     => p_labour_union_member_flag
12495     --,p_hourly_salaried_code         => p_hourly_salaried_code
12496     ,p_ass_attribute_category       => p_attribute_category
12497     ,p_ass_attribute1               => p_attribute1
12498     ,p_ass_attribute2               => p_attribute2
12499     ,p_ass_attribute3               => p_attribute3
12500     ,p_ass_attribute4               => p_attribute4
12501     ,p_ass_attribute5               => p_attribute5
12502     ,p_ass_attribute6               => p_attribute6
12503     ,p_ass_attribute7               => p_attribute7
12504     ,p_ass_attribute8               => p_attribute8
12505     ,p_ass_attribute9               => p_attribute9
12506     ,p_ass_attribute10              => p_attribute10
12507     ,p_ass_attribute11              => p_attribute11
12508     ,p_ass_attribute12              => p_attribute12
12509     ,p_ass_attribute13              => p_attribute13
12510     ,p_ass_attribute14              => p_attribute14
12511     ,p_ass_attribute15              => p_attribute15
12512     ,p_ass_attribute16              => p_attribute16
12513     ,p_ass_attribute17              => p_attribute17
12514     ,p_ass_attribute18              => p_attribute18
12515     ,p_ass_attribute19              => p_attribute19
12516     ,p_ass_attribute20              => p_attribute20
12517     ,p_ass_attribute21              => p_attribute21
12518     ,p_ass_attribute22              => p_attribute22
12519     ,p_ass_attribute23              => p_attribute23
12520     ,p_ass_attribute24              => p_attribute24
12521     ,p_ass_attribute25              => p_attribute25
12522     ,p_ass_attribute26              => p_attribute26
12523     ,p_ass_attribute27              => p_attribute27
12524     ,p_ass_attribute28              => p_attribute28
12525     ,p_ass_attribute29              => p_attribute29
12526     ,p_ass_attribute30              => p_attribute30
12527     --,p_notice_period		        => p_notice_period
12528     --,p_notice_period_uom	        => p_notice_period_uom
12529     --,p_employee_category	        => p_employee_category
12530     --,p_work_at_home		            => p_work_at_home
12531     --,p_job_post_source_name	        => p_job_post_source_name
12532     ,p_title                        => p_title
12533     ,p_vendor_assignment_number     => p_vendor_assignment_number
12534     ,p_vendor_employee_number       => p_vendor_employee_number
12535     ,p_vendor_id                    => l_vendor_id
12536     ,p_vendor_site_id               => p_vendor_site_id
12537     ,p_po_header_id                 => l_po_header_id
12538     ,p_po_line_id                   => p_po_line_id
12539     ,p_projected_assignment_end     => l_projected_assignment_end
12540     ,p_payroll_id_updated           => l_payroll_id_updated
12541     ,p_other_manager_warning        => l_other_manager_warning
12542     ,p_no_managers_warning          => l_no_managers_warning
12543     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
12544     ,p_validation_start_date        => l_validation_start_date
12545     ,p_validation_end_date          => l_validation_end_date
12546     ,p_object_version_number        => l_object_version_number
12547     ,p_effective_date               => l_effective_date
12548     ,p_datetrack_mode               => p_datetrack_update_mode
12549     --,p_contract_id                  => p_contract_id
12550     ,p_establishment_id             => p_establishment_id
12551     --,p_collective_agreement_id      => p_collective_agreement_id
12552     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
12553     --,p_cagr_id_flex_num             => p_cagr_id_flex_num
12554     ,p_validate                     => FALSE
12555     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
12556     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
12557     );
12558   --
12559  if g_debug then
12560   hr_utility.set_location(l_proc, 26);
12561  end if;
12562   --
12563   BEGIN
12564     --
12565     -- Start of API User Hook for the after hook of update_cwk_asg
12566     --
12567     hr_assignment_bkm.update_cwk_asg_a
12568       (p_effective_date               => l_effective_date
12569       ,p_datetrack_update_mode        => p_datetrack_update_mode
12570       ,p_assignment_id                => p_assignment_id
12571       ,p_object_version_number        => p_object_version_number
12572       ,p_assignment_category		  => p_assignment_category
12573       ,p_assignment_number            => p_assignment_number
12574       ,p_change_reason                => p_change_reason
12575       ,p_comments                     => p_comments
12576       ,p_default_code_comb_id         => p_default_code_comb_id
12577       ,p_establishment_id             => p_establishment_id
12578       ,p_frequency                    => p_frequency
12579       ,p_internal_address_line        => p_internal_address_line
12580       ,p_labour_union_member_flag     => p_labour_union_member_flag
12581       ,p_manager_flag                 => p_manager_flag
12582       ,p_normal_hours                 => p_normal_hours
12583       ,p_project_title				  => p_project_title
12584       ,p_set_of_books_id              => p_set_of_books_id
12585       ,p_source_type                  => p_source_type
12586       ,p_supervisor_id                => p_supervisor_id
12587       ,p_time_normal_finish           => p_time_normal_finish
12588       ,p_time_normal_start            => p_time_normal_start
12589       ,p_title                        => p_title
12590       ,p_vendor_assignment_number     => p_vendor_assignment_number
12591       ,p_vendor_employee_number       => p_vendor_employee_number
12592       ,p_vendor_id                    => l_vendor_id
12593       ,p_vendor_site_id               => p_vendor_site_id
12594       ,p_po_header_id                 => l_po_header_id
12595       ,p_po_line_id                   => p_po_line_id
12596       ,p_projected_assignment_end     => l_projected_assignment_end
12597       ,p_assignment_status_type_id    => p_assignment_status_type_id
12598       ,p_attribute_category           => p_attribute_category
12599       ,p_attribute1                   => p_attribute1
12600       ,p_attribute2                   => p_attribute2
12601       ,p_attribute3                   => p_attribute3
12602       ,p_attribute4                   => p_attribute4
12603       ,p_attribute5                   => p_attribute5
12604       ,p_attribute6                   => p_attribute6
12605       ,p_attribute7                   => p_attribute7
12606       ,p_attribute8                   => p_attribute8
12607       ,p_attribute9                   => p_attribute9
12608       ,p_attribute10                  => p_attribute10
12609       ,p_attribute11                  => p_attribute11
12610       ,p_attribute12                  => p_attribute12
12611       ,p_attribute13                  => p_attribute13
12612       ,p_attribute14                  => p_attribute14
12613       ,p_attribute15                  => p_attribute15
12614       ,p_attribute16                  => p_attribute16
12615       ,p_attribute17                  => p_attribute17
12616       ,p_attribute18                  => p_attribute18
12617       ,p_attribute19                  => p_attribute19
12618       ,p_attribute20                  => p_attribute20
12619       ,p_attribute21                  => p_attribute21
12620       ,p_attribute22                  => p_attribute22
12621       ,p_attribute23                  => p_attribute23
12622       ,p_attribute24                  => p_attribute24
12623       ,p_attribute25                  => p_attribute25
12624       ,p_attribute26                  => p_attribute26
12625       ,p_attribute27                  => p_attribute27
12626       ,p_attribute28                  => p_attribute28
12627       ,p_attribute29                  => p_attribute29
12628       ,p_attribute30                  => p_attribute30
12629       ,p_scl_segment1                 => p_scl_segment1
12630       ,p_scl_segment2                 => p_scl_segment2
12631       ,p_scl_segment3                 => p_scl_segment3
12632       ,p_scl_segment4                 => p_scl_segment4
12633       ,p_scl_segment5                 => p_scl_segment5
12634       ,p_scl_segment6                 => p_scl_segment6
12635       ,p_scl_segment7                 => p_scl_segment7
12636       ,p_scl_segment8                 => p_scl_segment8
12637       ,p_scl_segment9                 => p_scl_segment9
12638       ,p_scl_segment10                => p_scl_segment10
12639       ,p_scl_segment11                => p_scl_segment11
12640       ,p_scl_segment12                => p_scl_segment12
12641       ,p_scl_segment13                => p_scl_segment13
12642       ,p_scl_segment14                => p_scl_segment14
12643       ,p_scl_segment15                => p_scl_segment15
12644       ,p_scl_segment16                => p_scl_segment16
12645       ,p_scl_segment17                => p_scl_segment17
12646       ,p_scl_segment18                => p_scl_segment18
12647       ,p_scl_segment19                => p_scl_segment19
12648       ,p_scl_segment20                => p_scl_segment20
12649       ,p_scl_segment21                => p_scl_segment21
12650       ,p_scl_segment22                => p_scl_segment22
12651       ,p_scl_segment23                => p_scl_segment23
12652       ,p_scl_segment24                => p_scl_segment24
12653       ,p_scl_segment25                => p_scl_segment25
12654       ,p_scl_segment26                => p_scl_segment26
12655       ,p_scl_segment27                => p_scl_segment27
12656       ,p_scl_segment28                => p_scl_segment28
12657       ,p_scl_segment29                => p_scl_segment29
12658       ,p_scl_segment30                => p_scl_segment30
12659       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
12660       ,p_effective_start_date         => l_effective_start_date
12661       ,p_effective_end_date           => l_effective_end_date
12662       ,p_comment_id                   => l_comment_id
12663       ,p_no_managers_warning          => l_no_managers_warning
12664       ,p_other_manager_warning        => l_other_manager_warning
12665       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
12666       ,p_concatenated_segments        => l_concatenated_segments
12667       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
12668       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
12669     );
12670     --
12671   EXCEPTION
12672     --
12673     WHEN hr_api.cannot_find_prog_unit THEN
12674 	  --
12675       hr_api.cannot_find_prog_unit_error
12676         (p_module_name => 'UPDATE_CWK_ASG'
12677         ,p_hook_type   => 'AP'
12678         );
12679       --
12680       -- End of API User Hook for the after hook of update_cwk_asg
12681       --
12682   END;
12683   --
12684   -- When in validation only mode raise the Validate_Enabled exception
12685   --
12686   IF p_validate THEN
12687     --
12688     RAISE hr_api.validate_enabled;
12689 	--
12690   END IF;
12691   --
12692   -- Set all output arguments
12693   --
12694   p_object_version_number   := l_object_version_number;
12695   p_soft_coding_keyflex_id  := l_soft_coding_keyflex_id;
12696   p_comment_id              := l_comment_id;
12697   p_effective_start_date    := l_effective_start_date;
12698   p_effective_end_date      := l_effective_end_date;
12699   p_concatenated_segments   := l_concatenated_segments;
12700   p_no_managers_warning     := l_no_managers_warning;
12701   p_other_manager_warning   := l_other_manager_warning;
12702   p_hourly_salaried_warning := l_hourly_salaried_warning;
12703   --
12704   -- remove data from the session table
12705   --
12706   hr_kflex_utility.unset_session_date
12707     (p_session_id     => l_session_id);
12708   --
12709  if g_debug then
12710   hr_utility.set_location(' Leaving:'||l_proc, 999);
12711  end if;
12712   --
12713 EXCEPTION
12714   --
12715   WHEN hr_api.validate_enabled THEN
12716     --
12717     -- As the Validate_Enabled exception has been raised
12718     -- we must rollback to the savepoint
12719     --
12720     ROLLBACK TO update_cwk_asg;
12721     --
12722     -- Only set output warning arguments
12723     -- (Any key or derived arguments must be set to null
12724     -- when validation only mode is being used.)
12725     --
12726     p_object_version_number      := p_object_version_number;
12727     p_soft_coding_keyflex_id     := null;
12728     p_comment_id                 := null;
12729     p_effective_start_date       := null;
12730     p_effective_end_date         := null;
12731     p_concatenated_segments      := l_old_conc_segments;
12732     p_no_managers_warning        := l_no_managers_warning;
12733     p_other_manager_warning      := l_other_manager_warning;
12734     p_hourly_salaried_warning    := l_hourly_salaried_warning;
12735     --
12736   WHEN others THEN
12737     --
12738     -- A validation or unexpected error has occurred
12739     --
12740     -- Added as part of fix to bug 632479
12741     --
12742     p_object_version_number := lv_object_version_number;
12743 
12744     p_org_now_no_manager_warning      := null;
12745     p_effective_start_date            := null;
12746     p_effective_end_date              := null;
12747     p_comment_id                      := null;
12748     p_no_managers_warning             := null;
12749     p_other_manager_warning           := null;
12750     p_soft_coding_keyflex_id          := null;
12751     p_concatenated_segments           := null;
12752     p_hourly_salaried_warning         := null;
12753 
12754     ROLLBACK TO update_cwk_asg;
12755     RAISE;
12756     --
12757     -- End of fix.
12758     --
12759 END update_cwk_asg;
12760 --
12761 -- ----------------------------------------------------------------------------
12762 -- |---------------------< update_cwk_asg_criteria >--------------------------|
12763 -- ----------------------------------------------------------------------------
12764 --
12765 procedure update_cwk_asg_criteria
12766   (p_validate                     in     boolean
12767   ,p_effective_date               in     date
12768   ,p_datetrack_update_mode        in     varchar2
12769   ,p_assignment_id                in     number
12770   ,p_called_from_mass_update      in     boolean
12771   ,p_object_version_number        in out nocopy number
12772   ,p_grade_id                     in     number
12773   ,p_position_id                  in     number
12774   ,p_job_id                       in     number
12775   --
12776   -- p_payroll_id included for future phases of cwk
12777   --
12778   --,p_payroll_id                   in     number
12779   ,p_location_id                  in     number
12780   ,p_organization_id              in     number
12781   --
12782   -- p_pay_basis_id for future phases of cwk
12783   --
12784   ,p_pay_basis_id                 in     number
12785   ,p_segment1                     in     varchar2
12786   ,p_segment2                     in     varchar2
12787   ,p_segment3                     in     varchar2
12788   ,p_segment4                     in     varchar2
12789   ,p_segment5                     in     varchar2
12790   ,p_segment6                     in     varchar2
12791   ,p_segment7                     in     varchar2
12792   ,p_segment8                     in     varchar2
12793   ,p_segment9                     in     varchar2
12794   ,p_segment10                    in     varchar2
12795   ,p_segment11                    in     varchar2
12796   ,p_segment12                    in     varchar2
12797   ,p_segment13                    in     varchar2
12798   ,p_segment14                    in     varchar2
12799   ,p_segment15                    in     varchar2
12800   ,p_segment16                    in     varchar2
12801   ,p_segment17                    in     varchar2
12802   ,p_segment18                    in     varchar2
12803   ,p_segment19                    in     varchar2
12804   ,p_segment20                    in     varchar2
12805   ,p_segment21                    in     varchar2
12806   ,p_segment22                    in     varchar2
12807   ,p_segment23                    in     varchar2
12808   ,p_segment24                    in     varchar2
12809   ,p_segment25                    in     varchar2
12810   ,p_segment26                    in     varchar2
12811   ,p_segment27                    in     varchar2
12812   ,p_segment28                    in     varchar2
12813   ,p_segment29                    in     varchar2
12814   ,p_segment30                    in     varchar2
12815   ,p_concat_segments              in     varchar2
12816   ,p_people_group_name               out nocopy varchar2
12817   ,p_effective_start_date            out nocopy date
12818   ,p_effective_end_date              out nocopy date
12819   ,p_people_group_id                 out nocopy number
12820   ,p_org_now_no_manager_warning      out nocopy boolean
12821   ,p_other_manager_warning           out nocopy boolean
12822   ,p_spp_delete_warning              out nocopy boolean
12823   --
12824   -- p_entries_changed_warning included for future phases of cwk
12825   --
12826   ,p_entries_changed_warning         out nocopy varchar2
12827   ,p_tax_district_changed_warning    out nocopy boolean
12828   ) is
12829   --
12830   -- Declare cursors and local variables
12831   --
12832   -- Out variables
12833   --
12834   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
12835   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
12836   l_entries_changed_warning      varchar2(1) := 'N';
12837   l_people_group_name            pay_people_groups.group_name%TYPE;
12838   l_old_group_name               pay_people_groups.group_name%TYPE;
12839   l_no_managers_warning          boolean;
12840   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
12841   l_org_now_no_manager_warning   boolean;
12842   l_other_manager_warning        boolean;
12843   l_hourly_salaried_warning      boolean;
12844   l_payroll_id_updated           boolean;
12845   l_people_group_id              per_all_assignments_f.people_group_id%TYPE;
12846   l_spp_delete_warning           boolean := false; -- Bug 3545065
12847   l_tax_district_changed_warning boolean;
12848   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
12849   --
12850   l_api_updating                 boolean;
12851   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
12852   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
12853   l_entries_changed              varchar2(1);
12854   l_legislation_code             per_business_groups.legislation_code%TYPE;
12855   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
12856   l_proc                         varchar2(72) :=
12857                                        g_package || 'update_cwk_asg_criteria';
12858   l_validation_end_date          date;
12859   l_validation_start_date        date;
12860   l_effective_date               date;
12861   l_element_entry_id             number;
12862   l_organization_id              per_all_assignments_f.organization_id%type;
12863   l_location_id                  per_all_assignments_f.location_id%type;
12864   l_session_id                   number;
12865   l_assignment_type              per_all_assignments_f.assignment_type%TYPE;
12866   --
12867   lv_object_version_number     number := p_object_version_number ;
12868   l_grade_id                   number := Null; -- Bug 3545065
12869   --
12870 
12871   cursor csr_get_legislation_code is
12872     select bus.legislation_code
12873       from per_business_groups_perf bus
12874      where bus.business_group_id = l_business_group_id;
12875   --
12876   cursor csr_get_salary is
12877   select element_entry_id
12878   from   pay_element_entries_f
12879   where  assignment_id = p_assignment_id
12880   and    creator_type = 'SP'
12881   and    l_validation_start_date between
12882          effective_start_date and effective_end_date;
12883   --
12884   cursor csr_grp_idsel is
12885   select bus.people_group_structure
12886   from  per_business_groups_perf bus
12887   where bus.business_group_id = l_business_group_id;
12888   --
12889   cursor get_sec_date_range is
12890   select asg.effective_start_date
12891   ,      asg.effective_end_date
12892   from   per_all_assignments_f asg
12893   where  asg.assignment_id=p_assignment_id
12894   and   ((sysdate between asg.effective_start_date
12895           and asg.effective_end_date)
12896          or
12897          (sysdate<asg.effective_start_date
12898           and not exists
12899           (select 1
12900            from per_all_assignments_f asg2
12901            where asg2.person_id=asg.person_id
12902            and asg2.period_of_service_id=asg.period_of_service_id
12903            and asg2.effective_start_date<asg.effective_start_date)
12904          )
12905         );
12906   --
12907   cursor csr_get_assignment_type is
12908     select asg.assignment_type
12909       from per_all_assignments_f asg
12910      where asg.assignment_id = p_assignment_id
12911        and l_effective_date  between asg.effective_start_date
12912                              and     asg.effective_end_date;
12913   --
12914   l_sec_effective_start_date date;
12915   l_sec_effective_end_date date;
12916   --
12917   l_dt_update_mode     VARCHAR2(30);
12918   l_new_dt_update_mode VARCHAR2(30);
12919   --
12920   -- Start of bug 3553286
12921   l_job_id                       number := p_job_id;
12922   l_org_id                       number := p_organization_id;
12923   -- End of 3553286
12924 BEGIN
12925   --
12926  if g_debug then
12927   hr_utility.set_location('Entering:'|| l_proc, 1);
12928  end if;
12929   --
12930    IF p_called_from_mass_update THEN
12931     --
12932     if g_debug then
12933       hr_utility.set_location(l_proc,40);
12934     end if;
12935     --
12936     l_dt_update_mode     := 'CORRECTION';
12937     l_new_dt_update_mode := p_datetrack_update_mode;
12938     --
12939   ELSE
12940     --
12941     if g_debug then
12942       hr_utility.set_location(l_proc,50);
12943     end if;
12944     --
12945     l_dt_update_mode     := p_datetrack_update_mode;
12946     l_new_dt_update_mode := p_datetrack_update_mode;
12947     --
12948   END IF;
12949   --
12950   -- Truncate the p_effective_date value to remove time element.
12951   --
12952   l_effective_date := TRUNC(p_effective_date);
12953   --
12954   -- Bug 944911
12955   -- Made p_group_name to be out param
12956   -- and add p_concat_segment to be IN
12957   -- in case of sec_asg alone made p_pgp_concat_segments as in param
12958   -- Replaced p_group_name by p_concat_segments
12959   --
12960   l_old_group_name := p_concat_segments;
12961   --
12962   -- Issue a savepoint.
12963   --
12964   SAVEPOINT update_cwk_asg_criteria;
12965   --
12966   -- Check assignment is a cwk assignment
12967   --
12968   OPEN  csr_get_assignment_type;
12969   FETCH csr_get_assignment_type INTO l_assignment_type;
12970   --
12971   IF csr_get_assignment_type%NOTFOUND THEN
12972     --
12973     CLOSE csr_get_assignment_type;
12974 	--
12975     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
12976     hr_utility.raise_error;
12977 	--
12978   END IF;
12979   --
12980   CLOSE csr_get_assignment_type;
12981   --
12982  if g_debug then
12983   hr_utility.set_location(l_proc, 20);
12984  end if;
12985   --
12986   IF l_assignment_type <> 'C' THEN
12987     --
12988 	hr_utility.set_message(801,'HR_289575_ASG_ASG_NOT_EMP');
12989     hr_utility.raise_error;
12990 	--
12991   END IF;
12992   --
12993   BEGIN
12994     --
12995     -- Start of API User Hook for the before hook of update_emp_asg_criteria
12996     --
12997     hr_assignment_bko.update_cwk_asg_criteria_b
12998       (p_effective_date               => l_effective_date
12999       ,p_datetrack_update_mode        => l_dt_update_mode
13000       ,p_assignment_id                => p_assignment_id
13001       ,p_object_version_number        => p_object_version_number
13002       ,p_grade_id                     => l_grade_id -- Bug 3545065
13003       ,p_position_id                  => p_position_id
13004       ,p_job_id                       => p_job_id
13005       --,p_payroll_id                   => p_payroll_id
13006       ,p_location_id                  => p_location_id
13007       ,p_organization_id              => p_organization_id
13008       ,p_pay_basis_id                 => p_pay_basis_id
13009       ,p_segment1                     => p_segment1
13010       ,p_segment2                     => p_segment2
13011       ,p_segment3                     => p_segment3
13012       ,p_segment4                     => p_segment4
13013       ,p_segment5                     => p_segment5
13014       ,p_segment6                     => p_segment6
13015       ,p_segment7                     => p_segment7
13016       ,p_segment8                     => p_segment8
13017       ,p_segment9                     => p_segment9
13018       ,p_segment10                    => p_segment10
13019       ,p_segment11                    => p_segment11
13020       ,p_segment12                    => p_segment12
13021       ,p_segment13                    => p_segment13
13022       ,p_segment14                    => p_segment14
13023       ,p_segment15                    => p_segment15
13024       ,p_segment16                    => p_segment16
13025       ,p_segment17                    => p_segment17
13026       ,p_segment18                    => p_segment18
13027       ,p_segment19                    => p_segment19
13028       ,p_segment20                    => p_segment20
13029       ,p_segment21                    => p_segment21
13030       ,p_segment22                    => p_segment22
13031       ,p_segment23                    => p_segment23
13032       ,p_segment24                    => p_segment24
13033       ,p_segment25                    => p_segment25
13034       ,p_segment26                    => p_segment26
13035       ,p_segment27                    => p_segment27
13036       ,p_segment28                    => p_segment28
13037       ,p_segment29                    => p_segment29
13038       ,p_segment30                    => p_segment30
13039       ,p_concat_segments              => l_old_group_name);
13040   --
13041   EXCEPTION
13042     --
13043     WHEN hr_api.cannot_find_prog_unit THEN
13044 	  --
13045       hr_api.cannot_find_prog_unit_error
13046         (p_module_name => 'UPDATE_CWK_ASG_CRITERIA'
13047         ,p_hook_type   => 'BP');
13048     --
13049     -- End of API User Hook for the before hook of update_emp_cwk_criteria
13050     --
13051   END;
13052   --
13053  if g_debug then
13054   hr_utility.set_location(l_proc, 10);
13055  end if;
13056   --
13057   l_object_version_number := p_object_version_number;
13058   --
13059   -- Validation in addition to Table Handlers
13060   --
13061   -- Retrieve current assignment details from database.
13062   --
13063   l_api_updating := per_asg_shd.api_updating
13064     (p_assignment_id         => p_assignment_id
13065     ,p_effective_date        => l_effective_date
13066     ,p_object_version_number => l_object_version_number);
13067   --
13068  if g_debug then
13069   hr_utility.set_location(l_proc, 20);
13070  end if;
13071   --
13072   IF NOT l_api_updating THEN
13073     --
13074  if g_debug then
13075     hr_utility.set_location(l_proc, 30);
13076  end if;
13077     --
13078     -- As this is an updating API, the assignment should already exist.
13079     --
13080     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
13081     hr_utility.raise_error;
13082 	--
13083   ELSE
13084     --
13085  if g_debug then
13086     hr_utility.set_location(l_proc, 40);
13087  end if;
13088     --
13089     l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
13090 	--
13091   END IF;
13092   --
13093  if g_debug then
13094   hr_utility.set_location(l_proc, 50);
13095  end if;
13096   --
13097   -- Check that the assignment is an employee assignment.
13098   --
13099   IF per_asg_shd.g_old_rec.assignment_type <> 'C' THEN
13100     --
13101  if g_debug then
13102     hr_utility.set_location(l_proc, 60);
13103  end if;
13104     --
13105 	hr_utility.set_message(801, 'HR_289575_ASG_ASG_NOT_EMP');
13106     hr_utility.raise_error;
13107 	--
13108   END IF;
13109   --
13110  if g_debug then
13111   hr_utility.set_location(l_proc, 70);
13112  end if;
13113   --
13114   -- Process Logic
13115   --
13116   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
13117   --
13118   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
13119   --
13120   -- Start of bug fix 3553286
13121   -- This procedure will return the job_id and organization_id of a position
13122   --
13123   if (p_called_from_mass_update = TRUE and p_position_id is not null) then
13124      if (l_job_id is null) or (l_org_id is null) then
13125          hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
13126                                          l_job_id, l_org_id);
13127      end if;
13128   end if;
13129   -- End of 3553286
13130   -- insert the profile options and effective date for the flexfield
13131   -- validation to work
13132   --
13133   --
13134   IF (l_org_id = hr_api.g_number) THEN -- Bug 3553286
13135     --
13136     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
13137     --
13138   ELSE
13139     --
13140     l_organization_id := l_org_id; -- Bug 3553286
13141 	--
13142   END IF;
13143   --
13144   IF (p_location_id=hr_api.g_number) THEN
13145     --
13146     l_location_id:=per_asg_shd.g_old_rec.location_id;
13147 	--
13148   ELSE
13149     --
13150     l_location_id:=p_location_id;
13151 	--
13152   END IF;
13153   --
13154   hr_kflex_utility.set_profiles
13155     (p_business_group_id => l_business_group_id
13156     ,p_assignment_id     => p_assignment_id
13157     ,p_organization_id   => l_organization_id
13158     ,p_location_id       => l_location_id);
13159   --
13160   hr_kflex_utility.set_session_date
13161     (p_effective_date => l_effective_date
13162     ,p_session_id     => l_session_id);
13163   --
13164   OPEN csr_grp_idsel;
13165   FETCH csr_grp_idsel INTO l_flex_num;
13166   --
13167   IF csr_grp_idsel%NOTFOUND THEN
13168     --
13169     CLOSE csr_grp_idsel;
13170 	--
13171     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
13172     hr_utility.set_message_token('PROCEDURE', l_proc);
13173     hr_utility.set_message_token('STEP','5');
13174     hr_utility.raise_error;
13175 	--
13176   END IF;
13177   --
13178   CLOSE csr_grp_idsel;
13179   --
13180  if g_debug then
13181   hr_utility.set_location(l_proc, 120);
13182  end if;
13183   --
13184   -- Maintain the people group key flexfields.
13185   --
13186   -- Only call the flex code if a non-default value(includng null) is passed
13187   -- to the procedure.
13188   --
13189   if     nvl(p_segment1,'X')  <> hr_api.g_varchar2
13190       or nvl(p_segment2,'X')  <> hr_api.g_varchar2
13191       or nvl(p_segment3,'X')  <> hr_api.g_varchar2
13192       or nvl(p_segment4,'X')  <> hr_api.g_varchar2
13193       or nvl(p_segment5,'X')  <> hr_api.g_varchar2
13194       or nvl(p_segment6,'X')  <> hr_api.g_varchar2
13195       or nvl(p_segment7,'X')  <> hr_api.g_varchar2
13196       or nvl(p_segment8,'X')  <> hr_api.g_varchar2
13197       or nvl(p_segment9,'X')  <> hr_api.g_varchar2
13198       or nvl(p_segment10,'X') <> hr_api.g_varchar2
13199       or nvl(p_segment11,'X') <> hr_api.g_varchar2
13200       or nvl(p_segment12,'X') <> hr_api.g_varchar2
13201       or nvl(p_segment13,'X') <> hr_api.g_varchar2
13202       or nvl(p_segment14,'X') <> hr_api.g_varchar2
13203       or nvl(p_segment15,'X') <> hr_api.g_varchar2
13204       or nvl(p_segment16,'X') <> hr_api.g_varchar2
13205       or nvl(p_segment17,'X') <> hr_api.g_varchar2
13206       or nvl(p_segment18,'X') <> hr_api.g_varchar2
13207       or nvl(p_segment19,'X') <> hr_api.g_varchar2
13208       or nvl(p_segment20,'X') <> hr_api.g_varchar2
13209       or nvl(p_segment21,'X') <> hr_api.g_varchar2
13210       or nvl(p_segment22,'X') <> hr_api.g_varchar2
13211       or nvl(p_segment23,'X') <> hr_api.g_varchar2
13212       or nvl(p_segment24,'X') <> hr_api.g_varchar2
13213       or nvl(p_segment25,'X') <> hr_api.g_varchar2
13214       or nvl(p_segment26,'X') <> hr_api.g_varchar2
13215       or nvl(p_segment27,'X') <> hr_api.g_varchar2
13216       or nvl(p_segment28,'X') <> hr_api.g_varchar2
13217       or nvl(p_segment29,'X') <> hr_api.g_varchar2
13218       or nvl(p_segment30,'X') <> hr_api.g_varchar2
13219       or nvl(l_old_group_name,'X') <> hr_api.g_varchar2 THEN
13220     --
13221     hr_kflex_utility.upd_or_sel_keyflex_comb
13222     (p_appl_short_name        => 'PAY'
13223     ,p_flex_code              => 'GRP'
13224     ,p_flex_num               => l_flex_num
13225     ,p_segment1               => p_segment1
13226     ,p_segment2               => p_segment2
13227     ,p_segment3               => p_segment3
13228     ,p_segment4               => p_segment4
13229     ,p_segment5               => p_segment5
13230     ,p_segment6               => p_segment6
13231     ,p_segment7               => p_segment7
13232     ,p_segment8               => p_segment8
13233     ,p_segment9               => p_segment9
13234     ,p_segment10              => p_segment10
13235     ,p_segment11              => p_segment11
13236     ,p_segment12              => p_segment12
13237     ,p_segment13              => p_segment13
13238     ,p_segment14              => p_segment14
13239     ,p_segment15              => p_segment15
13240     ,p_segment16              => p_segment16
13241     ,p_segment17              => p_segment17
13242     ,p_segment18              => p_segment18
13243     ,p_segment19              => p_segment19
13244     ,p_segment20              => p_segment20
13245     ,p_segment21              => p_segment21
13246     ,p_segment22              => p_segment22
13247     ,p_segment23              => p_segment23
13248     ,p_segment24              => p_segment24
13249     ,p_segment25              => p_segment25
13250     ,p_segment26              => p_segment26
13251     ,p_segment27              => p_segment27
13252     ,p_segment28              => p_segment28
13253     ,p_segment29              => p_segment29
13254     ,p_segment30              => p_segment30
13255     ,p_concat_segments_in     => l_old_group_name
13256     ,p_ccid                   => l_people_group_id
13257     ,p_concat_segments_out    => l_people_group_name);
13258 	--
13259   END IF;
13260   --
13261  if g_debug then
13262   hr_utility.set_location(l_proc, 130);
13263  end if;
13264   --
13265   -- update the combinations column
13266   --
13267   update_pgp_concat_segs
13268     (p_people_group_id        => l_people_group_id
13269     ,p_group_name             => l_people_group_name);
13270   --
13271   -- Update assignment.
13272   --
13273   per_asg_upd.upd
13274     (p_assignment_id                => p_assignment_id
13275     ,p_effective_start_date         => l_effective_start_date
13276     ,p_effective_end_date           => l_effective_end_date
13277     ,p_business_group_id            => l_business_group_id
13278     -- Bug 3545065, Grade should not be maintained for CWK asg
13279     -- ,p_grade_id                     => p_grade_id
13280     ,p_position_id                  => p_position_id
13281     ,p_job_id                       => l_job_id -- Bug 3553286
13282 	--
13283 	-- Removed until used in a later phase of cwk
13284 	--
13285     --,p_payroll_id                   => p_payroll_id
13286     ,p_location_id                  => p_location_id
13287     ,p_organization_id              => l_org_id -- Bug 3553286
13288     ,p_people_group_id              => l_people_group_id
13289 	--
13290 	-- Removed until used in a later phase of cwk
13291 	--
13292     --,p_pay_basis_id                 => p_pay_basis_id
13293     ,p_comment_id                   => l_comment_id
13294     ,p_payroll_id_updated           => l_payroll_id_updated
13295     ,p_other_manager_warning        => l_other_manager_warning
13296     ,p_no_managers_warning          => l_no_managers_warning
13297     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
13298     ,p_validation_start_date        => l_validation_start_date
13299     ,p_validation_end_date          => l_validation_end_date
13300     ,p_object_version_number        => l_object_version_number
13301     ,p_effective_date               => l_effective_date
13302     ,p_datetrack_mode               => l_dt_update_mode
13303     ,p_validate                     => FALSE
13304     ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
13305   --
13306  if g_debug then
13307   hr_utility.set_location(l_proc, 140);
13308  end if;
13309   --
13310   -- add to the security lists if neccesary
13311   --
13312   OPEN get_sec_date_range;
13313   FETCH get_sec_date_range INTO l_sec_effective_start_date
13314                                ,l_sec_effective_end_date;
13315   CLOSE get_sec_date_range;
13316   --
13317   IF l_effective_date BETWEEN l_sec_effective_start_date AND
13318                               l_sec_effective_end_date THEN
13319     --
13320     IF (per_asg_shd.g_old_rec.organization_id = l_business_group_id AND
13321       l_org_id <> l_business_group_id) THEN -- Bug 3553286
13322       --
13323       hr_security_internal.clear_from_person_list
13324                             (per_asg_shd.g_old_rec.person_id);
13325       --
13326     END IF;
13327 	--
13328     hr_security_internal.add_to_person_list(l_effective_date,p_assignment_id);
13329 	--
13330   END IF;
13331   --
13332  if g_debug then
13333   hr_utility.set_location(l_proc, 145);
13334  end if;
13335   --
13336   -- Bug 560185 fix starts
13337   --
13338   -- Delete the SP element entry if there is one when the pay_basis
13339   -- changes
13340   --
13341   --
13342   --Pay Basis functionality is not included in the 1st phase
13343   --of non payrolled worker. As a result this code has been commented
13344   --out, but left in as it is likely to form part of a later phase
13345   --
13346   /*
13347   IF (p_pay_basis_id <> hr_api.g_number or
13348       p_pay_basis_id is null ) and
13349      (nvl(p_pay_basis_id,hr_api.g_number) <>
13350       nvl(per_asg_shd.g_old_rec.pay_basis_id, hr_api.g_number))
13351   then
13352     open csr_get_salary;
13353     fetch csr_get_salary into l_element_entry_id;
13354     if csr_get_salary%found then
13355       close csr_get_salary;
13356       --
13357       hr_entry_api.delete_element_entry
13358         ('DELETE'
13359         ,l_validation_start_date - 1
13360         ,l_element_entry_id);
13361       --
13362       l_entries_changed_warning := 'S';
13363     else
13364        close csr_get_salary;
13365     end if;
13366   end if;
13367   */
13368   --
13369   -- Maintain standard element entries for this assignment.
13370   --
13371   -- Payroll functionality is not included in the 1st phase
13372   -- of non payrolled worker. As a result this code has been commented
13373   -- out, but left in as it is likely to form part of a later phase
13374   --
13375   /*
13376   if p_payroll_id = hr_api.g_number
13377    then
13378      --
13379  if g_debug then
13380      hr_utility.set_location(l_proc, 150);
13381  end if;
13382      --
13383      l_new_payroll_id := per_asg_shd.g_old_rec.payroll_id;
13384   else
13385      --
13386  if g_debug then
13387      hr_utility.set_location(l_proc, 160);
13388  end if;
13389      --
13390      l_new_payroll_id := p_payroll_id;
13391   end if;
13392   --
13393  if g_debug then
13394   hr_utility.set_location(l_proc, 170);
13395  end if;
13396   --
13397   hrentmnt.maintain_entries_asg
13398     (p_assignment_id                => p_assignment_id
13399     ,p_old_payroll_id               => per_asg_shd.g_old_rec.payroll_id
13400     ,p_new_payroll_id               => l_new_payroll_id
13401     ,p_business_group_id            => l_business_group_id
13402     ,p_operation                    => 'ASG_CRITERIA'
13403     ,p_actual_term_date             => null
13404     ,p_last_standard_date           => null
13405     ,p_final_process_date           => null
13406     ,p_dt_mode                      => p_datetrack_update_mode
13407     ,p_validation_start_date        => l_validation_start_date
13408     ,p_validation_end_date          => l_validation_end_date
13409     ,p_entries_changed              => l_entries_changed
13410     );
13411   --
13412   -- Bug 630826 fix ends
13413   --
13414  if g_debug then
13415   hr_utility.set_location(l_proc, 180);
13416  end if;
13417   --
13418   if l_entries_changed_warning <> 'S' then
13419     l_entries_changed_warning := nvl(l_entries_changed, 'N');
13420   end if;
13421   */
13422   --
13423   -- Bug 3545065, Grade should not be maintained for CWK asg
13424   /*
13425   IF (per_asg_shd.g_old_rec.grade_id IS NOT NULL AND
13426       p_grade_id IS NULL) OR
13427 	 (per_asg_shd.g_old_rec.grade_id IS NOT NULL AND
13428 	  p_grade_id IS NOT NULL AND
13429 	  per_asg_shd.g_old_rec.grade_id <> p_grade_id AND
13430 	  p_grade_id <> hr_api.g_number) THEN
13431     --
13432  if g_debug then
13433     hr_utility.set_location(l_proc, 190);
13434  end if;
13435     --
13436     -- Maintain spinal point placements.
13437     --
13438     hr_assignment_internal.maintain_spp_asg
13439       (p_assignment_id                => p_assignment_id
13440       ,p_datetrack_mode               => l_new_dt_update_mode
13441       ,p_validation_start_date        => l_validation_start_date
13442       ,p_validation_end_date          => l_validation_end_date
13443       ,p_grade_id		              => p_grade_id
13444       ,p_spp_delete_warning           => l_spp_delete_warning);
13445     --
13446   ELSE
13447     --
13448  if g_debug then
13449     hr_utility.set_location(l_proc, 200);
13450  end if;
13451     --
13452     -- No SPPs to maintain.
13453     --
13454     l_spp_delete_warning := FALSE;
13455 	--
13456   END IF;
13457   --
13458   */
13459   -- End of bug 3545065
13460   --
13461  if g_debug then
13462   hr_utility.set_location(l_proc, 210);
13463  end if;
13464   --
13465   -- IF GB legislation and payroll has changed, then delete latest balance
13466   -- values,
13467   --
13468   OPEN  csr_get_legislation_code;
13469   FETCH csr_get_legislation_code INTO l_legislation_code;
13470   --
13471   IF csr_get_legislation_code%NOTFOUND THEN
13472     --
13473     CLOSE csr_get_legislation_code;
13474     --
13475  if g_debug then
13476     hr_utility.set_location(l_proc, 220);
13477  end if;
13478     --
13479     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
13480     hr_utility.set_message_token('PROCEDURE', l_proc);
13481     hr_utility.set_message_token('STEP', '215');
13482     hr_utility.raise_error;
13483 	--
13484   END IF;
13485   --
13486   CLOSE csr_get_legislation_code;
13487   --
13488  if g_debug then
13489   hr_utility.set_location(l_proc, 230);
13490  end if;
13491   --
13492   IF  l_legislation_code = 'GB' AND l_payroll_id_updated THEN
13493     --
13494  if g_debug then
13495     hr_utility.set_location(l_proc, 240);
13496  end if;
13497     --
13498     -- Delete latest balance values.
13499     --
13500     py_gb_asg.payroll_transfer
13501       (p_assignment_id => p_assignment_id);
13502     --
13503     -- When GB legislation, and the business group and the payroll has changed,
13504     -- set the Print P45 flag on the assignments extra info flexfield, and set
13505     -- the changed tax district warning out parameter.
13506     -- This functionality will be supported at a later date.
13507     --
13508     l_tax_district_changed_warning := FALSE;
13509 	--
13510   ELSE
13511     --
13512  if g_debug then
13513     hr_utility.set_location(l_proc, 250);
13514  end if;
13515     --
13516     l_tax_district_changed_warning := FALSE;
13517 	--
13518   END IF;
13519   --
13520  if g_debug then
13521   hr_utility.set_location(l_proc, 260);
13522  end if;
13523   --
13524   BEGIN
13525     --
13526     -- Start of API User Hook for the after hook of update_emp_asg_criteria
13527     --
13528     hr_assignment_bko.update_cwk_asg_criteria_a
13529       (p_effective_date               => l_effective_date
13530       ,p_datetrack_update_mode        => l_dt_update_mode
13531       ,p_assignment_id                => p_assignment_id
13532       ,p_object_version_number        => p_object_version_number
13533       ,p_grade_id                     => p_grade_id -- Bug 3545065
13534       ,p_position_id                  => p_position_id
13535       ,p_job_id                       => l_job_id -- Bug 3553286
13536       --,p_payroll_id                   => p_payroll_id
13537       ,p_location_id                  => p_location_id
13538       ,p_organization_id              => l_org_id -- Bug 3553286
13539       ,p_pay_basis_id                 => p_pay_basis_id
13540       ,p_segment1                     => p_segment1
13541       ,p_segment2                     => p_segment2
13542       ,p_segment3                     => p_segment3
13543       ,p_segment4                     => p_segment4
13544       ,p_segment5                     => p_segment5
13545       ,p_segment6                     => p_segment6
13546       ,p_segment7                     => p_segment7
13547       ,p_segment8                     => p_segment8
13548       ,p_segment9                     => p_segment9
13549       ,p_segment10                    => p_segment10
13550       ,p_segment11                    => p_segment11
13551       ,p_segment12                    => p_segment12
13552       ,p_segment13                    => p_segment13
13553       ,p_segment14                    => p_segment14
13554       ,p_segment15                    => p_segment15
13555       ,p_segment16                    => p_segment16
13556       ,p_segment17                    => p_segment17
13557       ,p_segment18                    => p_segment18
13558       ,p_segment19                    => p_segment19
13559       ,p_segment20                    => p_segment20
13560       ,p_segment21                    => p_segment21
13561       ,p_segment22                    => p_segment22
13562       ,p_segment23                    => p_segment23
13563       ,p_segment24                    => p_segment24
13564       ,p_segment25                    => p_segment25
13565       ,p_segment26                    => p_segment26
13566       ,p_segment27                    => p_segment27
13567       ,p_segment28                    => p_segment28
13568       ,p_segment29                    => p_segment29
13569       ,p_segment30                    => p_segment30
13570       ,p_people_group_name            => l_people_group_name
13571       ,p_effective_start_date         => l_effective_start_date
13572       ,p_effective_end_date           => l_effective_end_date
13573       ,p_people_group_id              => l_people_group_id
13574       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
13575       ,p_other_manager_warning        => l_other_manager_warning
13576       ,p_spp_delete_warning           => l_spp_delete_warning
13577       ,p_entries_changed_warning      => l_entries_changed_warning
13578       ,p_tax_district_changed_warning => l_tax_district_changed_warning
13579       ,p_concat_segments              => l_old_group_name);
13580     --
13581   EXCEPTION
13582     --
13583     WHEN hr_api.cannot_find_prog_unit THEN
13584 	  --
13585       hr_api.cannot_find_prog_unit_error
13586         (p_module_name => 'UPDATE_CWK_ASG_CRITERIA'
13587         ,p_hook_type   => 'AP');
13588       --
13589       -- End of API User Hook for the after hook of update_emp_asg_criteria
13590       --
13591   END;
13592   --
13593   -- When in validation only mode raise the Validate_Enabled exception
13594   --
13595   IF p_validate THEN
13596     --
13597     RAISE hr_api.validate_enabled;
13598 	--
13599   END IF;
13600   --
13601   -- Set all output arguments
13602   --
13603   p_effective_end_date           := l_effective_end_date;
13604   p_effective_start_date         := l_effective_start_date;
13605   p_people_group_id              := l_people_group_id;
13606   p_people_group_name            := l_people_group_name;
13607   p_entries_changed_warning      := l_entries_changed_warning;
13608   p_object_version_number        := l_object_version_number;
13609   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
13610   p_other_manager_warning        := l_other_manager_warning;
13611   p_spp_delete_warning           := l_spp_delete_warning;
13612   p_tax_district_changed_warning := l_tax_district_changed_warning;
13613   --
13614   --
13615   -- remove data from the session table
13616   --
13617   hr_kflex_utility.unset_session_date
13618     (p_session_id     => l_session_id);
13619   --
13620  if g_debug then
13621   hr_utility.set_location(' Leaving:'||l_proc, 999);
13622  end if;
13623   --
13624 EXCEPTION
13625   --
13626   WHEN hr_api.validate_enabled THEN
13627     --
13628     -- As the Validate_Enabled exception has been raised
13629     -- we must rollback to the savepoint
13630     --
13631     ROLLBACK TO update_cwk_asg_criteria;
13632     --
13633     -- Only set output warning arguments
13634     -- (Any key or derived arguments must be set to null
13635     -- when validation only mode is being used.)
13636     --
13637     p_effective_end_date           := NULL;
13638     p_effective_start_date         := NULL;
13639     p_entries_changed_warning      := l_entries_changed_warning;
13640     p_people_group_name                   := l_old_group_name;
13641     p_object_version_number        := p_object_version_number;
13642     p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
13643     p_other_manager_warning        := l_other_manager_warning;
13644     p_people_group_id              := NULL;
13645     p_spp_delete_warning           := l_spp_delete_warning;
13646     p_tax_district_changed_warning := l_tax_district_changed_warning;
13647     --
13648   WHEN others THEN
13649     --
13650     -- A validation or unexpected error has occurred
13651     --
13652     -- Added as part of fix to bug 632479
13653     --
13654     p_object_version_number := lv_object_version_number;
13655 
13656     ROLLBACK TO update_cwk_asg_criteria;
13657     RAISE;
13658     --
13659     -- End of fix.
13660     --
13661 END update_cwk_asg_criteria;
13662 --
13663 --
13664 -- ----------------------------------------------------------------------------
13665 -- |--------------------------< update_gb_emp_asg >---------------------------|
13666 -- ----------------------------------------------------------------------------
13667 --
13668 procedure update_gb_emp_asg
13669   (p_validate                     in     boolean
13670   ,p_effective_date               in     date
13671   ,p_datetrack_update_mode        in     varchar2
13672   ,p_assignment_id                in     number
13673   ,p_object_version_number        in out nocopy number
13674   ,p_supervisor_id                in     number
13675   ,p_assignment_number            in     varchar2
13676   ,p_change_reason                in     varchar2
13677   ,p_comments                     in     varchar2
13678   ,p_date_probation_end           in     date
13679   ,p_default_code_comb_id         in     number
13680   ,p_frequency                    in     varchar2
13681   ,p_internal_address_line        in     varchar2
13682   ,p_manager_flag                 in     varchar2
13683   ,p_normal_hours                 in     number
13684   ,p_perf_review_period           in     number
13685   ,p_perf_review_period_frequency in     varchar2
13686   ,p_probation_period             in     number
13687   ,p_probation_unit               in     varchar2
13688   ,p_sal_review_period            in     number
13689   ,p_sal_review_period_frequency  in     varchar2
13690   ,p_set_of_books_id              in     number
13691   ,p_source_type                  in     varchar2
13692   ,p_time_normal_finish           in     varchar2
13693   ,p_time_normal_start            in     varchar2
13694   ,p_bargaining_unit_code         in     varchar2
13695   ,p_labour_union_member_flag     in     varchar2
13696   ,p_hourly_salaried_code         in     varchar2
13697   ,p_ass_attribute_category       in     varchar2
13698   ,p_ass_attribute1               in     varchar2
13699   ,p_ass_attribute2               in     varchar2
13700   ,p_ass_attribute3               in     varchar2
13701   ,p_ass_attribute4               in     varchar2
13702   ,p_ass_attribute5               in     varchar2
13703   ,p_ass_attribute6               in     varchar2
13704   ,p_ass_attribute7               in     varchar2
13705   ,p_ass_attribute8               in     varchar2
13706   ,p_ass_attribute9               in     varchar2
13707   ,p_ass_attribute10              in     varchar2
13708   ,p_ass_attribute11              in     varchar2
13709   ,p_ass_attribute12              in     varchar2
13710   ,p_ass_attribute13              in     varchar2
13711   ,p_ass_attribute14              in     varchar2
13712   ,p_ass_attribute15              in     varchar2
13713   ,p_ass_attribute16              in     varchar2
13714   ,p_ass_attribute17              in     varchar2
13715   ,p_ass_attribute18              in     varchar2
13716   ,p_ass_attribute19              in     varchar2
13717   ,p_ass_attribute20              in     varchar2
13718   ,p_ass_attribute21              in     varchar2
13719   ,p_ass_attribute22              in     varchar2
13720   ,p_ass_attribute23              in     varchar2
13721   ,p_ass_attribute24              in     varchar2
13722   ,p_ass_attribute25              in     varchar2
13723   ,p_ass_attribute26              in     varchar2
13724   ,p_ass_attribute27              in     varchar2
13725   ,p_ass_attribute28              in     varchar2
13726   ,p_ass_attribute29              in     varchar2
13727   ,p_ass_attribute30              in     varchar2
13728   ,p_title                        in     varchar2
13729   ,p_supervisor_assignment_id     in     number
13730   ,p_comment_id                      out nocopy number
13731   ,p_effective_start_date            out nocopy date
13732   ,p_effective_end_date              out nocopy date
13733   ,p_no_managers_warning             out nocopy boolean
13734   ,p_other_manager_warning           out nocopy boolean
13735   ) is
13736   --
13737   -- Declare cursors and local variables
13738   --
13739   l_proc                       varchar2(72);
13740   l_effective_date             date;
13741   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
13742   l_concatenated_segments      varchar2(2000);
13743   l_legislation_code           per_business_groups.legislation_code%TYPE;
13744   l_cagr_concatenated_segments varchar2(300);
13745   l_cagr_grade_def_id	       number;
13746   --
13747   --
13748 begin
13749  if g_debug then
13750   l_proc := g_package||'update_gb_emp_asg';
13751   hr_utility.set_location('Entering:'|| l_proc, 10);
13752  end if;
13753   --
13754   -- Call the overloaded procedure
13755   --
13756   hr_assignment_api.update_gb_emp_asg
13757     (p_validate                     => p_validate
13758     ,p_effective_date               => p_effective_date
13759     ,p_datetrack_update_mode        => p_datetrack_update_mode
13760     ,p_assignment_id                => p_assignment_id
13761     ,p_object_version_number        => p_object_version_number
13762     ,p_supervisor_id                => p_supervisor_id
13763     ,p_assignment_number            => p_assignment_number
13764     ,p_change_reason                => p_change_reason
13765     ,p_comments                     => p_comments
13766     ,p_date_probation_end           => p_date_probation_end
13767     ,p_default_code_comb_id         => p_default_code_comb_id
13768     ,p_frequency                    => p_frequency
13769     ,p_internal_address_line        => p_internal_address_line
13770     ,p_manager_flag                 => p_manager_flag
13771     ,p_normal_hours                 => p_normal_hours
13772     ,p_perf_review_period           => p_perf_review_period
13773     ,p_perf_review_period_frequency => p_perf_review_period_frequency
13774     ,p_probation_period             => p_probation_period
13775     ,p_probation_unit               => p_probation_unit
13776     ,p_sal_review_period            => p_sal_review_period
13777     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
13778     ,p_set_of_books_id              => p_set_of_books_id
13779     ,p_source_type                  => p_source_type
13780     ,p_time_normal_finish           => p_time_normal_finish
13781     ,p_time_normal_start            => p_time_normal_start
13782     ,p_bargaining_unit_code         => p_bargaining_unit_code
13783     ,p_labour_union_member_flag     => p_labour_union_member_flag
13784     ,p_hourly_salaried_code         => p_hourly_salaried_code
13785     ,p_ass_attribute_category       => p_ass_attribute_category
13786     ,p_ass_attribute1               => p_ass_attribute1
13787     ,p_ass_attribute2               => p_ass_attribute2
13788     ,p_ass_attribute3               => p_ass_attribute3
13789     ,p_ass_attribute4               => p_ass_attribute4
13790     ,p_ass_attribute5               => p_ass_attribute5
13791     ,p_ass_attribute6               => p_ass_attribute6
13792     ,p_ass_attribute7               => p_ass_attribute7
13793     ,p_ass_attribute8               => p_ass_attribute8
13794     ,p_ass_attribute9               => p_ass_attribute9
13795     ,p_ass_attribute10              => p_ass_attribute10
13796     ,p_ass_attribute11              => p_ass_attribute11
13797     ,p_ass_attribute12              => p_ass_attribute12
13798     ,p_ass_attribute13              => p_ass_attribute13
13799     ,p_ass_attribute14              => p_ass_attribute14
13800     ,p_ass_attribute15              => p_ass_attribute15
13801     ,p_ass_attribute16              => p_ass_attribute16
13802     ,p_ass_attribute17              => p_ass_attribute17
13803     ,p_ass_attribute18              => p_ass_attribute18
13804     ,p_ass_attribute19              => p_ass_attribute19
13805     ,p_ass_attribute20              => p_ass_attribute20
13806     ,p_ass_attribute21              => p_ass_attribute21
13807     ,p_ass_attribute22              => p_ass_attribute22
13808     ,p_ass_attribute23              => p_ass_attribute23
13809     ,p_ass_attribute24              => p_ass_attribute24
13810     ,p_ass_attribute25              => p_ass_attribute25
13811     ,p_ass_attribute26              => p_ass_attribute26
13812     ,p_ass_attribute27              => p_ass_attribute27
13813     ,p_ass_attribute28              => p_ass_attribute28
13814     ,p_ass_attribute29              => p_ass_attribute29
13815     ,p_ass_attribute30              => p_ass_attribute30
13816     ,p_title                        => p_title
13817     ,p_cagr_grade_def_id 	    => l_cagr_grade_def_id
13818     ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
13819     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
13820     ,p_comment_id                   => p_comment_id
13821     ,p_effective_start_date         => p_effective_start_date
13822     ,p_effective_end_date           => p_effective_end_date
13823     ,p_concatenated_segments        => l_concatenated_segments
13824     ,p_no_managers_warning          => p_no_managers_warning
13825     ,p_other_manager_warning        => p_other_manager_warning
13826     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
13827     );
13828  if g_debug then
13829   hr_utility.set_location(' Leaving:'||l_proc, 20);
13830  end if;
13831 end update_gb_emp_asg;
13832 --
13833 -- ----------------------------------------------------------------------------
13834 -- |--------------------------< update_gb_emp_asg >------ OVERLOADED ---------|
13835 -- ----------------------------------------------------------------------------
13836 --
13837 -- added new parameters notice_period, units, employee_category,
13838 -- work_at_home and job_source on 05-OCT-01
13839 
13840 procedure update_gb_emp_asg
13841   (p_validate                     in     boolean
13842   ,p_effective_date               in     date
13843   ,p_datetrack_update_mode        in     varchar2
13844   ,p_assignment_id                in     number
13845   ,p_object_version_number        in out nocopy number
13846   ,p_supervisor_id                in     number
13847   ,p_assignment_number            in     varchar2
13848   ,p_change_reason                in     varchar2
13849   ,p_comments                     in     varchar2
13850   ,p_date_probation_end           in     date
13851   ,p_default_code_comb_id         in     number
13852   ,p_frequency                    in     varchar2
13853   ,p_internal_address_line        in     varchar2
13854   ,p_manager_flag                 in     varchar2
13855   ,p_normal_hours                 in     number
13856   ,p_perf_review_period           in     number
13857   ,p_perf_review_period_frequency in     varchar2
13858   ,p_probation_period             in     number
13859   ,p_probation_unit               in     varchar2
13860   ,p_sal_review_period            in     number
13861   ,p_sal_review_period_frequency  in     varchar2
13862   ,p_set_of_books_id              in     number
13863   ,p_source_type                  in     varchar2
13864   ,p_time_normal_finish           in     varchar2
13865   ,p_time_normal_start            in     varchar2
13866   ,p_bargaining_unit_code         in     varchar2
13867   ,p_labour_union_member_flag     in     varchar2
13868   ,p_hourly_salaried_code         in     varchar2
13869   ,p_ass_attribute_category       in     varchar2
13870   ,p_ass_attribute1               in     varchar2
13871   ,p_ass_attribute2               in     varchar2
13872   ,p_ass_attribute3               in     varchar2
13873   ,p_ass_attribute4               in     varchar2
13874   ,p_ass_attribute5               in     varchar2
13875   ,p_ass_attribute6               in     varchar2
13876   ,p_ass_attribute7               in     varchar2
13877   ,p_ass_attribute8               in     varchar2
13878   ,p_ass_attribute9               in     varchar2
13879   ,p_ass_attribute10              in     varchar2
13880   ,p_ass_attribute11              in     varchar2
13881   ,p_ass_attribute12              in     varchar2
13882   ,p_ass_attribute13              in     varchar2
13883   ,p_ass_attribute14              in     varchar2
13884   ,p_ass_attribute15              in     varchar2
13885   ,p_ass_attribute16              in     varchar2
13886   ,p_ass_attribute17              in     varchar2
13887   ,p_ass_attribute18              in     varchar2
13888   ,p_ass_attribute19              in     varchar2
13889   ,p_ass_attribute20              in     varchar2
13890   ,p_ass_attribute21              in     varchar2
13891   ,p_ass_attribute22              in     varchar2
13892   ,p_ass_attribute23              in     varchar2
13893   ,p_ass_attribute24              in     varchar2
13894   ,p_ass_attribute25              in     varchar2
13895   ,p_ass_attribute26              in     varchar2
13896   ,p_ass_attribute27              in     varchar2
13897   ,p_ass_attribute28              in     varchar2
13898   ,p_ass_attribute29              in     varchar2
13899   ,p_ass_attribute30              in     varchar2
13900   ,p_title                        in     varchar2
13901   ,p_contract_id                  in     number
13902   ,p_establishment_id             in     number
13903   ,p_collective_agreement_id      in     number
13904   ,p_cagr_id_flex_num             in     number
13905   ,p_notice_period		  in     number
13906   ,p_notice_period_uom	      	  in     varchar2
13907   ,p_employee_category	          in     varchar2
13908   ,p_work_at_home		  in     varchar2
13909   ,p_job_post_source_name	  in     varchar2
13910   ,p_supervisor_assignment_id     in     number
13911   ,p_cagr_grade_def_id               out nocopy number
13912   ,p_cagr_concatenated_segments      out nocopy varchar2
13913   ,p_concatenated_segments           out nocopy varchar2
13914   ,p_soft_coding_keyflex_id          out nocopy number
13915   ,p_comment_id                      out nocopy number
13916   ,p_effective_start_date            out nocopy date
13917   ,p_effective_end_date              out nocopy date
13918   ,p_no_managers_warning             out nocopy boolean
13919   ,p_other_manager_warning           out nocopy boolean
13920   ) is
13921   --
13922   -- Declare cursors and local variables
13923   --
13924   l_proc                       varchar2(72);
13925   l_effective_date             date;
13926   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
13927   l_concatenated_segments      varchar2(2000);
13928   l_legislation_code           per_business_groups.legislation_code%TYPE;
13929   --
13930   cursor check_legislation
13931     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
13932      c_effective_date date
13933     )
13934   is
13935     select bgp.legislation_code
13936     from per_all_assignments_f asg,
13937          per_business_groups_perf bgp
13938     where asg.business_group_id = bgp.business_group_id
13939     and   asg.assignment_id     = c_assignment_id
13940     and   c_effective_date
13941       between effective_start_date and effective_end_date;
13942   --
13943 begin
13944  if g_debug then
13945   l_proc := g_package||'update_gb_emp_asg';
13946   hr_utility.set_location('Entering:'|| l_proc, 10);
13947  end if;
13948   --
13949   -- Truncate date variables
13950   --
13951   l_effective_date := trunc(p_effective_date);
13952   --
13953   -- Validate in addition to Table Handlers
13954   --
13955   -- Check that the assignment exists.
13956   --
13957   open check_legislation(p_assignment_id, l_effective_date);
13958   fetch check_legislation into l_legislation_code;
13959   if check_legislation%notfound then
13960     close check_legislation;
13961     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
13962     hr_utility.raise_error;
13963   end if;
13964   close check_legislation;
13965  if g_debug then
13966   hr_utility.set_location(l_proc, 20);
13967  end if;
13968   --
13969   -- Check that the legislation of the specified business group is 'GB'.
13970   --
13971   if l_legislation_code <> 'GB' then
13972     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
13973     hr_utility.set_message_token('LEG_CODE','GB');
13974     hr_utility.raise_error;
13975   end if;
13976  if g_debug then
13977   hr_utility.set_location(l_proc, 30);
13978  end if;
13979   --
13980   -- Call update_emp_asg business process
13981   --
13982   hr_assignment_api.update_emp_asg
13983     (p_validate                     => p_validate
13984     ,p_effective_date               => p_effective_date
13985     ,p_datetrack_update_mode        => p_datetrack_update_mode
13986     ,p_assignment_id                => p_assignment_id
13987     ,p_object_version_number        => p_object_version_number
13988     ,p_supervisor_id                => p_supervisor_id
13989     ,p_assignment_number            => p_assignment_number
13990     ,p_change_reason                => p_change_reason
13991     ,p_comments                     => p_comments
13992     ,p_date_probation_end           => p_date_probation_end
13993     ,p_default_code_comb_id         => p_default_code_comb_id
13994     ,p_frequency                    => p_frequency
13995     ,p_internal_address_line        => p_internal_address_line
13996     ,p_manager_flag                 => p_manager_flag
13997     ,p_normal_hours                 => p_normal_hours
13998     ,p_perf_review_period           => p_perf_review_period
13999     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14000     ,p_probation_period             => p_probation_period
14001     ,p_probation_unit               => p_probation_unit
14002     ,p_sal_review_period            => p_sal_review_period
14003     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14004     ,p_set_of_books_id              => p_set_of_books_id
14005     ,p_source_type                  => p_source_type
14006     ,p_time_normal_finish           => p_time_normal_finish
14007     ,p_time_normal_start            => p_time_normal_start
14008     ,p_bargaining_unit_code         => p_bargaining_unit_code
14009     ,p_labour_union_member_flag     => p_labour_union_member_flag
14010     ,p_hourly_salaried_code         => p_hourly_salaried_code
14011     ,p_ass_attribute_category       => p_ass_attribute_category
14012     ,p_ass_attribute1               => p_ass_attribute1
14013     ,p_ass_attribute2               => p_ass_attribute2
14014     ,p_ass_attribute3               => p_ass_attribute3
14015     ,p_ass_attribute4               => p_ass_attribute4
14016     ,p_ass_attribute5               => p_ass_attribute5
14017     ,p_ass_attribute6               => p_ass_attribute6
14018     ,p_ass_attribute7               => p_ass_attribute7
14019     ,p_ass_attribute8               => p_ass_attribute8
14020     ,p_ass_attribute9               => p_ass_attribute9
14021     ,p_ass_attribute10              => p_ass_attribute10
14022     ,p_ass_attribute11              => p_ass_attribute11
14023     ,p_ass_attribute12              => p_ass_attribute12
14024     ,p_ass_attribute13              => p_ass_attribute13
14025     ,p_ass_attribute14              => p_ass_attribute14
14026     ,p_ass_attribute15              => p_ass_attribute15
14027     ,p_ass_attribute16              => p_ass_attribute16
14028     ,p_ass_attribute17              => p_ass_attribute17
14029     ,p_ass_attribute18              => p_ass_attribute18
14030     ,p_ass_attribute19              => p_ass_attribute19
14031     ,p_ass_attribute20              => p_ass_attribute20
14032     ,p_ass_attribute21              => p_ass_attribute21
14033     ,p_ass_attribute22              => p_ass_attribute22
14034     ,p_ass_attribute23              => p_ass_attribute23
14035     ,p_ass_attribute24              => p_ass_attribute24
14036     ,p_ass_attribute25              => p_ass_attribute25
14037     ,p_ass_attribute26              => p_ass_attribute26
14038     ,p_ass_attribute27              => p_ass_attribute27
14039     ,p_ass_attribute28              => p_ass_attribute28
14040     ,p_ass_attribute29              => p_ass_attribute29
14041     ,p_ass_attribute30              => p_ass_attribute30
14042     ,p_notice_period		    => p_notice_period
14043     ,p_notice_period_uom	    => p_notice_period_uom
14044     ,p_employee_category	    => p_employee_category
14045     ,p_work_at_home		    => p_work_at_home
14046     ,p_job_post_source_name	    => p_job_post_source_name
14047     ,p_title                        => p_title
14048     ,p_contract_id		    => p_contract_id
14049     ,p_establishment_id		    => p_establishment_id
14050     ,p_collective_agreement_id	    => p_collective_agreement_id
14051     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14052     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14053     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14054     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
14055     ,p_comment_id                   => p_comment_id
14056     ,p_effective_start_date         => p_effective_start_date
14057     ,p_effective_end_date           => p_effective_end_date
14058     ,p_concatenated_segments        => l_concatenated_segments
14059     ,p_no_managers_warning          => p_no_managers_warning
14060     ,p_other_manager_warning        => p_other_manager_warning
14061     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14062     );
14063  if g_debug then
14064   hr_utility.set_location(' Leaving:'||l_proc, 40);
14065  end if;
14066 end update_gb_emp_asg;
14067 
14068 --
14069 -- ----------------------------------------------------------------------------
14070 -- |--------------------------< update_gb_emp_asg >------ OVERLOADED ---------|
14071 -- ----------------------------------------------------------------------------
14072 --
14073 -- added new OUT parameter p_hourly_salaried_warning
14074 
14075 
14076 procedure update_gb_emp_asg
14077   (p_validate                     in     boolean
14078   ,p_effective_date               in     date
14079   ,p_datetrack_update_mode        in     varchar2
14080   ,p_assignment_id                in     number
14081   ,p_object_version_number        in out nocopy number
14082   ,p_supervisor_id                in     number
14083   ,p_assignment_number            in     varchar2
14084   ,p_change_reason                in     varchar2
14085   ,p_comments                     in     varchar2
14086   ,p_date_probation_end           in     date
14087   ,p_default_code_comb_id         in     number
14088   ,p_frequency                    in     varchar2
14089   ,p_internal_address_line        in     varchar2
14090   ,p_manager_flag                 in     varchar2
14091   ,p_normal_hours                 in     number
14092   ,p_perf_review_period           in     number
14093   ,p_perf_review_period_frequency in     varchar2
14094   ,p_probation_period             in     number
14095   ,p_probation_unit               in     varchar2
14096   ,p_sal_review_period            in     number
14097   ,p_sal_review_period_frequency  in     varchar2
14098   ,p_set_of_books_id              in     number
14099   ,p_source_type                  in     varchar2
14100   ,p_time_normal_finish           in     varchar2
14101   ,p_time_normal_start            in     varchar2
14102   ,p_bargaining_unit_code         in     varchar2
14103   ,p_labour_union_member_flag     in     varchar2
14104   ,p_hourly_salaried_code         in     varchar2
14105   ,p_ass_attribute_category       in     varchar2
14106   ,p_ass_attribute1               in     varchar2
14107   ,p_ass_attribute2               in     varchar2
14108   ,p_ass_attribute3               in     varchar2
14109   ,p_ass_attribute4               in     varchar2
14110   ,p_ass_attribute5               in     varchar2
14111   ,p_ass_attribute6               in     varchar2
14112   ,p_ass_attribute7               in     varchar2
14113   ,p_ass_attribute8               in     varchar2
14114   ,p_ass_attribute9               in     varchar2
14115   ,p_ass_attribute10              in     varchar2
14116   ,p_ass_attribute11              in     varchar2
14117   ,p_ass_attribute12              in     varchar2
14118   ,p_ass_attribute13              in     varchar2
14119   ,p_ass_attribute14              in     varchar2
14120   ,p_ass_attribute15              in     varchar2
14121   ,p_ass_attribute16              in     varchar2
14122   ,p_ass_attribute17              in     varchar2
14123   ,p_ass_attribute18              in     varchar2
14124   ,p_ass_attribute19              in     varchar2
14125   ,p_ass_attribute20              in     varchar2
14126   ,p_ass_attribute21              in     varchar2
14127   ,p_ass_attribute22              in     varchar2
14128   ,p_ass_attribute23              in     varchar2
14129   ,p_ass_attribute24              in     varchar2
14130   ,p_ass_attribute25              in     varchar2
14131   ,p_ass_attribute26              in     varchar2
14132   ,p_ass_attribute27              in     varchar2
14133   ,p_ass_attribute28              in     varchar2
14134   ,p_ass_attribute29              in     varchar2
14135   ,p_ass_attribute30              in     varchar2
14136   ,p_title                        in     varchar2
14137   ,p_contract_id                  in     number
14138   ,p_establishment_id             in     number
14139   ,p_collective_agreement_id      in     number
14140   ,p_cagr_id_flex_num             in     number
14141   ,p_notice_period		  in     number
14142   ,p_notice_period_uom	      	  in     varchar2
14143   ,p_employee_category	          in     varchar2
14144   ,p_work_at_home		  in     varchar2
14145   ,p_job_post_source_name	  in     varchar2
14146   ,p_supervisor_assignment_id     in     number
14147   ,p_cagr_grade_def_id               out nocopy number
14148   ,p_cagr_concatenated_segments      out nocopy varchar2
14149   ,p_concatenated_segments           out nocopy varchar2
14150   ,p_soft_coding_keyflex_id          out nocopy number
14151   ,p_comment_id                      out nocopy number
14152   ,p_effective_start_date            out nocopy date
14153   ,p_effective_end_date              out nocopy date
14154   ,p_no_managers_warning             out nocopy boolean
14155   ,p_other_manager_warning           out nocopy boolean
14156   ,p_hourly_salaried_warning         out nocopy boolean
14157   ) is
14158   --
14159   -- Declare cursors and local variables
14160   --
14161   l_proc                       varchar2(72);
14162   l_effective_date             date;
14163   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
14164   l_concatenated_segments      varchar2(2000);
14165   l_legislation_code           per_business_groups.legislation_code%TYPE;
14166   --
14167   cursor check_legislation
14168     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14169      c_effective_date date
14170     )
14171   is
14172     select bgp.legislation_code
14173     from per_all_assignments_f asg,
14174          per_business_groups_perf bgp
14175     where asg.business_group_id = bgp.business_group_id
14176     and   asg.assignment_id     = c_assignment_id
14177     and   c_effective_date
14178       between effective_start_date and effective_end_date;
14179   --
14180 begin
14181  if g_debug then
14182   l_proc := g_package||'update_gb_emp_asg';
14183   hr_utility.set_location('Entering:'|| l_proc, 10);
14184  end if;
14185   --
14186   -- Truncate date variables
14187   --
14188   l_effective_date := trunc(p_effective_date);
14189   --
14190   -- Validate in addition to Table Handlers
14191   --
14192   -- Check that the assignment exists.
14193   --
14194   open check_legislation(p_assignment_id, l_effective_date);
14195   fetch check_legislation into l_legislation_code;
14196   if check_legislation%notfound then
14197     close check_legislation;
14198     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14199     hr_utility.raise_error;
14200   end if;
14201   close check_legislation;
14202  if g_debug then
14203   hr_utility.set_location(l_proc, 20);
14204  end if;
14205   --
14206   -- Check that the legislation of the specified business group is 'GB'.
14207   --
14208   if l_legislation_code <> 'GB' then
14209     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14210     hr_utility.set_message_token('LEG_CODE','GB');
14211     hr_utility.raise_error;
14212   end if;
14213  if g_debug then
14214   hr_utility.set_location(l_proc, 30);
14215  end if;
14216   --
14217   -- Call update_emp_asg business process
14218   --
14219   hr_assignment_api.update_emp_asg
14220     (p_validate                     => p_validate
14221     ,p_effective_date               => p_effective_date
14222     ,p_datetrack_update_mode        => p_datetrack_update_mode
14223     ,p_assignment_id                => p_assignment_id
14224     ,p_object_version_number        => p_object_version_number
14225     ,p_supervisor_id                => p_supervisor_id
14226     ,p_assignment_number            => p_assignment_number
14227     ,p_change_reason                => p_change_reason
14228     ,p_comments                     => p_comments
14229     ,p_date_probation_end           => p_date_probation_end
14230     ,p_default_code_comb_id         => p_default_code_comb_id
14231     ,p_frequency                    => p_frequency
14232     ,p_internal_address_line        => p_internal_address_line
14233     ,p_manager_flag                 => p_manager_flag
14234     ,p_normal_hours                 => p_normal_hours
14235     ,p_perf_review_period           => p_perf_review_period
14236     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14237     ,p_probation_period             => p_probation_period
14238     ,p_probation_unit               => p_probation_unit
14239     ,p_sal_review_period            => p_sal_review_period
14240     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14241     ,p_set_of_books_id              => p_set_of_books_id
14242     ,p_source_type                  => p_source_type
14243     ,p_time_normal_finish           => p_time_normal_finish
14244     ,p_time_normal_start            => p_time_normal_start
14245     ,p_bargaining_unit_code         => p_bargaining_unit_code
14246     ,p_labour_union_member_flag     => p_labour_union_member_flag
14247     ,p_hourly_salaried_code         => p_hourly_salaried_code
14248     ,p_ass_attribute_category       => p_ass_attribute_category
14249     ,p_ass_attribute1               => p_ass_attribute1
14250     ,p_ass_attribute2               => p_ass_attribute2
14251     ,p_ass_attribute3               => p_ass_attribute3
14252     ,p_ass_attribute4               => p_ass_attribute4
14253     ,p_ass_attribute5               => p_ass_attribute5
14254     ,p_ass_attribute6               => p_ass_attribute6
14255     ,p_ass_attribute7               => p_ass_attribute7
14256     ,p_ass_attribute8               => p_ass_attribute8
14257     ,p_ass_attribute9               => p_ass_attribute9
14258     ,p_ass_attribute10              => p_ass_attribute10
14259     ,p_ass_attribute11              => p_ass_attribute11
14260     ,p_ass_attribute12              => p_ass_attribute12
14261     ,p_ass_attribute13              => p_ass_attribute13
14262     ,p_ass_attribute14              => p_ass_attribute14
14263     ,p_ass_attribute15              => p_ass_attribute15
14264     ,p_ass_attribute16              => p_ass_attribute16
14265     ,p_ass_attribute17              => p_ass_attribute17
14266     ,p_ass_attribute18              => p_ass_attribute18
14267     ,p_ass_attribute19              => p_ass_attribute19
14268     ,p_ass_attribute20              => p_ass_attribute20
14269     ,p_ass_attribute21              => p_ass_attribute21
14270     ,p_ass_attribute22              => p_ass_attribute22
14271     ,p_ass_attribute23              => p_ass_attribute23
14272     ,p_ass_attribute24              => p_ass_attribute24
14273     ,p_ass_attribute25              => p_ass_attribute25
14274     ,p_ass_attribute26              => p_ass_attribute26
14275     ,p_ass_attribute27              => p_ass_attribute27
14276     ,p_ass_attribute28              => p_ass_attribute28
14277     ,p_ass_attribute29              => p_ass_attribute29
14278     ,p_ass_attribute30              => p_ass_attribute30
14279     ,p_notice_period		    => p_notice_period
14280     ,p_notice_period_uom	    => p_notice_period_uom
14281     ,p_employee_category	    => p_employee_category
14282     ,p_work_at_home		    => p_work_at_home
14283     ,p_job_post_source_name	    => p_job_post_source_name
14284     ,p_title                        => p_title
14285     ,p_contract_id		    => p_contract_id
14286     ,p_establishment_id		    => p_establishment_id
14287     ,p_collective_agreement_id	    => p_collective_agreement_id
14288     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14289     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14290     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14291     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
14292     ,p_comment_id                   => p_comment_id
14293     ,p_effective_start_date         => p_effective_start_date
14294     ,p_effective_end_date           => p_effective_end_date
14295     ,p_concatenated_segments        => l_concatenated_segments
14296     ,p_no_managers_warning          => p_no_managers_warning
14297     ,p_other_manager_warning        => p_other_manager_warning
14298     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
14299     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14300     );
14301  if g_debug then
14302   hr_utility.set_location(' Leaving:'||l_proc, 40);
14303  end if;
14304 end update_gb_emp_asg;
14305 
14306 -- End of OVERLOADED procedure update_gb_emp_asg
14307 -- ----------------------------------------------------------------------------
14308 -- |--------------------------< update_us_emp_asg -- OLD >--------------------|
14309 -- ----------------------------------------------------------------------------
14310 --
14311 procedure update_us_emp_asg
14312   (p_validate                     in     boolean
14313   ,p_effective_date               in     date
14314   ,p_datetrack_update_mode        in     varchar2
14315   ,p_assignment_id                in     number
14316   ,p_object_version_number        in out nocopy number
14317   ,p_supervisor_id                in     number
14318   ,p_assignment_number            in     varchar2
14319   ,p_change_reason                in     varchar2
14320   ,p_comments                     in     varchar2
14321   ,p_date_probation_end           in     date
14322   ,p_default_code_comb_id         in     number
14323   ,p_frequency                    in     varchar2
14324   ,p_internal_address_line        in     varchar2
14325   ,p_manager_flag                 in     varchar2
14326   ,p_normal_hours                 in     number
14327   ,p_perf_review_period           in     number
14328   ,p_perf_review_period_frequency in     varchar2
14329   ,p_probation_period             in     number
14330   ,p_probation_unit               in     varchar2
14331   ,p_sal_review_period            in     number
14332   ,p_sal_review_period_frequency  in     varchar2
14333   ,p_set_of_books_id              in     number
14334   ,p_source_type                  in     varchar2
14335   ,p_time_normal_finish           in     varchar2
14336   ,p_time_normal_start            in     varchar2
14337   ,p_bargaining_unit_code         in     varchar2
14338   ,p_labour_union_member_flag     in     varchar2
14339   ,p_hourly_salaried_code         in     varchar2
14340   ,p_ass_attribute_category       in     varchar2
14341   ,p_ass_attribute1               in     varchar2
14342   ,p_ass_attribute2               in     varchar2
14343   ,p_ass_attribute3               in     varchar2
14344   ,p_ass_attribute4               in     varchar2
14345   ,p_ass_attribute5               in     varchar2
14346   ,p_ass_attribute6               in     varchar2
14347   ,p_ass_attribute7               in     varchar2
14348   ,p_ass_attribute8               in     varchar2
14349   ,p_ass_attribute9               in     varchar2
14350   ,p_ass_attribute10              in     varchar2
14351   ,p_ass_attribute11              in     varchar2
14352   ,p_ass_attribute12              in     varchar2
14353   ,p_ass_attribute13              in     varchar2
14354   ,p_ass_attribute14              in     varchar2
14355   ,p_ass_attribute15              in     varchar2
14356   ,p_ass_attribute16              in     varchar2
14357   ,p_ass_attribute17              in     varchar2
14358   ,p_ass_attribute18              in     varchar2
14359   ,p_ass_attribute19              in     varchar2
14360   ,p_ass_attribute20              in     varchar2
14361   ,p_ass_attribute21              in     varchar2
14362   ,p_ass_attribute22              in     varchar2
14363   ,p_ass_attribute23              in     varchar2
14364   ,p_ass_attribute24              in     varchar2
14365   ,p_ass_attribute25              in     varchar2
14366   ,p_ass_attribute26              in     varchar2
14367   ,p_ass_attribute27              in     varchar2
14368   ,p_ass_attribute28              in     varchar2
14369   ,p_ass_attribute29              in     varchar2
14370   ,p_ass_attribute30              in     varchar2
14371   ,p_title                        in     varchar2
14372   ,p_tax_unit                     in     varchar2
14373   ,p_timecard_approver            in     varchar2
14374   ,p_timecard_required            in     varchar2
14375   ,p_work_schedule                in     varchar2
14376   ,p_shift                        in     varchar2
14377   ,p_spouse_salary                in     varchar2
14378   ,p_legal_representative         in     varchar2
14379   ,p_wc_override_code             in     varchar2
14380   ,p_eeo_1_establishment          in     varchar2
14381   ,p_supervisor_assignment_id     in     number
14382   ,p_comment_id                      out nocopy number
14383   ,p_soft_coding_keyflex_id          out nocopy number
14384   ,p_effective_start_date            out nocopy date
14385   ,p_effective_end_date              out nocopy date
14386 -- Bug 944911
14387 -- Amended p_concatenated_segments to be out
14388 -- Added p_concat_segments  - in param
14389   ,p_concatenated_segments           out nocopy varchar2
14390   ,p_concat_segments              in     varchar2
14391   ,p_no_managers_warning             out nocopy boolean
14392   ,p_other_manager_warning           out nocopy boolean
14393   )
14394 is
14395   --
14396   -- Declare cursors and local variables
14397   --
14398   l_proc                       varchar2(72);
14399   l_effective_date             date;
14400   l_legislation_code           per_business_groups.legislation_code%TYPE;
14401   l_cagr_grade_def_id	       number;
14402   l_cagr_concatenated_segments number;
14403 
14404   --
14405 begin
14406  if g_debug then
14407   l_proc := g_package||'update_us_emp_asg';
14408   hr_utility.set_location('Entering:'|| l_proc, 10);
14409  end if;
14410   --
14411   -- Call the overloaded procedure update_us_emp_asg
14412   --
14413   hr_assignment_api.update_emp_asg
14414     (p_validate                     => p_validate
14415     ,p_effective_date               => p_effective_date
14416     ,p_datetrack_update_mode        => p_datetrack_update_mode
14417     ,p_assignment_id                => p_assignment_id
14418     ,p_object_version_number        => p_object_version_number
14419     ,p_supervisor_id                => p_supervisor_id
14420     ,p_assignment_number            => p_assignment_number
14421     ,p_change_reason                => p_change_reason
14422     ,p_comments                     => p_comments
14423     ,p_date_probation_end           => p_date_probation_end
14424     ,p_default_code_comb_id         => p_default_code_comb_id
14425     ,p_frequency                    => p_frequency
14426     ,p_internal_address_line        => p_internal_address_line
14427     ,p_manager_flag                 => p_manager_flag
14428     ,p_normal_hours                 => p_normal_hours
14429     ,p_perf_review_period           => p_perf_review_period
14430     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14431     ,p_probation_period             => p_probation_period
14432     ,p_probation_unit               => p_probation_unit
14433     ,p_sal_review_period            => p_sal_review_period
14434     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14435     ,p_set_of_books_id              => p_set_of_books_id
14436     ,p_source_type                  => p_source_type
14437     ,p_time_normal_finish           => p_time_normal_finish
14438     ,p_time_normal_start            => p_time_normal_start
14439     ,p_bargaining_unit_code         => p_bargaining_unit_code
14440     ,p_labour_union_member_flag     => p_labour_union_member_flag
14441     ,p_hourly_salaried_code         => p_hourly_salaried_code
14442     ,p_ass_attribute_category       => p_ass_attribute_category
14443     ,p_ass_attribute1               => p_ass_attribute1
14444     ,p_ass_attribute2               => p_ass_attribute2
14445     ,p_ass_attribute3               => p_ass_attribute3
14446     ,p_ass_attribute4               => p_ass_attribute4
14447     ,p_ass_attribute5               => p_ass_attribute5
14448     ,p_ass_attribute6               => p_ass_attribute6
14449     ,p_ass_attribute7               => p_ass_attribute7
14450     ,p_ass_attribute8               => p_ass_attribute8
14451     ,p_ass_attribute9               => p_ass_attribute9
14452     ,p_ass_attribute10              => p_ass_attribute10
14453     ,p_ass_attribute11              => p_ass_attribute11
14454     ,p_ass_attribute12              => p_ass_attribute12
14455     ,p_ass_attribute13              => p_ass_attribute13
14456     ,p_ass_attribute14              => p_ass_attribute14
14457     ,p_ass_attribute15              => p_ass_attribute15
14458     ,p_ass_attribute16              => p_ass_attribute16
14459     ,p_ass_attribute17              => p_ass_attribute17
14460     ,p_ass_attribute18              => p_ass_attribute18
14461     ,p_ass_attribute19              => p_ass_attribute19
14462     ,p_ass_attribute20              => p_ass_attribute20
14463     ,p_ass_attribute21              => p_ass_attribute21
14464     ,p_ass_attribute22              => p_ass_attribute22
14465     ,p_ass_attribute23              => p_ass_attribute23
14466     ,p_ass_attribute24              => p_ass_attribute24
14467     ,p_ass_attribute25              => p_ass_attribute25
14468     ,p_ass_attribute26              => p_ass_attribute26
14469     ,p_ass_attribute27              => p_ass_attribute27
14470     ,p_ass_attribute28              => p_ass_attribute28
14471     ,p_ass_attribute29              => p_ass_attribute29
14472     ,p_ass_attribute30              => p_ass_attribute30
14473     ,p_title                        => p_title
14474     ,p_segment1                     => p_tax_unit
14475     ,p_segment2                     => p_timecard_approver
14476     ,p_segment3                     => p_timecard_required
14477     ,p_segment4                     => p_work_schedule
14478     ,p_segment5                     => p_shift
14479     ,p_segment6                     => p_spouse_salary
14480     ,p_segment7                     => p_legal_representative
14481     ,p_segment8                     => p_wc_override_code
14482     ,p_segment9                     => p_eeo_1_establishment
14483     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
14484     ,p_comment_id                   => p_comment_id
14485     ,p_effective_start_date         => p_effective_start_date
14486     ,p_effective_end_date           => p_effective_end_date
14487     -- Bug 1889914
14488     ,p_cagr_grade_def_id	    => l_cagr_grade_def_id
14489     ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
14490 -- Bug 944911
14491 -- Added new param
14492     ,p_concatenated_segments        => p_concatenated_segments
14493     ,p_concat_segments              => p_concat_segments
14494     ,p_no_managers_warning          => p_no_managers_warning
14495     ,p_other_manager_warning        => p_other_manager_warning
14496     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14497     );
14498  if g_debug then
14499   hr_utility.set_location(' Leaving:'||l_proc, 40);
14500  end if;
14501 end update_us_emp_asg;
14502 --
14503 -- ----------------------------------------------------------------------------
14504 -- |--------------------------< update_us_emp_asg --NEW>----------------------|
14505 -- ----------------------------------------------------------------------------
14506 --
14507 -- added new parameters notice_period, units, employee_category,
14508 -- work_at_home and job_source on 05-OCT-01
14509 
14510 procedure update_us_emp_asg
14511   (p_validate                     in     boolean
14512   ,p_effective_date               in     date
14513   ,p_datetrack_update_mode        in     varchar2
14514   ,p_assignment_id                in     number
14515   ,p_object_version_number        in out nocopy number
14516   ,p_supervisor_id                in     number
14517   ,p_assignment_number            in     varchar2
14518   ,p_change_reason                in     varchar2
14519   ,p_comments                     in     varchar2
14520   ,p_date_probation_end           in     date
14521   ,p_default_code_comb_id         in     number
14522   ,p_frequency                    in     varchar2
14523   ,p_internal_address_line        in     varchar2
14524   ,p_manager_flag                 in     varchar2
14525   ,p_normal_hours                 in     number
14526   ,p_perf_review_period           in     number
14527   ,p_perf_review_period_frequency in     varchar2
14528   ,p_probation_period             in     number
14529   ,p_probation_unit               in     varchar2
14530   ,p_sal_review_period            in     number
14531   ,p_sal_review_period_frequency  in     varchar2
14532   ,p_set_of_books_id              in     number
14533   ,p_source_type                  in     varchar2
14534   ,p_time_normal_finish           in     varchar2
14535   ,p_time_normal_start            in     varchar2
14536   ,p_bargaining_unit_code         in     varchar2
14537   ,p_labour_union_member_flag     in     varchar2
14538   ,p_hourly_salaried_code         in     varchar2
14539   ,p_ass_attribute_category       in     varchar2
14540   ,p_ass_attribute1               in     varchar2
14541   ,p_ass_attribute2               in     varchar2
14542   ,p_ass_attribute3               in     varchar2
14543   ,p_ass_attribute4               in     varchar2
14544   ,p_ass_attribute5               in     varchar2
14545   ,p_ass_attribute6               in     varchar2
14546   ,p_ass_attribute7               in     varchar2
14547   ,p_ass_attribute8               in     varchar2
14548   ,p_ass_attribute9               in     varchar2
14549   ,p_ass_attribute10              in     varchar2
14550   ,p_ass_attribute11              in     varchar2
14551   ,p_ass_attribute12              in     varchar2
14552   ,p_ass_attribute13              in     varchar2
14553   ,p_ass_attribute14              in     varchar2
14554   ,p_ass_attribute15              in     varchar2
14555   ,p_ass_attribute16              in     varchar2
14556   ,p_ass_attribute17              in     varchar2
14557   ,p_ass_attribute18              in     varchar2
14558   ,p_ass_attribute19              in     varchar2
14559   ,p_ass_attribute20              in     varchar2
14560   ,p_ass_attribute21              in     varchar2
14561   ,p_ass_attribute22              in     varchar2
14562   ,p_ass_attribute23              in     varchar2
14563   ,p_ass_attribute24              in     varchar2
14564   ,p_ass_attribute25              in     varchar2
14565   ,p_ass_attribute26              in     varchar2
14566   ,p_ass_attribute27              in     varchar2
14567   ,p_ass_attribute28              in     varchar2
14568   ,p_ass_attribute29              in     varchar2
14569   ,p_ass_attribute30              in     varchar2
14570   ,p_title                        in     varchar2
14571   ,p_tax_unit                     in     varchar2
14572   ,p_timecard_approver            in     varchar2
14573   ,p_timecard_required            in     varchar2
14574   ,p_work_schedule                in     varchar2
14575   ,p_shift                        in     varchar2
14576   ,p_spouse_salary                in     varchar2
14577   ,p_legal_representative         in     varchar2
14578   ,p_wc_override_code             in     varchar2
14579   ,p_eeo_1_establishment          in     varchar2
14580   -- Added for bug 1889914
14581   ,p_contract_id		  in     number
14582   ,p_establishment_id		  in 	 number
14583   ,p_collective_agreement_id	  in     number
14584   ,p_cagr_id_flex_num		  in     number
14585   ,p_notice_period		  in     number
14586   ,p_notice_period_uom	      	  in     varchar2
14587   ,p_employee_category	          in     varchar2
14588   ,p_work_at_home		  in     varchar2
14589   ,p_job_post_source_name	  in     varchar2
14590   ,p_supervisor_assignment_id     in     number
14591   ,p_cagr_grade_def_id		     out nocopy number
14592   ,p_cagr_concatenated_segments      out nocopy varchar2
14593   -- End 1889914
14594   ,p_comment_id                      out nocopy number
14595   ,p_soft_coding_keyflex_id          out nocopy number
14596   ,p_effective_start_date            out nocopy date
14597   ,p_effective_end_date              out nocopy date
14598 -- Bug 944911
14599 -- Amended p_concatenated_segments to be out
14600 -- Added p_concat_segments  - in param
14601   ,p_concatenated_segments           out nocopy varchar2
14602   ,p_concat_segments              in     varchar2
14603   ,p_no_managers_warning             out nocopy boolean
14604   ,p_other_manager_warning           out nocopy boolean
14605   )
14606 is
14607   --
14608   -- Declare cursors and local variables
14609   --
14610   l_proc                       varchar2(72);
14611   l_effective_date             date;
14612   l_legislation_code           per_business_groups.legislation_code%TYPE;
14613 
14614   --
14615   cursor check_legislation
14616     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14617      c_effective_date date
14618     )
14619   is
14620     select bgp.legislation_code
14621     from per_all_assignments_f asg,
14622          per_business_groups_perf bgp
14623     where asg.business_group_id = bgp.business_group_id
14624     and   asg.assignment_id     = c_assignment_id
14625     and   c_effective_date
14626       between effective_start_date and effective_end_date;
14627   --
14628 begin
14629  if g_debug then
14630   l_proc := g_package||'update_us_emp_asg';
14631   hr_utility.set_location('Entering:'|| l_proc, 10);
14632  end if;
14633   --
14634   -- Truncate date variables
14635   --
14636   l_effective_date := trunc(p_effective_date);
14637   --
14638   -- Validate in addition to Table Handlers
14639   --
14640   -- Check that the assignment exists.
14641   --
14642   open check_legislation(p_assignment_id, l_effective_date);
14643   fetch check_legislation into l_legislation_code;
14644   if check_legislation%notfound then
14645     close check_legislation;
14646     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14647     hr_utility.raise_error;
14648   end if;
14649   close check_legislation;
14650  if g_debug then
14651   hr_utility.set_location(l_proc, 20);
14652  end if;
14653   --
14654   -- Check that the legislation of the specified business group is 'US'.
14655   --
14656   if l_legislation_code <> 'US' then
14657     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14658     hr_utility.set_message_token('LEG_CODE','US');
14659     hr_utility.raise_error;
14660   end if;
14661  if g_debug then
14662   hr_utility.set_location(l_proc, 30);
14663  end if;
14664   --
14665   -- Call update_emp_asg business process
14666   --
14667   hr_assignment_api.update_emp_asg
14668     (p_validate                     => p_validate
14669     ,p_effective_date               => p_effective_date
14670     ,p_datetrack_update_mode        => p_datetrack_update_mode
14671     ,p_assignment_id                => p_assignment_id
14672     ,p_object_version_number        => p_object_version_number
14673     ,p_supervisor_id                => p_supervisor_id
14674     ,p_assignment_number            => p_assignment_number
14675     ,p_change_reason                => p_change_reason
14676     ,p_comments                     => p_comments
14677     ,p_date_probation_end           => p_date_probation_end
14678     ,p_default_code_comb_id         => p_default_code_comb_id
14679     ,p_frequency                    => p_frequency
14680     ,p_internal_address_line        => p_internal_address_line
14681     ,p_manager_flag                 => p_manager_flag
14682     ,p_normal_hours                 => p_normal_hours
14683     ,p_perf_review_period           => p_perf_review_period
14684     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14685     ,p_probation_period             => p_probation_period
14686     ,p_probation_unit               => p_probation_unit
14687     ,p_sal_review_period            => p_sal_review_period
14688     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14689     ,p_set_of_books_id              => p_set_of_books_id
14690     ,p_source_type                  => p_source_type
14691     ,p_time_normal_finish           => p_time_normal_finish
14692     ,p_time_normal_start            => p_time_normal_start
14693     ,p_bargaining_unit_code         => p_bargaining_unit_code
14694     ,p_labour_union_member_flag     => p_labour_union_member_flag
14695     ,p_hourly_salaried_code         => p_hourly_salaried_code
14696     ,p_ass_attribute_category       => p_ass_attribute_category
14697     ,p_ass_attribute1               => p_ass_attribute1
14698     ,p_ass_attribute2               => p_ass_attribute2
14699     ,p_ass_attribute3               => p_ass_attribute3
14700     ,p_ass_attribute4               => p_ass_attribute4
14701     ,p_ass_attribute5               => p_ass_attribute5
14702     ,p_ass_attribute6               => p_ass_attribute6
14703     ,p_ass_attribute7               => p_ass_attribute7
14704     ,p_ass_attribute8               => p_ass_attribute8
14705     ,p_ass_attribute9               => p_ass_attribute9
14706     ,p_ass_attribute10              => p_ass_attribute10
14707     ,p_ass_attribute11              => p_ass_attribute11
14708     ,p_ass_attribute12              => p_ass_attribute12
14709     ,p_ass_attribute13              => p_ass_attribute13
14710     ,p_ass_attribute14              => p_ass_attribute14
14711     ,p_ass_attribute15              => p_ass_attribute15
14712     ,p_ass_attribute16              => p_ass_attribute16
14713     ,p_ass_attribute17              => p_ass_attribute17
14714     ,p_ass_attribute18              => p_ass_attribute18
14715     ,p_ass_attribute19              => p_ass_attribute19
14716     ,p_ass_attribute20              => p_ass_attribute20
14717     ,p_ass_attribute21              => p_ass_attribute21
14718     ,p_ass_attribute22              => p_ass_attribute22
14719     ,p_ass_attribute23              => p_ass_attribute23
14720     ,p_ass_attribute24              => p_ass_attribute24
14721     ,p_ass_attribute25              => p_ass_attribute25
14722     ,p_ass_attribute26              => p_ass_attribute26
14723     ,p_ass_attribute27              => p_ass_attribute27
14724     ,p_ass_attribute28              => p_ass_attribute28
14725     ,p_ass_attribute29              => p_ass_attribute29
14726     ,p_ass_attribute30              => p_ass_attribute30
14727     ,p_title                        => p_title
14728     ,p_contract_id		    => p_contract_id
14729     ,p_establishment_id		    => p_establishment_id
14730     ,p_collective_agreement_id	    => p_collective_agreement_id
14731     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14732     ,p_notice_period		    => p_notice_period
14733     ,p_notice_period_uom	    => p_notice_period_uom
14734     ,p_employee_category	    => p_employee_category
14735     ,p_work_at_home		    => p_work_at_home
14736     ,p_job_post_source_name	    => p_job_post_source_name
14737     ,p_segment1                     => p_tax_unit
14738     ,p_segment2                     => p_timecard_approver
14739     ,p_segment3                     => p_timecard_required
14740     ,p_segment4                     => p_work_schedule
14741     ,p_segment5                     => p_shift
14742     ,p_segment6                     => p_spouse_salary
14743     ,p_segment7                     => p_legal_representative
14744     ,p_segment8                     => p_wc_override_code
14745     ,p_segment9                     => p_eeo_1_establishment
14746     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14747     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14748     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
14749     ,p_comment_id                   => p_comment_id
14750     ,p_effective_start_date         => p_effective_start_date
14751     ,p_effective_end_date           => p_effective_end_date
14752 -- Bug 944911
14753 -- Added new param
14754     ,p_concatenated_segments        => p_concatenated_segments
14755     ,p_concat_segments              => p_concat_segments
14756     ,p_no_managers_warning          => p_no_managers_warning
14757     ,p_other_manager_warning        => p_other_manager_warning
14758     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14759     );
14760  if g_debug then
14761   hr_utility.set_location(' Leaving:'||l_proc, 40);
14762  end if;
14763 end update_us_emp_asg;
14764 -- End of update_us_emp_asg OVERLOADED procedure
14765 
14766 --
14767 -- ----------------------------------------------------------------------------
14768 -- |--------------------------< update_us_emp_asg --NEW2 >--------------------|
14769 -- ----------------------------------------------------------------------------
14770 --
14771 -- added new parameters p_hourly_salaried_warning
14772 
14773 
14774 procedure update_us_emp_asg
14775   (p_validate                     in     boolean
14776   ,p_effective_date               in     date
14777   ,p_datetrack_update_mode        in     varchar2
14778   ,p_assignment_id                in     number
14779   ,p_object_version_number        in out nocopy number
14780   ,p_supervisor_id                in     number
14781   ,p_assignment_number            in     varchar2
14782   ,p_change_reason                in     varchar2
14783   ,p_comments                     in     varchar2
14784   ,p_date_probation_end           in     date
14785   ,p_default_code_comb_id         in     number
14786   ,p_frequency                    in     varchar2
14787   ,p_internal_address_line        in     varchar2
14788   ,p_manager_flag                 in     varchar2
14789   ,p_normal_hours                 in     number
14790   ,p_perf_review_period           in     number
14791   ,p_perf_review_period_frequency in     varchar2
14792   ,p_probation_period             in     number
14793   ,p_probation_unit               in     varchar2
14794   ,p_sal_review_period            in     number
14795   ,p_sal_review_period_frequency  in     varchar2
14796   ,p_set_of_books_id              in     number
14797   ,p_source_type                  in     varchar2
14798   ,p_time_normal_finish           in     varchar2
14799   ,p_time_normal_start            in     varchar2
14800   ,p_bargaining_unit_code         in     varchar2
14801   ,p_labour_union_member_flag     in     varchar2
14802   ,p_hourly_salaried_code         in     varchar2
14803   ,p_ass_attribute_category       in     varchar2
14804   ,p_ass_attribute1               in     varchar2
14805   ,p_ass_attribute2               in     varchar2
14806   ,p_ass_attribute3               in     varchar2
14807   ,p_ass_attribute4               in     varchar2
14808   ,p_ass_attribute5               in     varchar2
14809   ,p_ass_attribute6               in     varchar2
14810   ,p_ass_attribute7               in     varchar2
14811   ,p_ass_attribute8               in     varchar2
14812   ,p_ass_attribute9               in     varchar2
14813   ,p_ass_attribute10              in     varchar2
14814   ,p_ass_attribute11              in     varchar2
14815   ,p_ass_attribute12              in     varchar2
14816   ,p_ass_attribute13              in     varchar2
14817   ,p_ass_attribute14              in     varchar2
14818   ,p_ass_attribute15              in     varchar2
14819   ,p_ass_attribute16              in     varchar2
14820   ,p_ass_attribute17              in     varchar2
14821   ,p_ass_attribute18              in     varchar2
14822   ,p_ass_attribute19              in     varchar2
14823   ,p_ass_attribute20              in     varchar2
14824   ,p_ass_attribute21              in     varchar2
14825   ,p_ass_attribute22              in     varchar2
14826   ,p_ass_attribute23              in     varchar2
14827   ,p_ass_attribute24              in     varchar2
14828   ,p_ass_attribute25              in     varchar2
14829   ,p_ass_attribute26              in     varchar2
14830   ,p_ass_attribute27              in     varchar2
14831   ,p_ass_attribute28              in     varchar2
14832   ,p_ass_attribute29              in     varchar2
14833   ,p_ass_attribute30              in     varchar2
14834   ,p_title                        in     varchar2
14835   ,p_tax_unit                     in     varchar2
14836   ,p_timecard_approver            in     varchar2
14837   ,p_timecard_required            in     varchar2
14838   ,p_work_schedule                in     varchar2
14839   ,p_shift                        in     varchar2
14840   ,p_spouse_salary                in     varchar2
14841   ,p_legal_representative         in     varchar2
14842   ,p_wc_override_code             in     varchar2
14843   ,p_eeo_1_establishment          in     varchar2
14844   -- Added for bug 1889914
14845   ,p_contract_id		  in     number
14846   ,p_establishment_id		  in 	 number
14847   ,p_collective_agreement_id	  in     number
14848   ,p_cagr_id_flex_num		  in     number
14849   ,p_notice_period		  in     number
14850   ,p_notice_period_uom	      	  in     varchar2
14851   ,p_employee_category	          in     varchar2
14852   ,p_work_at_home		  in     varchar2
14853   ,p_job_post_source_name	  in     varchar2
14854   ,p_supervisor_assignment_id     in     number
14855   ,p_cagr_grade_def_id		     out nocopy number
14856   ,p_cagr_concatenated_segments      out nocopy varchar2
14857   -- End 1889914
14858   ,p_comment_id                      out nocopy number
14859   ,p_soft_coding_keyflex_id          out nocopy number
14860   ,p_effective_start_date            out nocopy date
14861   ,p_effective_end_date              out nocopy date
14862 -- Bug 944911
14863 -- Amended p_concatenated_segments to be out
14864 -- Added p_concat_segments  - in param
14865   ,p_concatenated_segments           out nocopy varchar2
14866   ,p_concat_segments              in     varchar2
14867   ,p_no_managers_warning             out nocopy boolean
14868   ,p_other_manager_warning           out nocopy boolean
14869   ,p_hourly_salaried_warning         out nocopy boolean
14870   )
14871 is
14872   --
14873   -- Declare cursors and local variables
14874   --
14875   l_proc                       varchar2(72);
14876   l_effective_date             date;
14877   l_legislation_code           per_business_groups.legislation_code%TYPE;
14878   l_gsp_post_process_warning   varchar2(2000); -- bug 2999562
14879 
14880   --
14881   cursor check_legislation
14882     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14883      c_effective_date date
14884     )
14885   is
14886     select bgp.legislation_code
14887     from per_all_assignments_f asg,
14888          per_business_groups_perf bgp
14889     where asg.business_group_id = bgp.business_group_id
14890     and   asg.assignment_id     = c_assignment_id
14891     and   c_effective_date
14892       between effective_start_date and effective_end_date;
14893   --
14894 begin
14895  if g_debug then
14896   l_proc := g_package||'update_us_emp_asg';
14897   hr_utility.set_location('Entering:'|| l_proc, 10);
14898  end if;
14899   --
14900   -- Truncate date variables
14901   --
14902   l_effective_date := trunc(p_effective_date);
14903   --
14904   -- Validate in addition to Table Handlers
14905   --
14906   -- Check that the assignment exists.
14907   --
14908   open check_legislation(p_assignment_id, l_effective_date);
14909   fetch check_legislation into l_legislation_code;
14910   if check_legislation%notfound then
14911     close check_legislation;
14912     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14913     hr_utility.raise_error;
14914   end if;
14915   close check_legislation;
14916  if g_debug then
14917   hr_utility.set_location(l_proc, 20);
14918  end if;
14919   --
14920   -- Check that the legislation of the specified business group is 'US'.
14921   --
14922   if l_legislation_code <> 'US' then
14923     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14924     hr_utility.set_message_token('LEG_CODE','US');
14925     hr_utility.raise_error;
14926   end if;
14927  if g_debug then
14928   hr_utility.set_location(l_proc, 30);
14929  end if;
14930   --
14931   -- Call update_emp_asg business process
14932   --
14933   hr_assignment_api.update_emp_asg
14934     (p_validate                     => p_validate
14935     ,p_effective_date               => p_effective_date
14936     ,p_datetrack_update_mode        => p_datetrack_update_mode
14937     ,p_assignment_id                => p_assignment_id
14938     ,p_object_version_number        => p_object_version_number
14939     ,p_supervisor_id                => p_supervisor_id
14940     ,p_assignment_number            => p_assignment_number
14941     ,p_change_reason                => p_change_reason
14942     ,p_comments                     => p_comments
14943     ,p_date_probation_end           => p_date_probation_end
14944     ,p_default_code_comb_id         => p_default_code_comb_id
14945     ,p_frequency                    => p_frequency
14946     ,p_internal_address_line        => p_internal_address_line
14947     ,p_manager_flag                 => p_manager_flag
14948     ,p_normal_hours                 => p_normal_hours
14949     ,p_perf_review_period           => p_perf_review_period
14950     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14951     ,p_probation_period             => p_probation_period
14952     ,p_probation_unit               => p_probation_unit
14953     ,p_sal_review_period            => p_sal_review_period
14954     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14955     ,p_set_of_books_id              => p_set_of_books_id
14956     ,p_source_type                  => p_source_type
14957     ,p_time_normal_finish           => p_time_normal_finish
14958     ,p_time_normal_start            => p_time_normal_start
14959     ,p_bargaining_unit_code         => p_bargaining_unit_code
14960     ,p_labour_union_member_flag     => p_labour_union_member_flag
14961     ,p_hourly_salaried_code         => p_hourly_salaried_code
14962     ,p_ass_attribute_category       => p_ass_attribute_category
14963     ,p_ass_attribute1               => p_ass_attribute1
14964     ,p_ass_attribute2               => p_ass_attribute2
14965     ,p_ass_attribute3               => p_ass_attribute3
14966     ,p_ass_attribute4               => p_ass_attribute4
14967     ,p_ass_attribute5               => p_ass_attribute5
14968     ,p_ass_attribute6               => p_ass_attribute6
14969     ,p_ass_attribute7               => p_ass_attribute7
14970     ,p_ass_attribute8               => p_ass_attribute8
14971     ,p_ass_attribute9               => p_ass_attribute9
14972     ,p_ass_attribute10              => p_ass_attribute10
14973     ,p_ass_attribute11              => p_ass_attribute11
14974     ,p_ass_attribute12              => p_ass_attribute12
14975     ,p_ass_attribute13              => p_ass_attribute13
14976     ,p_ass_attribute14              => p_ass_attribute14
14977     ,p_ass_attribute15              => p_ass_attribute15
14978     ,p_ass_attribute16              => p_ass_attribute16
14979     ,p_ass_attribute17              => p_ass_attribute17
14980     ,p_ass_attribute18              => p_ass_attribute18
14981     ,p_ass_attribute19              => p_ass_attribute19
14982     ,p_ass_attribute20              => p_ass_attribute20
14983     ,p_ass_attribute21              => p_ass_attribute21
14984     ,p_ass_attribute22              => p_ass_attribute22
14985     ,p_ass_attribute23              => p_ass_attribute23
14986     ,p_ass_attribute24              => p_ass_attribute24
14987     ,p_ass_attribute25              => p_ass_attribute25
14988     ,p_ass_attribute26              => p_ass_attribute26
14989     ,p_ass_attribute27              => p_ass_attribute27
14990     ,p_ass_attribute28              => p_ass_attribute28
14991     ,p_ass_attribute29              => p_ass_attribute29
14992     ,p_ass_attribute30              => p_ass_attribute30
14993     ,p_title                        => p_title
14994     ,p_contract_id		    => p_contract_id
14995     ,p_establishment_id		    => p_establishment_id
14996     ,p_collective_agreement_id	    => p_collective_agreement_id
14997     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14998     ,p_notice_period		    => p_notice_period
14999     ,p_notice_period_uom	    => p_notice_period_uom
15000     ,p_employee_category	    => p_employee_category
15001     ,p_work_at_home		    => p_work_at_home
15002     ,p_job_post_source_name	    => p_job_post_source_name
15003     ,p_segment1                     => p_tax_unit
15004     ,p_segment2                     => p_timecard_approver
15005     ,p_segment3                     => p_timecard_required
15006     ,p_segment4                     => p_work_schedule
15007     ,p_segment5                     => p_shift
15008     ,p_segment6                     => p_spouse_salary
15009     ,p_segment7                     => p_legal_representative
15010     ,p_segment8                     => p_wc_override_code
15011     ,p_segment9                     => p_eeo_1_establishment
15012     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
15013     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
15014     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
15015     ,p_comment_id                   => p_comment_id
15016     ,p_effective_start_date         => p_effective_start_date
15017     ,p_effective_end_date           => p_effective_end_date
15018 -- Bug 944911
15019 -- Added new param
15020     ,p_concatenated_segments        => p_concatenated_segments
15021     ,p_concat_segments              => p_concat_segments
15022     ,p_no_managers_warning          => p_no_managers_warning
15023     ,p_other_manager_warning        => p_other_manager_warning
15024     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
15025     ,p_gsp_post_process_warning     => l_gsp_post_process_warning -- bug 2999562
15026     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
15027     );
15028  if g_debug then
15029   hr_utility.set_location(' Leaving:'||l_proc, 40);
15030  end if;
15031 end update_us_emp_asg;
15032 -- End of update_us_emp_asg OVERLOADED procedure
15033 
15034 --
15035 -- ----------------------------------------------------------------------------
15036 -- |--------------------------< update_us_emp_asg --NEW3 >--------------------|
15037 -- ----------------------------------------------------------------------------
15038 --
15039 -- added new parameters p_gsp_post_process_warning
15040 
15041 
15042 procedure update_us_emp_asg
15043   (p_validate                     in     boolean
15044   ,p_effective_date               in     date
15045   ,p_datetrack_update_mode        in     varchar2
15046   ,p_assignment_id                in     number
15047   ,p_object_version_number        in out nocopy number
15048   ,p_supervisor_id                in     number
15049   ,p_assignment_number            in     varchar2
15050   ,p_change_reason                in     varchar2
15051   ,p_comments                     in     varchar2
15052   ,p_date_probation_end           in     date
15053   ,p_default_code_comb_id         in     number
15054   ,p_frequency                    in     varchar2
15055   ,p_internal_address_line        in     varchar2
15056   ,p_manager_flag                 in     varchar2
15057   ,p_normal_hours                 in     number
15058   ,p_perf_review_period           in     number
15059   ,p_perf_review_period_frequency in     varchar2
15060   ,p_probation_period             in     number
15061   ,p_probation_unit               in     varchar2
15062   ,p_sal_review_period            in     number
15063   ,p_sal_review_period_frequency  in     varchar2
15064   ,p_set_of_books_id              in     number
15065   ,p_source_type                  in     varchar2
15066   ,p_time_normal_finish           in     varchar2
15067   ,p_time_normal_start            in     varchar2
15068   ,p_bargaining_unit_code         in     varchar2
15069   ,p_labour_union_member_flag     in     varchar2
15070   ,p_hourly_salaried_code         in     varchar2
15071   ,p_ass_attribute_category       in     varchar2
15072   ,p_ass_attribute1               in     varchar2
15073   ,p_ass_attribute2               in     varchar2
15074   ,p_ass_attribute3               in     varchar2
15075   ,p_ass_attribute4               in     varchar2
15076   ,p_ass_attribute5               in     varchar2
15077   ,p_ass_attribute6               in     varchar2
15078   ,p_ass_attribute7               in     varchar2
15079   ,p_ass_attribute8               in     varchar2
15080   ,p_ass_attribute9               in     varchar2
15081   ,p_ass_attribute10              in     varchar2
15082   ,p_ass_attribute11              in     varchar2
15083   ,p_ass_attribute12              in     varchar2
15084   ,p_ass_attribute13              in     varchar2
15085   ,p_ass_attribute14              in     varchar2
15086   ,p_ass_attribute15              in     varchar2
15087   ,p_ass_attribute16              in     varchar2
15088   ,p_ass_attribute17              in     varchar2
15089   ,p_ass_attribute18              in     varchar2
15090   ,p_ass_attribute19              in     varchar2
15091   ,p_ass_attribute20              in     varchar2
15092   ,p_ass_attribute21              in     varchar2
15093   ,p_ass_attribute22              in     varchar2
15094   ,p_ass_attribute23              in     varchar2
15095   ,p_ass_attribute24              in     varchar2
15096   ,p_ass_attribute25              in     varchar2
15097   ,p_ass_attribute26              in     varchar2
15098   ,p_ass_attribute27              in     varchar2
15099   ,p_ass_attribute28              in     varchar2
15100   ,p_ass_attribute29              in     varchar2
15101   ,p_ass_attribute30              in     varchar2
15102   ,p_title                        in     varchar2
15103   ,p_tax_unit                     in     varchar2
15104   ,p_timecard_approver            in     varchar2
15105   ,p_timecard_required            in     varchar2
15106   ,p_work_schedule                in     varchar2
15107   ,p_shift                        in     varchar2
15108   ,p_spouse_salary                in     varchar2
15109   ,p_legal_representative         in     varchar2
15110   ,p_wc_override_code             in     varchar2
15111   ,p_eeo_1_establishment          in     varchar2
15112   -- Added for bug 1889914
15113   ,p_contract_id		  in     number
15114   ,p_establishment_id		  in 	 number
15115   ,p_collective_agreement_id	  in     number
15116   ,p_cagr_id_flex_num		  in     number
15117   ,p_notice_period		  in     number
15118   ,p_notice_period_uom	      	  in     varchar2
15119   ,p_employee_category	          in     varchar2
15120   ,p_work_at_home		  in     varchar2
15121   ,p_job_post_source_name	  in     varchar2
15122   ,p_supervisor_assignment_id     in     number
15123   ,p_cagr_grade_def_id		     out nocopy number
15124   ,p_cagr_concatenated_segments      out nocopy varchar2
15125   -- End 1889914
15126   ,p_comment_id                      out nocopy number
15127   ,p_soft_coding_keyflex_id          out nocopy number
15128   ,p_effective_start_date            out nocopy date
15129   ,p_effective_end_date              out nocopy date
15130 -- Bug 944911
15131 -- Amended p_concatenated_segments to be out
15132 -- Added p_concat_segments  - in param
15133   ,p_concatenated_segments           out nocopy varchar2
15134   ,p_concat_segments              in     varchar2
15135   ,p_no_managers_warning             out nocopy boolean
15136   ,p_other_manager_warning           out nocopy boolean
15137   ,p_hourly_salaried_warning         out nocopy boolean
15138   ,p_gsp_post_process_warning        out nocopy varchar2
15139   )
15140 is
15141   --
15142   -- Declare cursors and local variables
15143   --
15144   l_proc                       varchar2(72);
15145   l_effective_date             date;
15146   l_legislation_code           per_business_groups.legislation_code%TYPE;
15147 
15148   --
15149   cursor check_legislation
15150     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
15151      c_effective_date date
15152     )
15153   is
15154     select bgp.legislation_code
15155     from per_all_assignments_f asg,
15156          per_business_groups_perf bgp
15157     where asg.business_group_id = bgp.business_group_id
15158     and   asg.assignment_id     = c_assignment_id
15159     and   c_effective_date
15160       between effective_start_date and effective_end_date;
15161   --
15162 begin
15163  if g_debug then
15164   l_proc := g_package||'update_us_emp_asg';
15165   hr_utility.set_location('Entering:'|| l_proc, 10);
15166  end if;
15167   --
15168   -- Truncate date variables
15169   --
15170   l_effective_date := trunc(p_effective_date);
15171   --
15172   -- Validate in addition to Table Handlers
15173   --
15174   -- Check that the assignment exists.
15175   --
15176   open check_legislation(p_assignment_id, l_effective_date);
15177   fetch check_legislation into l_legislation_code;
15178   if check_legislation%notfound then
15179     close check_legislation;
15180     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
15181     hr_utility.raise_error;
15182   end if;
15183   close check_legislation;
15184  if g_debug then
15185   hr_utility.set_location(l_proc, 20);
15186  end if;
15187   --
15188   -- Check that the legislation of the specified business group is 'US'.
15189   --
15190   if l_legislation_code <> 'US' then
15191     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
15192     hr_utility.set_message_token('LEG_CODE','US');
15193     hr_utility.raise_error;
15194   end if;
15195  if g_debug then
15196   hr_utility.set_location(l_proc, 30);
15197  end if;
15198   --
15199   -- Call update_emp_asg business process
15200   --
15201   hr_assignment_api.update_emp_asg
15202     (p_validate                     => p_validate
15203     ,p_effective_date               => p_effective_date
15204     ,p_datetrack_update_mode        => p_datetrack_update_mode
15205     ,p_assignment_id                => p_assignment_id
15206     ,p_object_version_number        => p_object_version_number
15207     ,p_supervisor_id                => p_supervisor_id
15208     ,p_assignment_number            => p_assignment_number
15209     ,p_change_reason                => p_change_reason
15210     ,p_comments                     => p_comments
15211     ,p_date_probation_end           => p_date_probation_end
15212     ,p_default_code_comb_id         => p_default_code_comb_id
15213     ,p_frequency                    => p_frequency
15214     ,p_internal_address_line        => p_internal_address_line
15215     ,p_manager_flag                 => p_manager_flag
15216     ,p_normal_hours                 => p_normal_hours
15217     ,p_perf_review_period           => p_perf_review_period
15218     ,p_perf_review_period_frequency => p_perf_review_period_frequency
15219     ,p_probation_period             => p_probation_period
15220     ,p_probation_unit               => p_probation_unit
15221     ,p_sal_review_period            => p_sal_review_period
15222     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
15223     ,p_set_of_books_id              => p_set_of_books_id
15224     ,p_source_type                  => p_source_type
15225     ,p_time_normal_finish           => p_time_normal_finish
15226     ,p_time_normal_start            => p_time_normal_start
15227     ,p_bargaining_unit_code         => p_bargaining_unit_code
15228     ,p_labour_union_member_flag     => p_labour_union_member_flag
15229     ,p_hourly_salaried_code         => p_hourly_salaried_code
15230     ,p_ass_attribute_category       => p_ass_attribute_category
15231     ,p_ass_attribute1               => p_ass_attribute1
15232     ,p_ass_attribute2               => p_ass_attribute2
15233     ,p_ass_attribute3               => p_ass_attribute3
15234     ,p_ass_attribute4               => p_ass_attribute4
15235     ,p_ass_attribute5               => p_ass_attribute5
15236     ,p_ass_attribute6               => p_ass_attribute6
15237     ,p_ass_attribute7               => p_ass_attribute7
15238     ,p_ass_attribute8               => p_ass_attribute8
15239     ,p_ass_attribute9               => p_ass_attribute9
15240     ,p_ass_attribute10              => p_ass_attribute10
15241     ,p_ass_attribute11              => p_ass_attribute11
15242     ,p_ass_attribute12              => p_ass_attribute12
15243     ,p_ass_attribute13              => p_ass_attribute13
15244     ,p_ass_attribute14              => p_ass_attribute14
15245     ,p_ass_attribute15              => p_ass_attribute15
15246     ,p_ass_attribute16              => p_ass_attribute16
15247     ,p_ass_attribute17              => p_ass_attribute17
15248     ,p_ass_attribute18              => p_ass_attribute18
15249     ,p_ass_attribute19              => p_ass_attribute19
15250     ,p_ass_attribute20              => p_ass_attribute20
15251     ,p_ass_attribute21              => p_ass_attribute21
15252     ,p_ass_attribute22              => p_ass_attribute22
15253     ,p_ass_attribute23              => p_ass_attribute23
15254     ,p_ass_attribute24              => p_ass_attribute24
15255     ,p_ass_attribute25              => p_ass_attribute25
15256     ,p_ass_attribute26              => p_ass_attribute26
15257     ,p_ass_attribute27              => p_ass_attribute27
15258     ,p_ass_attribute28              => p_ass_attribute28
15259     ,p_ass_attribute29              => p_ass_attribute29
15260     ,p_ass_attribute30              => p_ass_attribute30
15261     ,p_title                        => p_title
15262     ,p_contract_id		    => p_contract_id
15263     ,p_establishment_id		    => p_establishment_id
15264     ,p_collective_agreement_id	    => p_collective_agreement_id
15265     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
15266     ,p_notice_period		    => p_notice_period
15267     ,p_notice_period_uom	    => p_notice_period_uom
15268     ,p_employee_category	    => p_employee_category
15269     ,p_work_at_home		    => p_work_at_home
15270     ,p_job_post_source_name	    => p_job_post_source_name
15271     ,p_segment1                     => p_tax_unit
15272     ,p_segment2                     => p_timecard_approver
15273     ,p_segment3                     => p_timecard_required
15274     ,p_segment4                     => p_work_schedule
15275     ,p_segment5                     => p_shift
15276     ,p_segment6                     => p_spouse_salary
15277     ,p_segment7                     => p_legal_representative
15278     ,p_segment8                     => p_wc_override_code
15279     ,p_segment9                     => p_eeo_1_establishment
15280     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
15281     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
15282     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
15283     ,p_comment_id                   => p_comment_id
15284     ,p_effective_start_date         => p_effective_start_date
15285     ,p_effective_end_date           => p_effective_end_date
15286 -- Bug 944911
15287 -- Added new param
15288     ,p_concatenated_segments        => p_concatenated_segments
15289     ,p_concat_segments              => p_concat_segments
15290     ,p_no_managers_warning          => p_no_managers_warning
15291     ,p_other_manager_warning        => p_other_manager_warning
15292     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
15293     ,p_gsp_post_process_warning     => p_gsp_post_process_warning
15294     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
15295     );
15296  if g_debug then
15297   hr_utility.set_location(' Leaving:'||l_proc, 40);
15298  end if;
15299 end update_us_emp_asg;
15300 -- End of update_us_emp_asg OVERLOADED procedure
15301 
15302 --
15303 -- ----------------------------------------------------------------------------
15304 -- |---------------------< update_emp_asg_criteria -- OLD>---------------------|
15305 -- ----------------------------------------------------------------------------
15306 --
15307 
15308 procedure update_emp_asg_criteria
15309   (p_effective_date               in     date
15310   ,p_datetrack_update_mode        in     varchar2
15311   ,p_assignment_id                in     number
15312   ,p_validate                     in     boolean
15313   ,p_called_from_mass_update      in     boolean
15314   ,p_grade_id                     in     number
15315   ,p_position_id                  in     number
15316   ,p_job_id                       in     number
15317   ,p_payroll_id                   in     number
15318   ,p_location_id                  in     number
15319   ,p_organization_id              in     number
15320   ,p_pay_basis_id                 in     number
15321   ,p_segment1                     in     varchar2
15322   ,p_segment2                     in     varchar2
15323   ,p_segment3                     in     varchar2
15324   ,p_segment4                     in     varchar2
15325   ,p_segment5                     in     varchar2
15326   ,p_segment6                     in     varchar2
15327   ,p_segment7                     in     varchar2
15328   ,p_segment8                     in     varchar2
15329   ,p_segment9                     in     varchar2
15330   ,p_segment10                    in     varchar2
15331   ,p_segment11                    in     varchar2
15332   ,p_segment12                    in     varchar2
15333   ,p_segment13                    in     varchar2
15334   ,p_segment14                    in     varchar2
15335   ,p_segment15                    in     varchar2
15336   ,p_segment16                    in     varchar2
15337   ,p_segment17                    in     varchar2
15338   ,p_segment18                    in     varchar2
15339   ,p_segment19                    in     varchar2
15340   ,p_segment20                    in     varchar2
15341   ,p_segment21                    in     varchar2
15342   ,p_segment22                    in     varchar2
15343   ,p_segment23                    in     varchar2
15344   ,p_segment24                    in     varchar2
15345   ,p_segment25                    in     varchar2
15346   ,p_segment26                    in     varchar2
15347   ,p_segment27                    in     varchar2
15348   ,p_segment28                    in     varchar2
15349   ,p_segment29                    in     varchar2
15350   ,p_segment30                    in     varchar2
15351   ,p_employment_category          in     varchar2
15352 -- Bug 944911
15353 -- Amended p_group_name to out
15354 -- Added new param p_pgp_concat_segments - for sec asg procs
15355 -- for others added p_concat_segments
15356   ,p_concat_segments              in     varchar2
15357   ,p_grade_ladder_pgm_id          in     number
15358   ,p_supervisor_assignment_id     in     number
15359   ,p_people_group_id              in out nocopy number --bug 2359997
15360   ,p_object_version_number        in out nocopy number
15361   ,p_special_ceiling_step_id      in out nocopy number
15362   ,p_group_name                      out nocopy varchar2
15363   ,p_effective_start_date            out nocopy date
15364   ,p_effective_end_date              out nocopy date
15365   ,p_org_now_no_manager_warning      out nocopy boolean
15366   ,p_other_manager_warning           out nocopy boolean
15367   ,p_spp_delete_warning              out nocopy boolean
15368   ,p_entries_changed_warning         out nocopy varchar2
15369   ,p_tax_district_changed_warning    out nocopy boolean
15370   ) is
15371 
15372     --
15373     -- Declare cursors and local variables
15374     --
15375     -- Out variables
15376     --
15377     l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
15378     l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
15379     l_entries_changed_warning      varchar2(1) := 'N';
15380     l_group_name                   pay_people_groups.group_name%TYPE;
15381     l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
15382     l_org_now_no_manager_warning   boolean;
15383     l_other_manager_warning        boolean;
15384     l_people_group_id              per_all_assignments_f.people_group_id%TYPE
15385                                    := p_people_group_id; -- bug 2359997
15386     l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE
15387                                    := p_special_ceiling_step_id; --3485599
15388     l_spp_delete_warning           boolean;
15389     l_tax_district_changed_warning boolean;
15390 
15391     l_soft_coding_keyflex_id       number;
15392     l_concatenated_segments	   hr_soft_coding_keyflex.concatenated_segments%TYPE;
15393     l_contract_id		   number;
15394     l_establishment_id		   number;
15395     l_scl_segment1		   varchar2(60);
15396     l_proc                         varchar2(72) := g_package||'update_emp_asg_criteria';
15397 
15398     -- Start of fix 3553286
15399     -- Bug 2656155
15400     --p_jobid                        number := p_job_id;
15401     --p_org_id                       number := p_organization_id;
15402     --
15403     -- End of 3553286
15404 
15405  BEGIN
15406 
15407     l_object_version_number := p_object_version_number;
15408     --
15409  if g_debug then
15410     hr_utility.set_location('Entering:'|| l_proc, 5);
15411  end if;
15412 
15413  -- Start of fix 3553286
15414  -- Start of bug fix 2656155
15415  -- This procedure will return the job_id and organization_id of a position
15416  --
15417  -- Bug 3005283 : Starts here
15418  -- Description : This code should not be executed if position_id is null, otherwise org_id/job_id will be
15419  -- set to NULL if position_id is not passed to this procedure.  So added IF condition to check for that if
15420  -- position_id is not null and it is called from Mass Update form.
15421  --
15422  --  if (p_called_from_mass_update = TRUE and p_position_id is not null) then
15423  --    if (p_jobid is null) or (p_org_id is null) then
15424  --       hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
15425  --                                       p_jobid, p_org_id);
15426  --    end if;
15427  --   end if;
15428  --
15429  -- Bug 3005283 : Ends here.
15430  --
15431  -- End of fix 2656155
15432  -- End of fix 3553286
15433 
15434     --
15435     -- Calling New Overloaded Procedure
15436     --
15437 
15438     hr_assignment_api.update_emp_asg_criteria
15439       (p_validate                     =>  p_validate
15440       ,p_effective_date               =>  p_effective_date
15441       ,p_datetrack_update_mode        =>  p_datetrack_update_mode
15442       ,p_called_from_mass_update      =>  p_called_from_mass_update
15443       ,p_assignment_id                =>  p_assignment_id
15444       ,p_object_version_number        =>  l_object_version_number
15445       ,p_grade_id                     =>  p_grade_id
15446       ,p_position_id                  =>  p_position_id
15447       ,p_job_id                       =>  p_job_id -- Bug 2656155 -- 3553286
15448       ,p_payroll_id                   =>  p_payroll_id
15449       ,p_location_id                  =>  p_location_id
15450       ,p_special_ceiling_step_id      =>  l_special_ceiling_step_id
15451       ,p_organization_id              =>  p_organization_id -- Bug 2656155 -- 3553286
15452       ,p_pay_basis_id                 =>  p_pay_basis_id
15453       ,p_segment1                     =>  p_segment1
15454       ,p_segment2                     =>  p_segment2
15455       ,p_segment3                     =>  p_segment3
15456       ,p_segment4                     =>  p_segment4
15457       ,p_segment5                     =>  p_segment5
15458       ,p_segment6                     =>  p_segment6
15459       ,p_segment7                     =>  p_segment7
15460       ,p_segment8                     =>  p_segment8
15461       ,p_segment9                     =>  p_segment9
15462       ,p_segment10                    =>  p_segment10
15463       ,p_segment11                    =>  p_segment11
15464       ,p_segment12                    =>  p_segment12
15465       ,p_segment13                    =>  p_segment13
15466       ,p_segment14                    =>  p_segment14
15467       ,p_segment15                    =>  p_segment15
15468       ,p_segment16                    =>  p_segment16
15469       ,p_segment17                    =>  p_segment17
15470       ,p_segment18                    =>  p_segment18
15471       ,p_segment19                    =>  p_segment19
15472       ,p_segment20                    =>  p_segment20
15473       ,p_segment21                    =>  p_segment21
15474       ,p_segment22                    =>  p_segment22
15475       ,p_segment23                    =>  p_segment23
15476       ,p_segment24                    =>  p_segment24
15477       ,p_segment25                    =>  p_segment25
15478       ,p_segment26                    =>  p_segment26
15479       ,p_segment27                    =>  p_segment27
15480       ,p_segment28                    =>  p_segment28
15481       ,p_segment29                    =>  p_segment29
15482       ,p_segment30                    =>  p_segment30
15483       ,p_concat_segments              =>  p_concat_segments
15484       ,p_grade_ladder_pgm_id          =>  p_grade_ladder_pgm_id
15485       ,p_supervisor_assignment_id     =>  p_supervisor_assignment_id
15486       ,p_group_name                   =>  l_group_name
15487       ,p_employment_category          =>  p_employment_category
15488       ,p_effective_start_date         =>  l_effective_start_date
15489       ,p_effective_end_date           =>  l_effective_end_date
15490       ,p_people_group_id              =>  l_people_group_id
15491       ,p_org_now_no_manager_warning   =>  l_org_now_no_manager_warning
15492       ,p_other_manager_warning        =>  l_other_manager_warning
15493       ,p_spp_delete_warning           =>  l_spp_delete_warning
15494       ,p_entries_changed_warning      =>  l_entries_changed_warning
15495       ,p_tax_district_changed_warning =>  l_tax_district_changed_warning
15496       ,p_soft_coding_keyflex_id       =>  l_soft_coding_keyflex_id
15497       ,p_concatenated_segments        =>  l_concatenated_segments
15498 --2689059: changed the following: must pass hr_api defaults to NEW update API
15499       ,p_contract_id                  =>  hr_api.g_number  --l_contract_id
15500       ,p_establishment_id             =>  hr_api.g_number  --l_establishment_id
15501       ,p_scl_segment1                 =>  hr_api.g_varchar2  --l_scl_segment1
15502       ) ;
15503 
15504 
15505       --
15506       -- Set all output arguments
15507       --
15508       p_effective_end_date           := l_effective_end_date;
15509       p_effective_start_date         := l_effective_start_date;
15510       p_people_group_id              := l_people_group_id;
15511       p_group_name                   := l_group_name;
15512       p_entries_changed_warning      := l_entries_changed_warning;
15513       p_object_version_number        := l_object_version_number;
15514       p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
15515       p_other_manager_warning        := l_other_manager_warning;
15516       p_special_ceiling_step_id      := l_special_ceiling_step_id;
15517       p_spp_delete_warning           := l_spp_delete_warning;
15518       p_tax_district_changed_warning := l_tax_district_changed_warning;
15519 
15520  if g_debug then
15521     hr_utility.set_location('Leaving:'|| l_proc, 20);
15522  end if;
15523 
15524 End update_emp_asg_criteria;
15525 
15526 
15527 -- ----------------------------------------------------------------------------
15528 -- |---------------------< update_emp_asg_criteria-- NEW >---------------------|
15529 -- ----------------------------------------------------------------------------
15530 --
15531 
15532 procedure update_emp_asg_criteria
15533   (p_effective_date               in     date
15534   ,p_datetrack_update_mode        in     varchar2
15535   ,p_assignment_id                in     number
15536   ,p_validate                     in     boolean
15537   ,p_called_from_mass_update      in     boolean
15538   ,p_grade_id                     in     number
15539   ,p_position_id                  in     number
15540   ,p_job_id                       in     number
15541   ,p_payroll_id                   in     number
15542   ,p_location_id                  in     number
15543   ,p_organization_id              in     number
15544   ,p_pay_basis_id                 in     number
15545   ,p_segment1                     in     varchar2
15546   ,p_segment2                     in     varchar2
15547   ,p_segment3                     in     varchar2
15548   ,p_segment4                     in     varchar2
15549   ,p_segment5                     in     varchar2
15550   ,p_segment6                     in     varchar2
15551   ,p_segment7                     in     varchar2
15552   ,p_segment8                     in     varchar2
15553   ,p_segment9                     in     varchar2
15554   ,p_segment10                    in     varchar2
15555   ,p_segment11                    in     varchar2
15556   ,p_segment12                    in     varchar2
15557   ,p_segment13                    in     varchar2
15558   ,p_segment14                    in     varchar2
15559   ,p_segment15                    in     varchar2
15560   ,p_segment16                    in     varchar2
15561   ,p_segment17                    in     varchar2
15562   ,p_segment18                    in     varchar2
15563   ,p_segment19                    in     varchar2
15564   ,p_segment20                    in     varchar2
15565   ,p_segment21                    in     varchar2
15566   ,p_segment22                    in     varchar2
15567   ,p_segment23                    in     varchar2
15568   ,p_segment24                    in     varchar2
15569   ,p_segment25                    in     varchar2
15570   ,p_segment26                    in     varchar2
15571   ,p_segment27                    in     varchar2
15572   ,p_segment28                    in     varchar2
15573   ,p_segment29                    in     varchar2
15574   ,p_segment30                    in     varchar2
15575   ,p_employment_category          in     varchar2
15576 -- Bug 944911
15577 -- Amended p_group_name to out
15578 -- Added new param p_pgp_concat_segments - for sec asg procs
15579 -- for others added p_concat_segments
15580   ,p_concat_segments              in     varchar2
15581   ,p_contract_id                  in     number
15582   ,p_establishment_id             in     number
15583   ,p_scl_segment1                 in     varchar2
15584   ,p_grade_ladder_pgm_id          in     number
15585   ,p_supervisor_assignment_id     in     number
15586   ,p_object_version_number        in out nocopy number
15587   ,p_special_ceiling_step_id      in out nocopy number
15588   ,p_people_group_id              in out nocopy number
15589   ,p_soft_coding_keyflex_id       in out nocopy number
15590   ,p_group_name                      out nocopy varchar2
15591   ,p_effective_start_date            out nocopy date
15592   ,p_effective_end_date              out nocopy date
15593   ,p_org_now_no_manager_warning      out nocopy boolean
15594   ,p_other_manager_warning           out nocopy boolean
15595   ,p_spp_delete_warning              out nocopy boolean
15596   ,p_entries_changed_warning         out nocopy varchar2
15597   ,p_tax_district_changed_warning    out nocopy boolean
15598   ,p_concatenated_segments           out nocopy varchar2
15599   ) is
15600   --
15601   -- Declare cursors and local variables
15602   --
15603   -- Out variables
15604   --
15605   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
15606   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
15607   l_entries_changed_warning      varchar2(1) := 'N';
15608   l_group_name                   pay_people_groups.group_name%TYPE;
15609   l_old_group_name               pay_people_groups.group_name%TYPE;
15610   l_no_managers_warning          boolean;
15611   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
15612   l_org_now_no_manager_warning   boolean;
15613   l_other_manager_warning        boolean;
15614   l_hourly_salaried_warning      boolean;
15615   l_payroll_id_updated           boolean;
15616   l_people_group_id              per_all_assignments_f.people_group_id%TYPE
15617                                  := p_people_group_id; -- bug 2359997
15618   l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE
15619                                  := p_special_ceiling_step_id; -- bug 3485599
15620   l_spp_delete_warning           boolean;
15621   l_tax_district_changed_warning boolean;
15622   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
15623   --
15624   l_api_updating                 boolean;
15625   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
15626   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
15627   l_entries_changed              varchar2(1);
15628   l_legislation_code             per_business_groups.legislation_code%TYPE;
15629   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
15630   l_proc                         varchar2(72) :=
15631                                  g_package || 'update_emp_asg_criteria';
15632 
15633 -- Start of Fix for Bug 2622747
15634   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
15635   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15636   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15637 -- End of Fix for Bug 2622747
15638 
15639   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
15640 
15641  BEGIN
15642 
15643     l_object_version_number := p_object_version_number;
15644     --
15645  if g_debug then
15646     hr_utility.set_location('Entering:'|| l_proc, 5);
15647  end if;
15648 
15649     --
15650     -- Calling New Overloaded Procedure
15651     --
15652 
15653     hr_assignment_api.update_emp_asg_criteria
15654       (p_validate                     =>  p_validate
15655       ,p_effective_date               =>  p_effective_date
15656       ,p_datetrack_update_mode        =>  p_datetrack_update_mode
15657       ,p_called_from_mass_update      =>  p_called_from_mass_update
15658       ,p_assignment_id                =>  p_assignment_id
15659       ,p_object_version_number        =>  l_object_version_number
15660       ,p_grade_id                     =>  p_grade_id
15661       ,p_position_id                  =>  p_position_id
15662       ,p_job_id                       =>  p_job_id
15663       ,p_payroll_id                   =>  p_payroll_id
15664       ,p_location_id                  =>  p_location_id
15665       ,p_special_ceiling_step_id      =>  l_special_ceiling_step_id
15666       ,p_organization_id              =>  p_organization_id
15667       ,p_pay_basis_id                 =>  p_pay_basis_id
15668       ,p_segment1                     =>  p_segment1
15669       ,p_segment2                     =>  p_segment2
15670       ,p_segment3                     =>  p_segment3
15671       ,p_segment4                     =>  p_segment4
15672       ,p_segment5                     =>  p_segment5
15673       ,p_segment6                     =>  p_segment6
15674       ,p_segment7                     =>  p_segment7
15675       ,p_segment8                     =>  p_segment8
15676       ,p_segment9                     =>  p_segment9
15677       ,p_segment10                    =>  p_segment10
15678       ,p_segment11                    =>  p_segment11
15679       ,p_segment12                    =>  p_segment12
15680       ,p_segment13                    =>  p_segment13
15681       ,p_segment14                    =>  p_segment14
15682       ,p_segment15                    =>  p_segment15
15683       ,p_segment16                    =>  p_segment16
15684       ,p_segment17                    =>  p_segment17
15685       ,p_segment18                    =>  p_segment18
15686       ,p_segment19                    =>  p_segment19
15687       ,p_segment20                    =>  p_segment20
15688       ,p_segment21                    =>  p_segment21
15689       ,p_segment22                    =>  p_segment22
15690       ,p_segment23                    =>  p_segment23
15691       ,p_segment24                    =>  p_segment24
15692       ,p_segment25                    =>  p_segment25
15693       ,p_segment26                    =>  p_segment26
15694       ,p_segment27                    =>  p_segment27
15695       ,p_segment28                    =>  p_segment28
15696       ,p_segment29                    =>  p_segment29
15697       ,p_segment30                    =>  p_segment30
15698       ,p_concat_segments              =>  p_concat_segments
15699       ,p_grade_ladder_pgm_id          =>  p_grade_ladder_pgm_id
15700       ,p_supervisor_assignment_id     =>  p_supervisor_assignment_id
15701       ,p_employment_category          =>  p_employment_category
15702       ,p_contract_id                  =>  p_contract_id
15703       ,p_establishment_id             =>  p_establishment_id
15704       ,p_scl_segment1                 =>  p_scl_segment1
15705       ,p_group_name                   =>  l_group_name
15706       ,p_effective_start_date         =>  l_effective_start_date
15707       ,p_effective_end_date           =>  l_effective_end_date
15708       ,p_people_group_id              =>  l_people_group_id
15709       ,p_org_now_no_manager_warning   =>  l_org_now_no_manager_warning
15710       ,p_other_manager_warning        =>  l_other_manager_warning
15711       ,p_spp_delete_warning           =>  l_spp_delete_warning
15712       ,p_entries_changed_warning      =>  l_entries_changed_warning
15713       ,p_tax_district_changed_warning =>  l_tax_district_changed_warning
15714       ,p_soft_coding_keyflex_id       =>  l_soft_coding_keyflex_id
15715       ,p_concatenated_segments        =>  l_concatenated_segments
15716       ,p_gsp_post_process_warning     =>  l_gsp_post_process_warning -- bug 2999562
15717       ) ;
15718 
15719   --
15720   -- Set all output arguments
15721   --
15722   p_effective_end_date           := l_effective_end_date;
15723   p_effective_start_date         := l_effective_start_date;
15724   p_people_group_id              := l_people_group_id;
15725   p_group_name                   := l_group_name;
15726   p_entries_changed_warning      := l_entries_changed_warning;
15727   p_object_version_number        := l_object_version_number;
15728   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
15729   p_other_manager_warning        := l_other_manager_warning;
15730   p_special_ceiling_step_id      := l_special_ceiling_step_id;
15731   p_spp_delete_warning           := l_spp_delete_warning;
15732   p_tax_district_changed_warning := l_tax_district_changed_warning;
15733   --
15734   --
15735  if g_debug then
15736   hr_utility.set_location(' Leaving:'||l_proc, 997);
15737  end if;
15738   --
15739 end update_emp_asg_criteria;
15740 -- ----------------------------------------------------------------------------
15741 -- |---------------------< update_emp_asg_criteria-- NEW2 >-------------------|
15742 -- ----------------------------------------------------------------------------
15743 --
15744 
15745 procedure update_emp_asg_criteria
15746   (p_effective_date               in     date
15747   ,p_datetrack_update_mode        in     varchar2
15748   ,p_assignment_id                in     number
15749   ,p_validate                     in     boolean
15750   ,p_called_from_mass_update      in     boolean
15751   ,p_grade_id                     in     number
15752   ,p_position_id                  in     number
15753   ,p_job_id                       in     number
15754   ,p_payroll_id                   in     number
15755   ,p_location_id                  in     number
15756   ,p_organization_id              in     number
15757   ,p_pay_basis_id                 in     number
15758   ,p_segment1                     in     varchar2
15759   ,p_segment2                     in     varchar2
15760   ,p_segment3                     in     varchar2
15761   ,p_segment4                     in     varchar2
15762   ,p_segment5                     in     varchar2
15763   ,p_segment6                     in     varchar2
15764   ,p_segment7                     in     varchar2
15765   ,p_segment8                     in     varchar2
15766   ,p_segment9                     in     varchar2
15767   ,p_segment10                    in     varchar2
15768   ,p_segment11                    in     varchar2
15769   ,p_segment12                    in     varchar2
15770   ,p_segment13                    in     varchar2
15771   ,p_segment14                    in     varchar2
15772   ,p_segment15                    in     varchar2
15773   ,p_segment16                    in     varchar2
15774   ,p_segment17                    in     varchar2
15775   ,p_segment18                    in     varchar2
15776   ,p_segment19                    in     varchar2
15777   ,p_segment20                    in     varchar2
15778   ,p_segment21                    in     varchar2
15779   ,p_segment22                    in     varchar2
15780   ,p_segment23                    in     varchar2
15781   ,p_segment24                    in     varchar2
15782   ,p_segment25                    in     varchar2
15783   ,p_segment26                    in     varchar2
15784   ,p_segment27                    in     varchar2
15785   ,p_segment28                    in     varchar2
15786   ,p_segment29                    in     varchar2
15787   ,p_segment30                    in     varchar2
15788   ,p_employment_category          in     varchar2
15789 -- Bug 944911
15790 -- Amended p_group_name to out
15791 -- Added new param p_pgp_concat_segments - for sec asg procs
15792 -- for others added p_concat_segments
15793   ,p_concat_segments              in     varchar2
15794   ,p_contract_id                  in     number
15795   ,p_establishment_id             in     number
15796   ,p_scl_segment1                 in     varchar2
15797   ,p_grade_ladder_pgm_id          in     number
15798   ,p_supervisor_assignment_id     in     number
15799   ,p_object_version_number        in out nocopy number
15800   ,p_special_ceiling_step_id      in out nocopy number
15801   ,p_people_group_id              in out nocopy number
15802   ,p_soft_coding_keyflex_id       in out nocopy number
15803   ,p_group_name                      out nocopy varchar2
15804   ,p_effective_start_date            out nocopy date
15805   ,p_effective_end_date              out nocopy date
15806   ,p_org_now_no_manager_warning      out nocopy boolean
15807   ,p_other_manager_warning           out nocopy boolean
15808   ,p_spp_delete_warning              out nocopy boolean
15809   ,p_entries_changed_warning         out nocopy varchar2
15810   ,p_tax_district_changed_warning    out nocopy boolean
15811   ,p_concatenated_segments           out nocopy varchar2
15812   ,p_gsp_post_process_warning        out nocopy varchar2
15813   ,p_create_salary_proposal       in     varchar2 default 'N' --added for bug 12911607
15814   ) is
15815   --
15816   -- Declare cursors and local variables
15817   --
15818   -- Out variables
15819   --
15820   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
15821   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
15822   l_entries_changed_warning      varchar2(1) := 'N';
15823   l_group_name                   pay_people_groups.group_name%TYPE;
15824   l_old_group_name               pay_people_groups.group_name%TYPE;
15825   l_no_managers_warning          boolean;
15826   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
15827   l_org_now_no_manager_warning   boolean;
15828   l_other_manager_warning        boolean;
15829   l_hourly_salaried_warning      boolean;
15830   l_payroll_id_updated           boolean;
15831   l_people_group_id              per_all_assignments_f.people_group_id%TYPE
15832                                  := p_people_group_id; -- bug 2359997
15833   l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE;
15834   l_spp_delete_warning           boolean;
15835   l_tax_district_changed_warning boolean;
15836   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
15837   l_gsp_post_process_warning     varchar2(2000); -- bug2999562
15838   --
15839   l_api_updating                 boolean;
15840   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
15841   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
15842   l_entries_changed              varchar2(1);
15843   l_legislation_code             per_business_groups.legislation_code%TYPE;
15844   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
15845   l_proc                         varchar2(72) :=
15846                                  g_package || 'update_emp_asg_criteria';
15847   l_validation_end_date          date;
15848   l_validation_start_date        date;
15849   l_effective_date               date;
15850   l_element_entry_id             number;
15851   l_organization_id              per_all_assignments_f.organization_id%type;
15852   l_location_id                  per_all_assignments_f.location_id%type;
15853   l_session_id                   number;
15854   l_step_id                      per_spinal_point_steps_f.step_id%TYPE;
15855 
15856 -- Start of Fix for Bug 2622747
15857   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
15858   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15859   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15860 -- End of Fix for Bug 2622747
15861 
15862   --
15863   -- bug 2359997 new variable to indicate whether people group key flex
15864   -- entered with a value.
15865   --
15866   l_pgp_null_ind               number(1) := 0;
15867   --
15868   -- bug 2359997 new variables for derived values where key flex id is known.
15869   --
15870   --
15871   l_pgp_segment1               varchar2(60) := p_segment1;
15872   l_pgp_segment2               varchar2(60) := p_segment2;
15873   l_pgp_segment3               varchar2(60) := p_segment3;
15874   l_pgp_segment4               varchar2(60) := p_segment4;
15875   l_pgp_segment5               varchar2(60) := p_segment5;
15876   l_pgp_segment6               varchar2(60) := p_segment6;
15877   l_pgp_segment7               varchar2(60) := p_segment7;
15878   l_pgp_segment8               varchar2(60) := p_segment8;
15879   l_pgp_segment9               varchar2(60) := p_segment9;
15880   l_pgp_segment10              varchar2(60) := p_segment10;
15881   l_pgp_segment11              varchar2(60) := p_segment11;
15882   l_pgp_segment12              varchar2(60) := p_segment12;
15883   l_pgp_segment13              varchar2(60) := p_segment13;
15884   l_pgp_segment14              varchar2(60) := p_segment14;
15885   l_pgp_segment15              varchar2(60) := p_segment15;
15886   l_pgp_segment16              varchar2(60) := p_segment16;
15887   l_pgp_segment17              varchar2(60) := p_segment17;
15888   l_pgp_segment18              varchar2(60) := p_segment18;
15889   l_pgp_segment19              varchar2(60) := p_segment19;
15890   l_pgp_segment20              varchar2(60) := p_segment20;
15891   l_pgp_segment21              varchar2(60) := p_segment21;
15892   l_pgp_segment22              varchar2(60) := p_segment22;
15893   l_pgp_segment23              varchar2(60) := p_segment23;
15894   l_pgp_segment24              varchar2(60) := p_segment24;
15895   l_pgp_segment25              varchar2(60) := p_segment25;
15896   l_pgp_segment26              varchar2(60) := p_segment26;
15897   l_pgp_segment27              varchar2(60) := p_segment27;
15898   l_pgp_segment28              varchar2(60) := p_segment28;
15899   l_pgp_segment29              varchar2(60) := p_segment29;
15900   l_pgp_segment30              varchar2(60) := p_segment30;
15901 
15902 -- Start of Fix for Bug 2622747
15903   l_scl_segment1               varchar2(60) := p_scl_segment1;
15904   l_scl_segment2               varchar2(60) := hr_api.g_varchar2 ;
15905   l_scl_segment3               varchar2(60) := hr_api.g_varchar2 ;
15906   l_scl_segment4               varchar2(60) := hr_api.g_varchar2 ;
15907   l_scl_segment5               varchar2(60) := hr_api.g_varchar2 ;
15908   l_scl_segment6               varchar2(60) := hr_api.g_varchar2 ;
15909   l_scl_segment7               varchar2(60) := hr_api.g_varchar2 ;
15910   l_scl_segment8               varchar2(60) := hr_api.g_varchar2 ;
15911   l_scl_segment9               varchar2(60) := hr_api.g_varchar2 ;
15912   l_scl_segment10              varchar2(60) := hr_api.g_varchar2 ;
15913   l_scl_segment11              varchar2(60) := hr_api.g_varchar2 ;
15914   l_scl_segment12              varchar2(60) := hr_api.g_varchar2 ;
15915   l_scl_segment13              varchar2(60) := hr_api.g_varchar2 ;
15916   l_scl_segment14              varchar2(60) := hr_api.g_varchar2 ;
15917   l_scl_segment15              varchar2(60) := hr_api.g_varchar2 ;
15918   l_scl_segment16              varchar2(60) := hr_api.g_varchar2 ;
15919   l_scl_segment17              varchar2(60) := hr_api.g_varchar2 ;
15920   l_scl_segment18              varchar2(60) := hr_api.g_varchar2 ;
15921   l_scl_segment19              varchar2(60) := hr_api.g_varchar2 ;
15922   l_scl_segment20              varchar2(60) := hr_api.g_varchar2 ;
15923   l_scl_segment21              varchar2(60) := hr_api.g_varchar2 ;
15924   l_scl_segment22              varchar2(60) := hr_api.g_varchar2 ;
15925   l_scl_segment23              varchar2(60) := hr_api.g_varchar2 ;
15926   l_scl_segment24              varchar2(60) := hr_api.g_varchar2 ;
15927   l_scl_segment25              varchar2(60) := hr_api.g_varchar2 ;
15928   l_scl_segment26              varchar2(60) := hr_api.g_varchar2 ;
15929   l_scl_segment27              varchar2(60) := hr_api.g_varchar2 ;
15930   l_scl_segment28              varchar2(60) := hr_api.g_varchar2 ;
15931   l_scl_segment29              varchar2(60) := hr_api.g_varchar2 ;
15932   l_scl_segment30              varchar2(60) := hr_api.g_varchar2 ;
15933   --
15934   lv_object_version_number        number := p_object_version_number ;
15935   lv_special_ceiling_step_id      number := p_special_ceiling_step_id ;
15936   lv_people_group_id              number := p_people_group_id ;
15937   lv_soft_coding_keyflex_id       number := p_soft_coding_keyflex_id ;
15938   --
15939 
15940 -- End of Fix for Bug 2622747
15941   l_element_entry_id1             number;  -- bug 4464072
15942   --
15943   -- bug 2359997 get pay_people_group segment values where
15944   -- people_group_id is known
15945   --
15946   cursor c_pgp_segments is
15947      select group_name,    --4103321
15948             segment1,
15949             segment2,
15950             segment3,
15951             segment4,
15952             segment5,
15953             segment6,
15954             segment7,
15955             segment8,
15956             segment9,
15957             segment10,
15958             segment11,
15959             segment12,
15960             segment13,
15961             segment14,
15962             segment15,
15963             segment16,
15964             segment17,
15965             segment18,
15966             segment19,
15967             segment20,
15968             segment21,
15969             segment22,
15970             segment23,
15971             segment24,
15972             segment25,
15973             segment26,
15974             segment27,
15975             segment28,
15976             segment29,
15977             segment30
15978      from   pay_people_groups
15979      where  people_group_id = l_people_group_id;
15980   --
15981   cursor csr_get_legislation_code is
15982     select bus.legislation_code
15983       from per_business_groups_perf bus
15984      where bus.business_group_id = l_business_group_id;
15985   --
15986   cursor csr_get_salary is
15987   select element_entry_id
15988   from   pay_element_entries_f
15989   where  assignment_id = p_assignment_id
15990   and    creator_type = 'SP'
15991   and    l_validation_start_date between
15992          effective_start_date and effective_end_date;
15993 
15994 -- start of fix for  bug 4464072
15995 cursor csr_chk_rec_exists is
15996   select element_entry_id
15997   from   pay_element_entries_f
15998   where  assignment_id = p_assignment_id
15999   and    creator_type = 'SP'
16000   and   element_entry_id = l_element_entry_id	-- added for Bug14373426
16001   and    (l_validation_start_date - 1) between
16002          effective_start_date and effective_end_date;
16003 
16004 -- end of fix for bug 4464072
16005   --
16006   cursor csr_grp_idsel is
16007   select bus.people_group_structure
16008   from  per_business_groups_perf bus
16009   where bus.business_group_id = l_business_group_id;
16010   --
16011   cursor get_sec_date_range is
16012   select asg.effective_start_date
16013   ,      asg.effective_end_date
16014   from   per_all_assignments_f asg
16015   where  asg.assignment_id=p_assignment_id
16016   and   ((sysdate between asg.effective_start_date
16017           and asg.effective_end_date)
16018          or
16019          (sysdate<asg.effective_start_date
16020           and not exists
16021           (select 1
16022            from per_all_assignments_f asg2
16023            where asg2.person_id=asg.person_id
16024            and asg2.period_of_service_id=asg.period_of_service_id
16025            and asg2.effective_start_date<asg.effective_start_date)
16026          )
16027         );
16028   --
16029   cursor csr_chk_grade_and_ceiling is
16030     select sps.step_id
16031     from   per_spinal_point_steps_f sps,
16032            per_grade_spines_f pgs
16033     where  pgs.grade_id       = p_grade_id
16034     and    pgs.grade_spine_id = sps.grade_spine_id
16035     and    sps.step_id        = p_special_ceiling_step_id;
16036 
16037       cursor csr_get_people_group_id is
16038   select people_group_id
16039   from per_all_assignments_f
16040   where assignment_id = p_assignment_id
16041   and p_effective_date between effective_start_date and effective_end_date;
16042 
16043   --
16044   l_sec_effective_start_date date;
16045   l_sec_effective_end_date date;
16046   --
16047   l_dt_update_mode     VARCHAR2(30);
16048   l_new_dt_update_mode VARCHAR2(30);
16049   --
16050   -- Start of bug 3553286
16051   l_job_id                       number := p_job_id;
16052   l_org_id                       number := p_organization_id;
16053   -- End of 3553286
16054   --
16055   -- Start of 4103321
16056     l_old_pgp_segments   c_pgp_segments%rowtype;
16057     l_old_conc_segs      pay_people_groups.group_name%type;
16058   -- End of 4103321
16059 
16060 /* commented the code for Bug#14248434 */
16061   -- Start changes for bug 12911607
16062   /* l_pay_proposal_id 			number;
16063   L_sp_Element_Entry_Id         number;
16064   l_ovn					        number;
16065   l_pay_basis_id				number;
16066   l_inv_next_sal_date_warning	boolean;
16067   l_proposed_salary_warning	    boolean;
16068   l_approved_warning			boolean;
16069   l_payroll_warning			    boolean;
16070   l_proposal_reason             varchar2(240) := NULL;
16071 
16072   cursor csr_pay_proposal_exists is
16073   select pay_proposal_id
16074   from per_pay_proposals
16075   where assignment_id = p_assignment_id
16076   and change_date = p_effective_date; */
16077   -- End changes for bug 12911607
16078  /* commented the code for Bug#14248434 */
16079   --
16080   -- Start changes for bug 12911607
16081   l_pay_proposal_id             number;
16082   l_dummy                       varchar2(20);
16083   L_sp_Element_Entry_Id         number;
16084   l_ovn                         number;
16085   l_pay_basis_id	        number;
16086   l_inv_next_sal_date_warning	boolean;
16087   l_proposed_salary_warning	boolean;
16088   l_approved_warning            boolean;
16089   l_payroll_warning	        boolean;
16090   l_proposal_reason             varchar2(240) := NULL;
16091 
16092   cursor csr_pay_proposal_exists is
16093   select pay_proposal_id
16094   from per_pay_proposals
16095   where assignment_id = p_assignment_id
16096   and change_date = p_effective_date;
16097 
16098   cursor future_pay_proposals is
16099   select 'exist'
16100   from   per_pay_proposals
16101   where  assignment_id  = p_assignment_id
16102   and change_date >= p_effective_date;
16103 
16104   -- End changes for bug 12911607
16105   --
16106 begin
16107   if g_debug then
16108    hr_utility.set_location('Entering:'|| l_proc, 30);
16109   end if;
16110 
16111   --
16112   -- Truncate the p_effective_date value to remove time element.
16113   --
16114   l_effective_date := trunc(p_effective_date);
16115   --
16116   -- Bug 944911
16117   -- Made p_group_name to be out param
16118   -- and add p_concat_segment to be IN
16119   -- in case of sec_asg alone made p_pgp_concat_segments as in param
16120   -- Replaced p_group_name by p_concat_segments
16121   --
16122   l_old_group_name := p_concat_segments;
16123   --
16124   -- Added as part of fix for bug 2473971
16125   --
16126   IF p_called_from_mass_update THEN
16127     --
16128     if g_debug then
16129       hr_utility.set_location(l_proc,40);
16130     end if;
16131     --
16132     l_dt_update_mode     := 'CORRECTION';
16133     l_new_dt_update_mode := p_datetrack_update_mode;
16134     --
16135   ELSE
16136     --
16137     if g_debug then
16138       hr_utility.set_location(l_proc,50);
16139     end if;
16140     --
16141     l_dt_update_mode     := p_datetrack_update_mode;
16142     l_new_dt_update_mode := p_datetrack_update_mode;
16143     --
16144   END IF;
16145   --
16146   -- Bug 2359997 - if p_people_group_id enters with
16147   -- a value then get segment values from pay_people_groups.
16148   --
16149   if g_debug then
16150     hr_utility.set_location(l_proc, 60);
16151   end if;
16152   --
16153   if l_people_group_id is null
16154   then
16155      l_pgp_null_ind := 0;
16156   else
16157     -- get segment values
16158      open c_pgp_segments;
16159       fetch c_pgp_segments into l_old_conc_segs,   -- 4103321
16160                                 l_pgp_segment1,
16161                                 l_pgp_segment2,
16162                                 l_pgp_segment3,
16163                                 l_pgp_segment4,
16164                                 l_pgp_segment5,
16165                                 l_pgp_segment6,
16166                                 l_pgp_segment7,
16167                                 l_pgp_segment8,
16168                                 l_pgp_segment9,
16169                                 l_pgp_segment10,
16170                                 l_pgp_segment11,
16171                                 l_pgp_segment12,
16172                                 l_pgp_segment13,
16173                                 l_pgp_segment14,
16174                                 l_pgp_segment15,
16175                                 l_pgp_segment16,
16176                                 l_pgp_segment17,
16177                                 l_pgp_segment18,
16178                                 l_pgp_segment19,
16179                                 l_pgp_segment20,
16180                                 l_pgp_segment21,
16181                                 l_pgp_segment22,
16182                                 l_pgp_segment23,
16183                                 l_pgp_segment24,
16184                                 l_pgp_segment25,
16185                                 l_pgp_segment26,
16186                                 l_pgp_segment27,
16187                                 l_pgp_segment28,
16188                                 l_pgp_segment29,
16189                                 l_pgp_segment30;
16190      close c_pgp_segments;
16191     -- l_pgp_null_ind := 1;  fix for the bug#14476390
16192        l_pgp_null_ind := 0;
16193   end if;
16194 
16195 
16196   --
16197   -- Issue a savepoint.
16198   --
16199   savepoint update_emp_asg_criteria;
16200   --
16201   begin
16202   --
16203     -- Start of API User Hook for the before hook of update_emp_asg_criteria
16204     --
16205     hr_assignment_bk3.update_emp_asg_criteria_b
16206       (p_effective_date               => l_effective_date
16207       ,p_datetrack_update_mode        => l_dt_update_mode
16208       ,p_assignment_id                => p_assignment_id
16209       ,p_object_version_number        => p_object_version_number
16210       ,p_grade_id                     => p_grade_id
16211       ,p_position_id                  => p_position_id
16212       ,p_job_id                       => p_job_id
16213       ,p_payroll_id                   => p_payroll_id
16214       ,p_location_id                  => p_location_id
16215       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
16216       ,p_organization_id              => p_organization_id
16217       ,p_pay_basis_id                 => p_pay_basis_id
16218       ,p_segment1                     => l_pgp_segment1
16219       ,p_segment2                     => l_pgp_segment2
16220       ,p_segment3                     => l_pgp_segment3
16221       ,p_segment4                     => l_pgp_segment4
16222       ,p_segment5                     => l_pgp_segment5
16223       ,p_segment6                     => l_pgp_segment6
16224       ,p_segment7                     => l_pgp_segment7
16225       ,p_segment8                     => l_pgp_segment8
16226       ,p_segment9                     => l_pgp_segment9
16227       ,p_segment10                    => l_pgp_segment10
16228       ,p_segment11                    => l_pgp_segment11
16229       ,p_segment12                    => l_pgp_segment12
16230       ,p_segment13                    => l_pgp_segment13
16231       ,p_segment14                    => l_pgp_segment14
16232       ,p_segment15                    => l_pgp_segment15
16233       ,p_segment16                    => l_pgp_segment16
16234       ,p_segment17                    => l_pgp_segment17
16235       ,p_segment18                    => l_pgp_segment18
16236       ,p_segment19                    => l_pgp_segment19
16237       ,p_segment20                    => l_pgp_segment20
16238       ,p_segment21                    => l_pgp_segment21
16239       ,p_segment22                    => l_pgp_segment22
16240       ,p_segment23                    => l_pgp_segment23
16241       ,p_segment24                    => l_pgp_segment24
16242       ,p_segment25                    => l_pgp_segment25
16243       ,p_segment26                    => l_pgp_segment26
16244       ,p_segment27                    => l_pgp_segment27
16245       ,p_segment28                    => l_pgp_segment28
16246       ,p_segment29                    => l_pgp_segment29
16247       ,p_segment30                    => l_pgp_segment30
16248        --
16249        -- Bug 944911
16250        -- Amended p_group_name to p_concat_segments
16251        --
16252       ,p_concat_segments              => l_old_group_name
16253       ,p_employment_category          => p_employment_category
16254 -- Start of Fix for Bug 2622747
16255       ,p_contract_id                  => p_contract_id
16256       ,p_establishment_id             => p_establishment_id
16257       );
16258 -- End of Fix for Bug 2622747
16259 
16260   exception
16261     when hr_api.cannot_find_prog_unit then
16262       hr_api.cannot_find_prog_unit_error
16263         (p_module_name => 'UPDATE_EMP_ASG_CRITERIA'
16264         ,p_hook_type   => 'BP'
16265         );
16266     --
16267     -- End of API User Hook for the before hook of update_emp_asg_criteria
16268     --
16269   end;
16270   --
16271   if g_debug then
16272     hr_utility.set_location(l_proc, 70);
16273   end if;
16274   --
16275   l_object_version_number := p_object_version_number;
16276   --
16277   -- Validation in addition to Table Handlers
16278   --
16279   -- Retrieve current assignment details from database.
16280   --
16281   l_api_updating := per_asg_shd.api_updating
16282     (p_assignment_id         => p_assignment_id
16283     ,p_effective_date        => l_effective_date
16284     ,p_object_version_number => l_object_version_number);
16285   --
16286   if g_debug then
16287    hr_utility.set_location(l_proc, 80);
16288   end if;
16289   --
16290   if not l_api_updating
16291   then
16292     --
16293     if g_debug then
16294       hr_utility.set_location(l_proc, 90);
16295     end if;
16296     --
16297     -- As this is an updating API, the assignment should already exist.
16298     --
16299     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
16300     hr_utility.raise_error;
16301     -- else
16302     --
16303     if g_debug then
16304       hr_utility.set_location(l_proc, 100);
16305     end if;
16306     --
16307     -- l_people_group_id := per_asg_shd.g_old_rec.people_group_id; bug 2359997
16308   end if;
16309   --
16310   if g_debug then
16311    hr_utility.set_location(l_proc, 110);
16312   end if;
16313   --
16314   -- Check that the assignment is an employee assignment.
16315   --
16316   if per_asg_shd.g_old_rec.assignment_type <> 'E'
16317   then
16318     --
16319     if g_debug then
16320       hr_utility.set_location(l_proc, 120);
16321     end if;
16322     --
16323     hr_utility.set_message(801, 'HR_7948_ASG_ASG_NOT_EMP');
16324     hr_utility.raise_error;
16325   end if;
16326   --
16327   if g_debug then
16328    hr_utility.set_location(l_proc, 130);
16329   end if;
16330   --
16331   -- Removed as part of fix for bug
16332   --
16333   -- Process Logic
16334   --
16335   -- bug 2473971
16336   --
16337   -- Set special_ceiling_step_id to null if grade_id is being changed or is
16338   -- null.
16339   --
16340   --   if  per_asg_shd.g_old_rec.grade_id <> p_grade_id
16341   --       or p_grade_id is null
16342   --   then
16343   --     --
16344   --     --
16345   --     l_special_ceiling_step_id := null;
16346   --   else
16347   --     --
16348   --     --
16349   --     if p_special_ceiling_step_id = hr_api.g_number then
16350   --       --
16351   --       --
16352   --       l_special_ceiling_step_id := per_asg_shd.g_old_rec.special_ceiling_step_id;
16353   --       else
16354   --       --
16355   --       --
16356   --       l_special_ceiling_step_id := p_special_ceiling_step_id;
16357   --      end if;
16358   --     --
16359   --   end if;
16360   --
16361   --
16362   -- Process Logic
16363   --
16364   -- bug 2473971 and reworked to include
16365   -- cursor check as part of fix for bug 2564704
16366   --
16367   -- If the grade has been changed and the special ceiling
16368   -- id is populated then check that the ceiling id
16369   -- is for the grade.
16370   --
16371   --  Bug 348599 Added the condition to
16372   --  allow updation of p_ceiling_step_id even though
16373   --  the grade is assigned to assignment but not passed
16374   --  to api.
16375   --
16376   if (per_asg_shd.g_old_rec.grade_id <> p_grade_id AND
16377       p_grade_id <> hr_api.g_number AND -- 3485599
16378       p_special_ceiling_step_id IS NOT NULL) then
16379     --
16380     if g_debug then
16381       hr_utility.set_location(l_proc, 140);
16382     end if;
16383     --
16384     open csr_chk_grade_and_ceiling;
16385     fetch csr_chk_grade_and_ceiling into l_step_id;
16386     --
16387     -- If the ceiling id is not for the new grade then
16388     -- set the ceiling to be null
16389     --
16390     if csr_chk_grade_and_ceiling%NOTFOUND then
16391       --
16392       if g_debug then
16393         hr_utility.set_location(l_proc, 150);
16394       end if;
16395       --
16396       close csr_chk_grade_and_ceiling;
16397       --
16398       l_special_ceiling_step_id := NULL;
16399     --
16400     -- if the ceiling id is for the grade
16401     -- then set the local variable to the parameter.
16402     --
16403     else
16404       --
16405       if g_debug then
16406         hr_utility.set_location(l_proc, 160);
16407       end if;
16408       --
16409       close csr_chk_grade_and_ceiling;
16410       --
16411       l_special_ceiling_step_id := p_special_ceiling_step_id;
16412       --
16413     end if;
16414   --
16415   --  Set special_ceiling_step_id to null if grade_id
16416   --  is being changed or is null.
16417   --
16418   elsif p_grade_id is null then
16419     --
16420     if g_debug then
16421       hr_utility.set_location(l_proc, 170);
16422     end if;
16423     --
16424     l_special_ceiling_step_id := null;
16425     --
16426   else
16427     --
16428     if g_debug then
16429        hr_utility.set_location(l_proc, 180);
16430     end if;
16431     --
16432     if p_special_ceiling_step_id = hr_api.g_number then
16433       --
16434       if g_debug then
16435         hr_utility.set_location(l_proc, 190);
16436       end if;
16437       --
16438       l_special_ceiling_step_id := per_asg_shd.g_old_rec.special_ceiling_step_id;
16439       --
16440     else
16441       --
16442       if g_debug then
16443         hr_utility.set_location(l_proc, 200);
16444       end if;
16445       --
16446       l_special_ceiling_step_id := p_special_ceiling_step_id;
16447       --
16448     end if;
16449     --
16450   end if;
16451   if g_debug then
16452     hr_utility.set_location(l_proc, 210);
16453   end if;
16454   --
16455   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
16456   --
16457   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
16458   --
16459   -- Start of bug fix 3553286
16460   -- This procedure will return the job_id and organization_id of a position
16461   --
16462   if (p_called_from_mass_update = TRUE and p_position_id is not null) then
16463      if (l_job_id is null) or (l_org_id is null) then
16464          hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
16465                                          l_job_id, l_org_id);
16466      end if;
16467   end if;
16468   -- End of 3553286
16469   -- insert the profile options and effective date for the flexfield
16470   -- validation to work
16471   --
16472   --
16473   if (l_org_id = hr_api.g_number) then -- Bug 3553286
16474     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
16475   else
16476     l_organization_id:= l_org_id; -- Bug 3553286
16477   end if;
16478   --
16479   if (p_location_id=hr_api.g_number) then
16480     l_location_id:=per_asg_shd.g_old_rec.location_id;
16481   else
16482     l_location_id:=p_location_id;
16483   end if;
16484   --
16485   if g_debug then
16486     hr_utility.set_location(l_proc, 220);
16487   end if;
16488   --
16489   hr_kflex_utility.set_profiles
16490   (p_business_group_id => l_business_group_id
16491   ,p_assignment_id     => p_assignment_id
16492   ,p_organization_id   => l_organization_id
16493   ,p_location_id       => l_location_id);
16494   --
16495   if g_debug then
16496     hr_utility.set_location(l_proc, 230);
16497   end if;
16498   --
16499   hr_kflex_utility.set_session_date
16500   (p_effective_date => l_effective_date
16501   ,p_session_id     => l_session_id);
16502   --
16503   if g_debug then
16504     hr_utility.set_location(l_proc, 240);
16505   end if;
16506   --
16507   open csr_grp_idsel;
16508   fetch csr_grp_idsel
16509   into l_flex_num;
16510     if csr_grp_idsel%NOTFOUND then
16511        close csr_grp_idsel;
16512           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
16513           hr_utility.set_message_token('PROCEDURE', l_proc);
16514           hr_utility.set_message_token('STEP','5');
16515           hr_utility.raise_error;
16516      end if;
16517   close csr_grp_idsel;
16518   --
16519  if g_debug then
16520   hr_utility.set_location(l_proc, 250);
16521  end if;
16522   --
16523   -- Maintain the people group key flexfields.
16524   --
16525   -- Only call the flex code if a non-default value(includng null) is passed
16526   -- to the procedure.
16527   --
16528     --
16529   if  l_pgp_null_ind = 0 -- bug 2359997
16530   then
16531     --
16532      -- Changes for Bug#12874349
16533 
16534   open csr_get_people_group_id;
16535 fetch csr_get_people_group_id into l_people_group_id;
16536  close csr_get_people_group_id;
16537 
16538     l_people_group_id := nvl(l_people_group_id,per_asg_shd.g_old_rec.people_group_id);
16539 
16540     -- End of changes for bug#12874349
16541     --
16542     --l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
16543 
16544     -- 4103321 modified the if statement
16545 
16546     if l_people_group_id is not null then
16547        open c_pgp_segments;
16548        fetch c_pgp_segments into l_old_pgp_segments;
16549        close c_pgp_segments;
16550     end if;
16551     --
16552     if   nvl(p_segment1, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment1, hr_api.g_varchar2)
16553       or nvl(p_segment2, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment2, hr_api.g_varchar2)
16554       or nvl(p_segment3, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment3, hr_api.g_varchar2)
16555       or nvl(p_segment4, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment4, hr_api.g_varchar2)
16556       or nvl(p_segment5, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment5, hr_api.g_varchar2)
16557       or nvl(p_segment6, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment6, hr_api.g_varchar2)
16558       or nvl(p_segment7, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment7, hr_api.g_varchar2)
16559       or nvl(p_segment8, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment8, hr_api.g_varchar2)
16560       or nvl(p_segment9, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment9, hr_api.g_varchar2)
16561       or nvl(p_segment10, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment10, hr_api.g_varchar2)
16562       or nvl(p_segment11, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment11, hr_api.g_varchar2)
16563       or nvl(p_segment12, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment12, hr_api.g_varchar2)
16564       or nvl(p_segment13, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment13, hr_api.g_varchar2)
16565       or nvl(p_segment14, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment14, hr_api.g_varchar2)
16566       or nvl(p_segment15, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment15, hr_api.g_varchar2)
16567       or nvl(p_segment16, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment16, hr_api.g_varchar2)
16568       or nvl(p_segment17, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment17, hr_api.g_varchar2)
16569       or nvl(p_segment18, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment18, hr_api.g_varchar2)
16570       or nvl(p_segment19, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment19, hr_api.g_varchar2)
16571       or nvl(p_segment20, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment20, hr_api.g_varchar2)
16572       or nvl(p_segment21, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment21, hr_api.g_varchar2)
16573       or nvl(p_segment22, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment22, hr_api.g_varchar2)
16574       or nvl(p_segment23, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment23, hr_api.g_varchar2)
16575       or nvl(p_segment24, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment24, hr_api.g_varchar2)
16576       or nvl(p_segment25, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment25, hr_api.g_varchar2)
16577       or nvl(p_segment26, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment26, hr_api.g_varchar2)
16578       or nvl(p_segment27, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment27, hr_api.g_varchar2)
16579       or nvl(p_segment28, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment28, hr_api.g_varchar2)
16580       or nvl(p_segment29, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment29, hr_api.g_varchar2)
16581       or nvl(p_segment30, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment30, hr_api.g_varchar2)
16582       or nvl(l_old_group_name,hr_api.g_varchar2) <> nvl(l_old_pgp_segments.group_name, hr_api.g_varchar2)
16583       or l_people_group_id is  null -- fix for bug 4633742.
16584     then
16585       hr_kflex_utility.upd_or_sel_keyflex_comb
16586       (p_appl_short_name              => 'PAY'
16587       ,p_flex_code                    => 'GRP'
16588       ,p_flex_num                     => l_flex_num
16589       ,p_segment1                     => l_pgp_segment1
16590       ,p_segment2                     => l_pgp_segment2
16591       ,p_segment3                     => l_pgp_segment3
16592       ,p_segment4                     => l_pgp_segment4
16593       ,p_segment5                     => l_pgp_segment5
16594       ,p_segment6                     => l_pgp_segment6
16595       ,p_segment7                     => l_pgp_segment7
16596       ,p_segment8                     => l_pgp_segment8
16597       ,p_segment9                     => l_pgp_segment9
16598       ,p_segment10                    => l_pgp_segment10
16599       ,p_segment11                    => l_pgp_segment11
16600       ,p_segment12                    => l_pgp_segment12
16601       ,p_segment13                    => l_pgp_segment13
16602       ,p_segment14                    => l_pgp_segment14
16603       ,p_segment15                    => l_pgp_segment15
16604       ,p_segment16                    => l_pgp_segment16
16605       ,p_segment17                    => l_pgp_segment17
16606       ,p_segment18                    => l_pgp_segment18
16607       ,p_segment19                    => l_pgp_segment19
16608       ,p_segment20                    => l_pgp_segment20
16609       ,p_segment21                    => l_pgp_segment21
16610       ,p_segment22                    => l_pgp_segment22
16611       ,p_segment23                    => l_pgp_segment23
16612       ,p_segment24                    => l_pgp_segment24
16613       ,p_segment25                    => l_pgp_segment25
16614       ,p_segment26                    => l_pgp_segment26
16615       ,p_segment27                    => l_pgp_segment27
16616       ,p_segment28                    => l_pgp_segment28
16617       ,p_segment29                    => l_pgp_segment29
16618       ,p_segment30                    => l_pgp_segment30
16619       ,p_concat_segments_in           => l_old_group_name
16620       ,p_ccid                         => l_people_group_id
16621       ,p_concat_segments_out          => l_group_name
16622       );
16623     --
16624     --end if;--fix for bug 4633742.
16625     --
16626  if g_debug then
16627     hr_utility.set_location(l_proc, 260);
16628  end if;
16629     --
16630     -- update the combinations column
16631     --
16632     update_pgp_concat_segs
16633     (p_people_group_id        => l_people_group_id
16634     ,p_group_name             => l_group_name
16635     );
16636   --
16637   end if;
16638 end if;--fix for bug 4633742.
16639   --
16640  if g_debug then
16641   hr_utility.set_location(l_proc, 270);
16642  end if;
16643   --
16644 --
16645 -- Start of fix for Bug 2622747
16646 --
16647   validate_SCL (
16648    p_validate                     => FALSE -- Changed from p_validate to FALSE for fix of #3180527
16649   ,p_assignment_id                => p_assignment_id
16650   ,p_effective_date               => l_effective_date
16651   ,p_business_group_id            => l_business_group_id
16652   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
16653   ,p_concatenated_segments        => l_concatenated_segments
16654   ,p_concat_segments              => NULL
16655   ,p_segment1                     => l_scl_segment1
16656   ,p_segment2                     => l_scl_segment2
16657   ,p_segment3                     => l_scl_segment3
16658   ,p_segment4                     => l_scl_segment4
16659   ,p_segment5                     => l_scl_segment5
16660   ,p_segment6                     => l_scl_segment6
16661   ,p_segment7                     => l_scl_segment7
16662   ,p_segment8                     => l_scl_segment8
16663   ,p_segment9                     => l_scl_segment9
16664   ,p_segment10                    => l_scl_segment10
16665   ,p_segment11                    => l_scl_segment11
16666   ,p_segment12                    => l_scl_segment12
16667   ,p_segment13                    => l_scl_segment13
16668   ,p_segment14                    => l_scl_segment14
16669   ,p_segment15                    => l_scl_segment15
16670   ,p_segment16                    => l_scl_segment16
16671   ,p_segment17                    => l_scl_segment17
16672   ,p_segment18                    => l_scl_segment18
16673   ,p_segment19                    => l_scl_segment19
16674   ,p_segment20                    => l_scl_segment20
16675   ,p_segment21                    => l_scl_segment21
16676   ,p_segment22                    => l_scl_segment22
16677   ,p_segment23                    => l_scl_segment23
16678   ,p_segment24                    => l_scl_segment24
16679   ,p_segment25                    => l_scl_segment25
16680   ,p_segment26                    => l_scl_segment26
16681   ,p_segment27                    => l_scl_segment27
16682   ,p_segment28                    => l_scl_segment28
16683   ,p_segment29                    => l_scl_segment29
16684   ,p_segment30                    => l_scl_segment30
16685   );
16686 --End of fix for Bug 2622747
16687   --
16688   -- Update assignment.
16689   --
16690   per_asg_upd.upd
16691     (p_assignment_id                => p_assignment_id
16692     ,p_effective_start_date         => l_effective_start_date
16693     ,p_effective_end_date           => l_effective_end_date
16694     ,p_business_group_id            => l_business_group_id
16695     ,p_grade_id                     => p_grade_id
16696     ,p_position_id                  => p_position_id
16697     ,p_job_id                       => l_job_id -- Bug 3553286 p_job_id
16698     ,p_payroll_id                   => p_payroll_id
16699     ,p_location_id                  => p_location_id
16700     ,p_special_ceiling_step_id      => l_special_ceiling_step_id
16701     ,p_organization_id              => l_org_id -- Bug 3553286 p_organization_id
16702     ,p_people_group_id              => l_people_group_id
16703     ,p_pay_basis_id                 => p_pay_basis_id
16704     ,p_comment_id                   => l_comment_id
16705     ,p_employment_category          => p_employment_category
16706     ,p_payroll_id_updated           => l_payroll_id_updated
16707     ,p_other_manager_warning        => l_other_manager_warning
16708     ,p_no_managers_warning          => l_no_managers_warning
16709     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
16710     ,p_validation_start_date        => l_validation_start_date
16711     ,p_validation_end_date          => l_validation_end_date
16712     ,p_object_version_number        => l_object_version_number
16713     ,p_effective_date               => l_effective_date
16714     ,p_datetrack_mode               => l_dt_update_mode
16715     ,p_validate                     => FALSE
16716     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
16717     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
16718     ,p_contract_id                  => p_contract_id
16719     ,p_establishment_id             => p_establishment_id
16720     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
16721     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
16722     );
16723   --
16724  if g_debug then
16725   hr_utility.set_location(l_proc, 280);
16726  end if;
16727   --
16728   -- add to the security lists if neccesary
16729   --
16730   open get_sec_date_range;
16731   fetch get_sec_date_range into l_sec_effective_start_date,
16732                                 l_sec_effective_end_date;
16733   close get_sec_date_range;
16734   --
16735   if l_effective_date between l_sec_effective_start_date
16736   and l_sec_effective_end_date then
16737     if (per_asg_shd.g_old_rec.organization_id = l_business_group_id
16738     and l_org_id <> l_business_group_id) then  -- Bug 3553286
16739       hr_security_internal.clear_from_person_list
16740                            (per_asg_shd.g_old_rec.person_id);
16741     end if;
16742     hr_security_internal.add_to_person_list(l_effective_date,p_assignment_id);
16743   end if;
16744   --
16745  if g_debug then
16746   hr_utility.set_location(l_proc, 290);
16747  end if;
16748   --
16749   -- Bug 560185 fix starts
16750   --
16751   -- Delete the SP element entry if there is one when the pay_basis
16752   -- changes
16753   --
16754   if (p_pay_basis_id <> hr_api.g_number or
16755       p_pay_basis_id is null ) and
16756      (nvl(p_pay_basis_id,hr_api.g_number) <>
16757       nvl(per_asg_shd.g_old_rec.pay_basis_id, hr_api.g_number))
16758   then
16759  -- start of bug fix 4464072
16760  -- commented out the following part and newly defined
16761 
16762   /*  open csr_get_salary;
16763     fetch csr_get_salary into l_element_entry_id;
16764     if csr_get_salary%found then
16765       close csr_get_salary;
16766       --
16767       hr_entry_api.delete_element_entry
16768         ('DELETE'
16769         ,l_validation_start_date - 1
16770         ,l_element_entry_id);
16771       --
16772       l_entries_changed_warning := 'S';
16773     else
16774        close csr_get_salary;
16775     end if;
16776   end if; */
16777 
16778  /*open csr_get_salary;
16779     fetch csr_get_salary into l_element_entry_id;
16780     if csr_get_salary%found then
16781       close csr_get_salary;
16782 
16783       open csr_chk_rec_exists;
16784       fetch csr_chk_rec_exists into l_element_entry_id1;
16785 
16786   if csr_chk_rec_exists%found then
16787       close csr_chk_rec_exists;
16788 
16789       --
16790       hr_entry_api.delete_element_entry
16791         ('DELETE'
16792         ,l_validation_start_date - 1
16793         ,l_element_entry_id);*/  --Commented as part of Fix of Bug#16170631 and Bug#12911607.
16794 
16795 /* commented the code for Bug#14248434 */
16796       -- Start changes for bug 12911607
16797       /*hr_entry_api.delete_element_entry
16798         ('DELETE'
16799         ,l_validation_start_date - 1
16800         ,l_element_entry_id);*/
16801      /* open csr_pay_proposal_exists;
16802       fetch csr_pay_proposal_exists into l_pay_proposal_id;
16803       close  csr_pay_proposal_exists;
16804 
16805       if l_pay_proposal_id is null then -- no salary proposal exists on this date. Go create it .
16806 
16807        if hr_api.not_exists_in_hr_lookups
16808         (p_effective_date	=> p_effective_date
16809         ,p_lookup_type	    => 'PROPOSAL_REASON'
16810         ,p_lookup_code 	    => 'SALBASISCHG'
16811         )
16812        then
16813         l_proposal_reason :=null;
16814        else
16815         l_proposal_reason := 'SALBASISCHG';
16816        end if;
16817 
16818        Hr_Maintain_Proposal_Api.INSERT_SALARY_PROPOSAL
16819 	  (P_PAY_PROPOSAL_ID            =>  l_Pay_Proposal_Id
16820 	  ,P_ASSIGNMENT_ID              =>  p_assignment_id
16821 	  ,P_BUSINESS_GROUP_ID          =>  l_business_group_id
16822 	  ,P_CHANGE_DATE                =>  p_effective_date
16823 	  ,P_PROPOSED_SALARY_N          =>  per_saladmin_utility.get_proposed_salary(p_assignment_id,p_effective_date-1)
16824 	  ,P_OBJECT_VERSION_NUMBER      =>  l_ovn
16825 	  ,P_ELEMENT_ENTRY_ID           =>  L_sp_Element_Entry_Id
16826 	  ,P_MULTIPLE_COMPONENTS        =>  'N'
16827 	  ,P_APPROVED                   =>  'Y'
16828 	  ,P_PROPOSAL_REASON            =>  l_proposal_reason
16829 	  ,P_INV_NEXT_SAL_DATE_WARNING  =>  L_INV_NEXT_SAL_DATE_WARNING
16830 	  ,P_PROPOSED_SALARY_WARNING    =>  L_PROPOSED_SALARY_WARNING
16831 	  ,P_APPROVED_WARNING           =>  L_APPROVED_WARNING
16832 	  ,P_PAYROLL_WARNING            =>  L_PAYROLL_WARNING);*/
16833 
16834       -- End changes for bug 12911607
16835  /* commented the code for Bug#14248434 */
16836 
16837        -- Start changes for bug 12911607
16838      OPEN csr_get_salary; -- Check any salary proposal exists on the given dates.
16839      FETCH csr_get_salary INTO l_element_entry_id;
16840 
16841      hr_utility.set_location('l_element_entry_id:'|| l_element_entry_id, 291);
16842 
16843      IF csr_get_salary%found THEN
16844       IF p_create_salary_proposal = 'Y' and  p_pay_basis_id is not null THEN -- if 1 Check for Pay Proposal
16845         CLOSE csr_get_salary;
16846 
16847 	hr_utility.set_location('P_CREATE_SALARY_PROPOSAL is Y. Update SP', 292);
16848 
16849         OPEN csr_chk_rec_exists; -- Check any salary proposal exists on the given date - 1.
16850         FETCH csr_chk_rec_exists INTO l_element_entry_id1;
16851 
16852         hr_utility.set_location('l_element_entry_id1:'|| l_element_entry_id1, 293);
16853 
16854         IF csr_chk_rec_exists%found THEN -- if 2 Check for Previous Pay Proposal
16855           CLOSE csr_chk_rec_exists;
16856 
16857           OPEN csr_pay_proposal_exists;
16858           FETCH csr_pay_proposal_exists INTO l_pay_proposal_id;
16859           CLOSE csr_pay_proposal_exists;
16860 
16861           IF l_pay_proposal_id IS NULL THEN -- if 3
16862                 -- no salary proposal exists on this date. Go create it .
16863             hr_utility.set_location('Creating new salary proposal', 292);
16864 
16865             if p_datetrack_update_mode in ('CORRECTION','UPDATE') then
16866 
16867                 open  future_pay_proposals;
16868                 Fetch future_pay_proposals into l_dummy;
16869                 if future_pay_proposals%notfound then
16870                    --
16871                    -- No problem. Can allow sal basis change. Just close the cursor.
16872                    --
16873                     IF hr_api.not_exists_in_hr_lookups -- if 4
16874                       (p_effective_date => p_effective_date,
16875                       p_lookup_type => 'PROPOSAL_REASON',
16876                       p_lookup_code => 'SALBASISCHG'
16877                       ) THEN
16878                       l_proposal_reason := NULL;
16879                     ELSE
16880                       l_proposal_reason := 'SALBASISCHG';
16881                     END IF; -- if 4
16882                     Hr_Maintain_Proposal_Api.INSERT_SALARY_PROPOSAL
16883                     (P_PAY_PROPOSAL_ID => l_Pay_Proposal_Id,
16884                     P_ASSIGNMENT_ID => p_assignment_id,
16885                     P_BUSINESS_GROUP_ID => l_business_group_id,
16886                     P_CHANGE_DATE => p_effective_date,
16887                     P_PROPOSED_SALARY_N => per_saladmin_utility.get_proposed_salary(p_assignment_id, p_effective_date - 1),
16888                     P_OBJECT_VERSION_NUMBER => l_ovn,
16889                     P_ELEMENT_ENTRY_ID => L_sp_Element_Entry_Id,
16890                     P_MULTIPLE_COMPONENTS => 'N',
16891                     P_APPROVED => 'Y',
16892                     P_PROPOSAL_REASON => l_proposal_reason,
16893                     P_INV_NEXT_SAL_DATE_WARNING => L_INV_NEXT_SAL_DATE_WARNING,
16894                     P_PROPOSED_SALARY_WARNING => L_PROPOSED_SALARY_WARNING,
16895                     P_APPROVED_WARNING => L_APPROVED_WARNING,
16896                     P_PAYROLL_WARNING => L_PAYROLL_WARNING);
16897 
16898                     hr_utility.set_location('l_Pay_Proposal_Id:' || l_Pay_Proposal_Id, 293);
16899 
16900                 else
16901                    --
16902                    -- Can't allow the change. Close the cursor, reset the
16903                    -- salary basis values, and raise an error.
16904                    --
16905                    close future_pay_proposals;
16906                    --
16907                   hr_utility.set_message('PAY', 'HR_51033_ASS_FUT_SAL_ADMIN');
16908                   hr_utility.raise_error;
16909                end if;
16910 
16911            end if; --check furture_pay_proposals
16912 
16913           ELSE -- if 3
16914             IF l_element_entry_id = l_element_entry_id1 THEN  -- if 4
16915               hr_utility.set_location('End-Dating the salary proposal element.', 294);
16916               hr_utility.set_location('l_element_entry_id:' || l_element_entry_id, 294);
16917               hr_entry_api.delete_element_entry
16918               ('DELETE',
16919               l_validation_start_date - 1,
16920               l_element_entry_id);
16921             ELSE
16922                -- Zapping the latest salary proposal if no prior salary proposal exists.
16923                hr_utility.set_location('Zaping the element of latest salary proposal.', 295);
16924                hr_utility.set_location('l_element_entry_id' || l_element_entry_id, 295);
16925                hr_entry_api.delete_element_entry
16926                 ('ZAP',
16927                 l_validation_start_date,
16928                 l_element_entry_id);
16929             END IF;  --if 4
16930           END IF; -- if 3
16931         ELSE -- else 2 Check for Previous Pay Proposal
16932             -- Zapping the salary proposal if no prior salary proposal exists.
16933           hr_utility.set_location('Zaping the only salary proposal element.', 297);
16934           hr_entry_api.delete_element_entry
16935           ('ZAP',
16936           l_validation_start_date,
16937           l_element_entry_id);
16938 
16939           CLOSE csr_chk_rec_exists;
16940         END IF; -- if 2 Check for Previous Pay Proposal
16941         l_entries_changed_warning := 'S';
16942       ELSE -- else 1 Check for Pay Proposal
16943           hr_utility.set_location('P_CREATE_SALARY_PROPOSAL is N, End-date Salary Proposal', 298);
16944           CLOSE csr_get_salary;
16945 
16946           hr_entry_api.delete_element_entry
16947             ('DELETE'
16948             ,l_validation_start_date - 1
16949             ,l_element_entry_id);
16950           --
16951           l_entries_changed_warning := 'S';
16952       END IF;  -- if 1 Check for Pay Proposal
16953     ELSE
16954       hr_utility.set_location('No Salary Proposal found', 299);
16955       CLOSE csr_get_salary;
16956     END IF;
16957     --End changes for #12911607
16958 
16959   end if;
16960   --
16961   -- end of fix for bug 4464072
16962   --
16963   -- Bug 560185 fix ends
16964   --
16965   -- Maintain standard element entries for this assignment.
16966   --
16967   -- Bug 638026 fix starts
16968   --
16969   if p_payroll_id = hr_api.g_number
16970    then
16971      --
16972  if g_debug then
16973      hr_utility.set_location(l_proc, 300);
16974  end if;
16975      --
16976      l_new_payroll_id := per_asg_shd.g_old_rec.payroll_id;
16977    else
16978      --
16979  if g_debug then
16980      hr_utility.set_location(l_proc, 310);
16981  end if;
16982      --
16983      l_new_payroll_id := p_payroll_id;
16984    end if;
16985   --
16986  if g_debug then
16987   hr_utility.set_location(l_proc, 320);
16988  end if;
16989   --
16990   hr_utility.set_location('p_old_pg_id :'||to_char(per_asg_shd.g_old_rec.payroll_id),325);
16991   hr_utility.set_location('p_new_pg_id :'||to_char(l_people_group_id),325);
16992   --
16993         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_grade_id:' || p_grade_id,11);  -- Bug#13960540
16994         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_s_grd_id:' || per_asg_shd.g_old_rec.grade_id,11);
16995         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_old_org_id:' || per_asg_shd.g_old_rec.organization_id,11);
16996         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_new_org_id:' || l_organization_id,11);
16997         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_old_emp_cat:' || per_asg_shd.g_old_rec.employment_category,11);
16998         hr_utility.set_location('peasgapi.pkb.hrentmnt.maintain_entries_asg..p_new_emp_cat:' || p_employment_category,11); -- Bug#13960540
16999 
17000   --
17001   hrentmnt.maintain_entries_asg
17002     (p_assignment_id                => p_assignment_id
17003     ,p_old_payroll_id               => per_asg_shd.g_old_rec.payroll_id
17004     ,p_new_payroll_id               => l_new_payroll_id
17005     ,p_business_group_id            => l_business_group_id
17006     ,p_operation                    => 'ASG_CRITERIA'
17007     ,p_actual_term_date             => null
17008     ,p_last_standard_date           => null
17009     ,p_final_process_date           => null
17010     ,p_dt_mode                      => l_new_dt_update_mode
17011     ,p_validation_start_date        => l_validation_start_date
17012     ,p_validation_end_date          => l_validation_end_date
17013     ,p_entries_changed              => l_entries_changed
17014     ,p_old_people_group_id          => per_asg_shd.g_old_rec.people_group_id
17015     ,p_new_people_group_id          => l_people_group_id
17016     ,p_old_grade_id                 => per_asg_shd.g_old_rec.grade_id              -- Added for Bug#13960540
17017     ,p_new_grade_id		    => p_grade_id                                  -- Added for Bug#13960540
17018     ,p_old_organization_id          => per_asg_shd.g_old_rec.organization_id       -- Added for Bug#13960540
17019     ,p_new_organization_id          => l_organization_id                           -- Added for Bug#13960540
17020     ,p_old_employment_category      => per_asg_shd.g_old_rec.employment_category   -- Added for Bug#13960540
17021     ,p_new_employment_category      => p_employment_category                       -- Added for Bug#13960540
17022     );
17023   --
17024   -- Bug 630826 fix ends
17025   --
17026  if g_debug then
17027   hr_utility.set_location(l_proc, 330);
17028  end if;
17029 
17030 
17031 /* commented the code for Bug#14248434 */
17032   --
17033   -- Begin of Addition for bug 12911607
17034   --
17035  /*if l_entries_changed_warning = 'S' or l_entries_changed_warning = 'Y' then
17036 
17037   per_saladmin_utility.adjust_pay_proposals(p_assignment_id => p_assignment_id);
17038   per_saladmin_utility.handle_asg_crit_change(p_assignment_id => p_assignment_id,p_effective_date => p_effective_date);
17039  end if;*/
17040 
17041   -- End of Addition for bug 12911607
17042   --
17043 /* commented the code for Bug#14248434 */
17044   --
17045   if l_entries_changed_warning <> 'S' then
17046     l_entries_changed_warning := nvl(l_entries_changed, 'N');
17047   end if;
17048   --
17049   IF    (    per_asg_shd.g_old_rec.grade_id is not null
17050          AND p_grade_id is null)
17051      OR (    per_asg_shd.g_old_rec.grade_id is not null
17052          AND p_grade_id is not null
17053          AND per_asg_shd.g_old_rec.grade_id <> p_grade_id
17054          AND p_grade_id <> hr_api.g_number)
17055   then
17056     --
17057  if g_debug then
17058     hr_utility.set_location(l_proc, 340);
17059  end if;
17060     --
17061     -- Maintain spinal point placements.
17062     --
17063     hr_assignment_internal.maintain_spp_asg
17064       (p_assignment_id                => p_assignment_id
17065       ,p_datetrack_mode               => l_new_dt_update_mode
17066       ,p_validation_start_date        => l_validation_start_date
17067       ,p_validation_end_date          => l_validation_end_date
17068       ,p_grade_id		                   => p_grade_id
17069       ,p_spp_delete_warning           => l_spp_delete_warning
17070       );
17071   else
17072     --
17073  if g_debug then
17074     hr_utility.set_location(l_proc, 350);
17075  end if;
17076     --
17077     -- No SPPs to maintain.
17078     --
17079     l_spp_delete_warning := FALSE;
17080   end if;
17081   --
17082  if g_debug then
17083   hr_utility.set_location(l_proc, 360);
17084  end if;
17085   --
17086   -- IF GB legislation and payroll has changed, then delete latest balance
17087   -- values,
17088   --
17089   open  csr_get_legislation_code;
17090   fetch csr_get_legislation_code
17091    into l_legislation_code;
17092   --
17093   if csr_get_legislation_code%NOTFOUND then
17094     --
17095     close csr_get_legislation_code;
17096     --
17097  if g_debug then
17098     hr_utility.set_location(l_proc, 370);
17099  end if;
17100     --
17101     -- This should never happen!
17102     --
17103     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
17104     hr_utility.set_message_token('PROCEDURE', l_proc);
17105     hr_utility.set_message_token('STEP', '215');
17106     hr_utility.raise_error;
17107   end if;
17108   --
17109   close csr_get_legislation_code;
17110   --
17111  if g_debug then
17112   hr_utility.set_location(l_proc, 380);
17113  end if;
17114   --
17115   if  l_legislation_code = 'GB'
17116   and l_payroll_id_updated
17117   then
17118     --
17119  if g_debug then
17120     hr_utility.set_location(l_proc, 390);
17121  end if;
17122     --
17123     -- Delete latest balance values.
17124     --
17125     py_gb_asg.payroll_transfer
17126       (p_assignment_id => p_assignment_id);
17127     --
17128     -- When GB legislation, and the business group and the payroll has changed,
17129     -- set the Print P45 flag on the assignments extra info flexfield, and set
17130     -- the changed tax district warning out parameter.
17131     -- This functionality will be supported at a later date.
17132     --
17133     l_tax_district_changed_warning := FALSE;
17134   else
17135     --
17136  if g_debug then
17137     hr_utility.set_location(l_proc, 400);
17138  end if;
17139     --
17140     l_tax_district_changed_warning := FALSE;
17141   end if;
17142   --
17143  if g_debug then
17144   hr_utility.set_location(l_proc, 410);
17145  end if;
17146   --
17147   --
17148   begin
17149     --
17150     -- Start of API User Hook for the after hook of update_emp_asg_criteria
17151     --
17152     hr_assignment_bk3.update_emp_asg_criteria_a
17153       (p_effective_date               => l_effective_date
17154       ,p_datetrack_update_mode        => l_dt_update_mode
17155       ,p_assignment_id                => p_assignment_id
17156       ,p_object_version_number        => p_object_version_number
17157       ,p_grade_id                     => p_grade_id
17158       ,p_position_id                  => p_position_id
17159       ,p_job_id                       => l_job_id -- Bug 3553286 p_job_id
17160       ,p_payroll_id                   => p_payroll_id
17161       ,p_location_id                  => p_location_id
17162       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
17163       ,p_organization_id              => l_org_id -- Bug 3553286 p_organization_id
17164       ,p_pay_basis_id                 => p_pay_basis_id
17165       ,p_segment1                     => l_pgp_segment1
17166       ,p_segment2                     => l_pgp_segment2
17167       ,p_segment3                     => l_pgp_segment3
17168       ,p_segment4                     => l_pgp_segment4
17169       ,p_segment5                     => l_pgp_segment5
17170       ,p_segment6                     => l_pgp_segment6
17171       ,p_segment7                     => l_pgp_segment7
17172       ,p_segment8                     => l_pgp_segment8
17173       ,p_segment9                     => l_pgp_segment9
17174       ,p_segment10                    => l_pgp_segment10
17175       ,p_segment11                    => l_pgp_segment11
17176       ,p_segment12                    => l_pgp_segment12
17177       ,p_segment13                    => l_pgp_segment13
17178       ,p_segment14                    => l_pgp_segment14
17179       ,p_segment15                    => l_pgp_segment15
17180       ,p_segment16                    => l_pgp_segment16
17181       ,p_segment17                    => l_pgp_segment17
17182       ,p_segment18                    => l_pgp_segment18
17183       ,p_segment19                    => l_pgp_segment19
17184       ,p_segment20                    => l_pgp_segment20
17185       ,p_segment21                    => l_pgp_segment21
17186       ,p_segment22                    => l_pgp_segment22
17187       ,p_segment23                    => l_pgp_segment23
17188       ,p_segment24                    => l_pgp_segment24
17189       ,p_segment25                    => l_pgp_segment25
17190       ,p_segment26                    => l_pgp_segment26
17191       ,p_segment27                    => l_pgp_segment27
17192       ,p_segment28                    => l_pgp_segment28
17193       ,p_segment29                    => l_pgp_segment29
17194       ,p_segment30                    => l_pgp_segment30
17195       ,p_group_name                   => l_group_name
17196       ,p_employment_category          => p_employment_category
17197       ,p_effective_start_date         => l_effective_start_date
17198       ,p_effective_end_date           => l_effective_end_date
17199       ,p_people_group_id              => l_people_group_id
17200       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
17201       ,p_other_manager_warning        => l_other_manager_warning
17202       ,p_spp_delete_warning           => l_spp_delete_warning
17203       ,p_entries_changed_warning      => l_entries_changed_warning
17204       ,p_tax_district_changed_warning => l_tax_district_changed_warning
17205        --
17206        -- Bug 944911
17207        -- Added the new in param
17208        --
17209       ,p_concat_segments              => l_old_group_name
17210 -- Start of Fix for Bug 2622747
17211       ,p_contract_id                  => p_contract_id
17212       ,p_establishment_id             => p_establishment_id
17213       ,p_concatenated_segments        => l_concatenated_segments
17214       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
17215       ,p_scl_segment1                 => l_scl_segment1
17216 -- End of Fix for Bug 2622747
17217       );
17218   exception
17219     when hr_api.cannot_find_prog_unit then
17220       hr_api.cannot_find_prog_unit_error
17221         (p_module_name => 'UPDATE_EMP_ASG_CRITERIA'
17222         ,p_hook_type   => 'AP'
17223         );
17224     --
17225     -- End of API User Hook for the after hook of update_emp_asg_criteria
17226     --
17227   end;
17228 
17229   --
17230   -- call pqh post process procedure -- bug 2999562
17231   --
17232   pqh_gsp_post_process.call_pp_from_assignments(
17233       p_effective_date    => p_effective_date
17234      ,p_assignment_id     => p_assignment_id
17235      ,p_date_track_mode   => p_datetrack_update_mode
17236      ,p_warning_mesg      => l_gsp_post_process_warning
17237   );
17238 
17239   --
17240   --
17241   -- When in validation only mode raise the Validate_Enabled exception
17242   --
17243   if p_validate then
17244     raise hr_api.validate_enabled;
17245   end if;
17246   --
17247   -- Set all output arguments
17248   --
17249   p_effective_end_date           := l_effective_end_date;
17250   p_effective_start_date         := l_effective_start_date;
17251   p_people_group_id              := l_people_group_id;
17252   p_group_name                   := l_group_name;
17253   p_entries_changed_warning      := l_entries_changed_warning;
17254   p_object_version_number        := l_object_version_number;
17255   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
17256   p_other_manager_warning        := l_other_manager_warning;
17257   p_special_ceiling_step_id      := l_special_ceiling_step_id;
17258   p_spp_delete_warning           := l_spp_delete_warning;
17259   p_tax_district_changed_warning := l_tax_district_changed_warning;
17260   p_gsp_post_process_warning     := l_gsp_post_process_warning; -- bug 2999562
17261   --
17262   --
17263   -- remove data from the session table
17264   hr_kflex_utility.unset_session_date
17265     (p_session_id     => l_session_id);
17266   --
17267  if g_debug then
17268   hr_utility.set_location(' Leaving:'||l_proc, 997);
17269  end if;
17270   --
17271 exception
17272   when hr_api.validate_enabled then
17273     --
17274  if g_debug then
17275     hr_utility.set_location(' Leaving:'||l_proc, 998);
17276  end if;
17277     --
17278     -- As the Validate_Enabled exception has been raised
17279     -- we must rollback to the savepoint
17280     --
17281     ROLLBACK TO update_emp_asg_criteria;
17282     --
17283     -- Only set output warning arguments
17284     -- (Any key or derived arguments must be set to null
17285     -- when validation only mode is being used.)
17286     --
17287     p_effective_end_date           := null;
17288     p_effective_start_date         := null;
17289     p_entries_changed_warning      := l_entries_changed_warning;
17290     p_group_name                   := l_old_group_name;
17291     p_object_version_number        := p_object_version_number;
17292     p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
17293     p_other_manager_warning        := l_other_manager_warning;
17294     p_people_group_id              := null;
17295     p_special_ceiling_step_id      := p_special_ceiling_step_id;
17296     p_spp_delete_warning           := l_spp_delete_warning;
17297     p_tax_district_changed_warning := l_tax_district_changed_warning;
17298     p_concatenated_segments        := l_concatenated_segments;
17299     p_soft_coding_keyflex_id       := l_soft_coding_keyflex_id;
17300     p_gsp_post_process_warning     := l_gsp_post_process_warning; -- bug 2999562
17301     --
17302     if l_pgp_null_ind = 0   -- bug 2359997 only re-set to null if
17303                             -- p_people_group_id came in as null.
17304     then
17305        p_people_group_id    := null;
17306     end if;
17307     --
17308   when others then
17309     --
17310  if g_debug then
17311     hr_utility.set_location(' Leaving:'||l_proc, 999);
17312  end if;
17313     --
17314     -- A validation or unexpected error has occurred
17315     --
17316     -- Added as part of fix to bug 632479
17317     --
17318     p_object_version_number        := lv_object_version_number ;
17319     p_special_ceiling_step_id      := lv_special_ceiling_step_id ;
17320     p_people_group_id              := lv_people_group_id ;
17321     p_soft_coding_keyflex_id       := lv_soft_coding_keyflex_id ;
17322 
17323     p_group_name                      := null;
17324     p_effective_start_date            := null;
17325     p_effective_end_date              := null;
17326     p_org_now_no_manager_warning      := null;
17327     p_other_manager_warning           := null;
17328     p_spp_delete_warning              := null;
17329     p_entries_changed_warning         := null;
17330     p_tax_district_changed_warning    := null;
17331     p_concatenated_segments           := null;
17332     p_gsp_post_process_warning        := null;
17333 
17334     ROLLBACK TO update_emp_asg_criteria;
17335     raise;
17336     --
17337     -- End of fix.
17338     --
17339 end update_emp_asg_criteria;
17340 --
17341 -- ----------------------------------------------------------------------------
17342 -- |--------------------------< update_apl_asg >------------------------------|
17343 -- ----------------------------------------------------------------------------
17344 --
17345 -- added new parameters notice_period, units, employee_category,
17346 -- work_at_home and job_source on 05-OCT-01
17347 
17348 procedure update_apl_asg
17349   (p_validate                     in     boolean
17350   ,p_effective_date               in     date
17351   ,p_datetrack_update_mode        in     varchar2
17352   ,p_assignment_id                in     number
17353   ,p_object_version_number        in out nocopy number
17354   ,p_recruiter_id                 in     number
17355   ,p_grade_id                     in     number
17356   ,p_position_id                  in     number
17357   ,p_job_id                       in     number
17358   ,p_payroll_id                   in     number
17359   ,p_location_id                  in     number
17360   ,p_person_referred_by_id        in     number
17361   ,p_supervisor_id                in     number
17362   ,p_special_ceiling_step_id      in     number
17363   ,p_recruitment_activity_id      in     number
17364   ,p_source_organization_id       in     number
17365   ,p_organization_id              in     number
17366   ,p_vacancy_id                   in     number
17367   ,p_pay_basis_id                 in     number
17368   ,p_application_id               in     number
17369   ,p_change_reason                in     varchar2
17370   ,p_assignment_status_type_id    in     number
17371   ,p_comments                     in     varchar2
17372   ,p_date_probation_end           in     date
17373   ,p_default_code_comb_id         in     number
17374   ,p_employment_category          in     varchar2
17375   ,p_frequency                    in     varchar2
17376   ,p_internal_address_line        in     varchar2
17377   ,p_manager_flag                 in     varchar2
17378   ,p_normal_hours                 in     number
17379   ,p_perf_review_period           in     number
17380   ,p_perf_review_period_frequency in     varchar2
17381   ,p_probation_period             in     number
17382   ,p_probation_unit               in     varchar2
17383   ,p_sal_review_period            in     number
17384   ,p_sal_review_period_frequency  in     varchar2
17385   ,p_set_of_books_id              in     number
17386   ,p_source_type                  in     varchar2
17387   ,p_time_normal_finish           in     varchar2
17388   ,p_time_normal_start            in     varchar2
17389   ,p_bargaining_unit_code         in     varchar2
17390   ,p_ass_attribute_category       in     varchar2
17391   ,p_ass_attribute1               in     varchar2
17392   ,p_ass_attribute2               in     varchar2
17393   ,p_ass_attribute3               in     varchar2
17394   ,p_ass_attribute4               in     varchar2
17395   ,p_ass_attribute5               in     varchar2
17396   ,p_ass_attribute6               in     varchar2
17397   ,p_ass_attribute7               in     varchar2
17398   ,p_ass_attribute8               in     varchar2
17399   ,p_ass_attribute9               in     varchar2
17400   ,p_ass_attribute10              in     varchar2
17401   ,p_ass_attribute11              in     varchar2
17402   ,p_ass_attribute12              in     varchar2
17403   ,p_ass_attribute13              in     varchar2
17404   ,p_ass_attribute14              in     varchar2
17405   ,p_ass_attribute15              in     varchar2
17406   ,p_ass_attribute16              in     varchar2
17407   ,p_ass_attribute17              in     varchar2
17408   ,p_ass_attribute18              in     varchar2
17409   ,p_ass_attribute19              in     varchar2
17410   ,p_ass_attribute20              in     varchar2
17411   ,p_ass_attribute21              in     varchar2
17412   ,p_ass_attribute22              in     varchar2
17413   ,p_ass_attribute23              in     varchar2
17414   ,p_ass_attribute24              in     varchar2
17415   ,p_ass_attribute25              in     varchar2
17416   ,p_ass_attribute26              in     varchar2
17417   ,p_ass_attribute27              in     varchar2
17418   ,p_ass_attribute28              in     varchar2
17419   ,p_ass_attribute29              in     varchar2
17420   ,p_ass_attribute30              in     varchar2
17421   ,p_title                        in     varchar2
17422   ,p_scl_segment1                 in     varchar2
17423   ,p_scl_segment2                 in     varchar2
17424   ,p_scl_segment3                 in     varchar2
17425   ,p_scl_segment4                 in     varchar2
17426   ,p_scl_segment5                 in     varchar2
17427   ,p_scl_segment6                 in     varchar2
17428   ,p_scl_segment7                 in     varchar2
17429   ,p_scl_segment8                 in     varchar2
17430   ,p_scl_segment9                 in     varchar2
17431   ,p_scl_segment10                in     varchar2
17432   ,p_scl_segment11                in     varchar2
17433   ,p_scl_segment12                in     varchar2
17434   ,p_scl_segment13                in     varchar2
17435   ,p_scl_segment14                in     varchar2
17436   ,p_scl_segment15                in     varchar2
17437   ,p_scl_segment16                in     varchar2
17438   ,p_scl_segment17                in     varchar2
17439   ,p_scl_segment18                in     varchar2
17440   ,p_scl_segment19                in     varchar2
17441   ,p_scl_segment20                in     varchar2
17442   ,p_scl_segment21                in     varchar2
17443   ,p_scl_segment22                in     varchar2
17444   ,p_scl_segment23                in     varchar2
17445   ,p_scl_segment24                in     varchar2
17446   ,p_scl_segment25                in     varchar2
17447   ,p_scl_segment26                in     varchar2
17448   ,p_scl_segment27                in     varchar2
17449   ,p_scl_segment28                in     varchar2
17450   ,p_scl_segment29                in     varchar2
17451   ,p_scl_segment30                in     varchar2
17452 -- Bug 944911
17453 -- Amended p_scl_concatenated_segments to be an out instead of in out
17454 -- Added p_scl_concat_segments ( in param )
17455 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
17456   ,p_scl_concat_segments          in     varchar2
17457   ,p_concatenated_segments           out nocopy varchar2
17458   ,p_pgp_segment1                 in     varchar2
17459   ,p_pgp_segment2                 in     varchar2
17460   ,p_pgp_segment3                 in     varchar2
17461   ,p_pgp_segment4                 in     varchar2
17462   ,p_pgp_segment5                 in     varchar2
17463   ,p_pgp_segment6                 in     varchar2
17464   ,p_pgp_segment7                 in     varchar2
17465   ,p_pgp_segment8                 in     varchar2
17466   ,p_pgp_segment9                 in     varchar2
17467   ,p_pgp_segment10                in     varchar2
17468   ,p_pgp_segment11                in     varchar2
17469   ,p_pgp_segment12                in     varchar2
17470   ,p_pgp_segment13                in     varchar2
17471   ,p_pgp_segment14                in     varchar2
17472   ,p_pgp_segment15                in     varchar2
17473   ,p_pgp_segment16                in     varchar2
17474   ,p_pgp_segment17                in     varchar2
17475   ,p_pgp_segment18                in     varchar2
17476   ,p_pgp_segment19                in     varchar2
17477   ,p_pgp_segment20                in     varchar2
17478   ,p_pgp_segment21                in     varchar2
17479   ,p_pgp_segment22                in     varchar2
17480   ,p_pgp_segment23                in     varchar2
17481   ,p_pgp_segment24                in     varchar2
17482   ,p_pgp_segment25                in     varchar2
17483   ,p_pgp_segment26                in     varchar2
17484   ,p_pgp_segment27                in     varchar2
17485   ,p_pgp_segment28                in     varchar2
17486   ,p_pgp_segment29                in     varchar2
17487   ,p_pgp_segment30                in     varchar2
17488 -- Bug 944911
17489 -- Made p_group_name to be out param
17490 -- and add p_concat_segment to be IN
17491 -- in case of sec_asg alone made p_pgp_concat_segments as in param
17492   ,p_concat_segments              in     varchar2
17493   ,p_contract_id                  in     number
17494   ,p_establishment_id             in     number
17495   ,p_collective_agreement_id      in     number
17496   ,p_cagr_id_flex_num             in     number
17497   ,p_cag_segment1                 in     varchar2
17498   ,p_cag_segment2                 in     varchar2
17499   ,p_cag_segment3                 in     varchar2
17500   ,p_cag_segment4                 in     varchar2
17501   ,p_cag_segment5                 in     varchar2
17502   ,p_cag_segment6                 in     varchar2
17503   ,p_cag_segment7                 in     varchar2
17504   ,p_cag_segment8                 in     varchar2
17505   ,p_cag_segment9                 in     varchar2
17506   ,p_cag_segment10                in     varchar2
17507   ,p_cag_segment11                in     varchar2
17508   ,p_cag_segment12                in     varchar2
17509   ,p_cag_segment13                in     varchar2
17510   ,p_cag_segment14                in     varchar2
17511   ,p_cag_segment15                in     varchar2
17512   ,p_cag_segment16                in     varchar2
17513   ,p_cag_segment17                in     varchar2
17514   ,p_cag_segment18                in     varchar2
17515   ,p_cag_segment19                in     varchar2
17516   ,p_cag_segment20                in     varchar2
17517   ,p_notice_period		  in     number
17518   ,p_notice_period_uom	      	  in     varchar2
17519   ,p_employee_category	          in     varchar2
17520   ,p_work_at_home		  in     varchar2
17521   ,p_job_post_source_name	  in     varchar2
17522   ,p_posting_content_id           in     number
17523   ,p_applicant_rank               in     number
17524   ,p_grade_ladder_pgm_id          in     number
17525   ,p_supervisor_assignment_id     in     number
17526   ,p_cagr_grade_def_id            in out nocopy number
17527   ,p_cagr_concatenated_segments      out nocopy varchar2
17528   ,p_group_name                      out nocopy varchar2
17529   ,p_comment_id                      out nocopy number
17530   ,p_people_group_id              in out nocopy number
17531   ,p_soft_coding_keyflex_id       in out nocopy number
17532   ,p_effective_start_date            out nocopy date
17533   ,p_effective_end_date              out nocopy date
17534  ) is
17535   --
17536   -- Declare cursors and local variables
17537   --
17538   -- Out variables
17539   --
17540   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
17541   l_business_group_id          per_all_assignments_f.business_group_id%TYPE;
17542   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
17543   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
17544   l_dummy_payroll              boolean;
17545   l_dummy_manager1             boolean;
17546   l_dummy_manager2             boolean;
17547   l_dummy_manager3             boolean;
17548   l_hourly_salaried_warning    boolean;
17549   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
17550   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
17551   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
17552   l_effective_date             date;
17553   l_date_probation_end         date;
17554   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
17555   l_organization_id            per_all_assignments_f.organization_id%type;
17556   l_location_id                per_all_assignments_f.location_id%type;
17557   l_cagr_grade_def_id          per_cagr_grades_def.cagr_grade_def_id%TYPE         := p_cagr_grade_def_id;
17558   l_cagr_id_flex_num           per_cagr_grades_def.id_flex_num%TYPE;
17559   l_unused_start_date          date;
17560   l_unused_end_date            date;
17561   l_cagr_concatenated_segments varchar2(2000);
17562   --
17563   -- Internal working variables
17564   --
17565   l_assignment_status_id       number;
17566   l_asg_status_ovn             number;
17567   --
17568   l_people_group_id            per_all_assignments_f.people_group_id%TYPE         := p_people_group_id;
17569   l_group_name                 pay_people_groups.group_name%TYPE;
17570   l_old_group_name             pay_people_groups.group_name%TYPE;
17571   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE  := p_soft_coding_keyflex_id;
17572   l_scl_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE  ;
17573   l_old_scl_conc_segments hr_soft_coding_keyflex.concatenated_segments%TYPE;
17574   l_proc                       varchar2(72) := g_package||'update_apl_asg';
17575   l_api_updating               boolean;
17576   l_session_id                 number;
17577   l_old_asg_status per_assignment_status_types.per_system_status%type;
17578   l_new_asg_status per_assignment_status_types.per_system_status%type;
17579   --
17580   -- bug 2230915 new variables to indicate whether key flex id parameters
17581   -- enter the program with a value.
17582   --
17583   l_pgp_null_ind               number(1) := 0;
17584   l_scl_null_ind               number(1) := 0;
17585   l_cag_null_ind               number(1) := 0;
17586   --
17587   -- bug 2230915 new variables for derived values where key flex id is known.
17588   --
17589   l_scl_segment1               varchar2(60) := p_scl_segment1;
17590   l_scl_segment2               varchar2(60) := p_scl_segment2;
17591   l_scl_segment3               varchar2(60) := p_scl_segment3;
17592   l_scl_segment4               varchar2(60) := p_scl_segment4;
17593   l_scl_segment5               varchar2(60) := p_scl_segment5;
17594   l_scl_segment6               varchar2(60) := p_scl_segment6;
17595   l_scl_segment7               varchar2(60) := p_scl_segment7;
17596   l_scl_segment8               varchar2(60) := p_scl_segment8;
17597   l_scl_segment9               varchar2(60) := p_scl_segment9;
17598   l_scl_segment10              varchar2(60) := p_scl_segment10;
17599   l_scl_segment11              varchar2(60) := p_scl_segment11;
17600   l_scl_segment12              varchar2(60) := p_scl_segment12;
17601   l_scl_segment13              varchar2(60) := p_scl_segment13;
17602   l_scl_segment14              varchar2(60) := p_scl_segment14;
17603   l_scl_segment15              varchar2(60) := p_scl_segment15;
17604   l_scl_segment16              varchar2(60) := p_scl_segment16;
17605   l_scl_segment17              varchar2(60) := p_scl_segment17;
17606   l_scl_segment18              varchar2(60) := p_scl_segment18;
17607   l_scl_segment19              varchar2(60) := p_scl_segment19;
17608   l_scl_segment20              varchar2(60) := p_scl_segment20;
17609   l_scl_segment21              varchar2(60) := p_scl_segment21;
17610   l_scl_segment22              varchar2(60) := p_scl_segment22;
17611   l_scl_segment23              varchar2(60) := p_scl_segment23;
17612   l_scl_segment24              varchar2(60) := p_scl_segment24;
17613   l_scl_segment25              varchar2(60) := p_scl_segment25;
17614   l_scl_segment26              varchar2(60) := p_scl_segment26;
17615   l_scl_segment27              varchar2(60) := p_scl_segment27;
17616   l_scl_segment28              varchar2(60) := p_scl_segment28;
17617   l_scl_segment29              varchar2(60) := p_scl_segment29;
17618   l_scl_segment30              varchar2(60) := p_scl_segment30;
17619   --
17620   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
17621   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
17622   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
17623   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
17624   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
17625   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
17626   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
17627   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
17628   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
17629   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
17630   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
17631   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
17632   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
17633   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
17634   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
17635   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
17636   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
17637   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
17638   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
17639   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
17640   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
17641   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
17642   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
17643   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
17644   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
17645   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
17646   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
17647   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
17648   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
17649   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
17650   --
17651   l_cag_segment1               varchar2(60) := p_cag_segment1;
17652   l_cag_segment2               varchar2(60) := p_cag_segment2;
17653   l_cag_segment3               varchar2(60) := p_cag_segment3;
17654   l_cag_segment4               varchar2(60) := p_cag_segment4;
17655   l_cag_segment5               varchar2(60) := p_cag_segment5;
17656   l_cag_segment6               varchar2(60) := p_cag_segment6;
17657   l_cag_segment7               varchar2(60) := p_cag_segment7;
17658   l_cag_segment8               varchar2(60) := p_cag_segment8;
17659   l_cag_segment9               varchar2(60) := p_cag_segment9;
17660   l_cag_segment10              varchar2(60) := p_cag_segment10;
17661   l_cag_segment11              varchar2(60) := p_cag_segment11;
17662   l_cag_segment12              varchar2(60) := p_cag_segment12;
17663   l_cag_segment13              varchar2(60) := p_cag_segment13;
17664   l_cag_segment14              varchar2(60) := p_cag_segment14;
17665   l_cag_segment15              varchar2(60) := p_cag_segment15;
17666   l_cag_segment16              varchar2(60) := p_cag_segment16;
17667   l_cag_segment17              varchar2(60) := p_cag_segment17;
17668   l_cag_segment18              varchar2(60) := p_cag_segment18;
17669   l_cag_segment19              varchar2(60) := p_cag_segment19;
17670   l_cag_segment20              varchar2(60) := p_cag_segment20;
17671   --
17672   lv_object_version_number     number := p_object_version_number ;
17673   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
17674   lv_people_group_id           number := p_people_group_id ;
17675   lv_soft_coding_keyflex_id    number := p_soft_coding_keyflex_id ;
17676 
17677   --
17678   cursor csr_old_asg_status is
17679   select ast.per_system_status
17680   from per_assignment_status_types ast,
17681        per_all_assignments_f asg
17682   where ast.assignment_status_type_id = asg.assignment_status_type_id
17683   and   asg.assignment_id = p_assignment_id
17684   and   l_effective_date between asg.effective_start_date and asg.effective_end_date;
17685   --
17686   cursor csr_new_asg_status is
17687   select ast.per_system_status
17688   from per_assignment_status_types ast
17689   where ast.assignment_status_type_id = p_assignment_status_type_id;
17690   --
17691   --
17692   cursor csr_grp_idsel is
17693     select bus.people_group_structure
17694      from  per_business_groups_perf bus
17695      where bus.business_group_id = l_business_group_id;
17696   --
17697   cursor csr_scl_idsel is
17698     select plr.rule_mode                       id_flex_num
17699     from   pay_legislation_rules               plr,
17700            per_business_groups_perf            pgr
17701     where  plr.legislation_code                = pgr.legislation_code
17702     and    pgr.business_group_id               = l_business_group_id
17703     and    plr.rule_type                       = 'S'
17704     and    exists
17705           (select 1
17706            from   fnd_segment_attribute_values fsav
17707            where  to_char(fsav.id_flex_num)    = plr.rule_mode -- Fix For Bug# 12813119
17708            and    fsav.application_id          = 800
17709            and    fsav.id_flex_code            = 'SCL'
17710            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
17711            and    fsav.attribute_value         = 'Y')
17712     and    exists
17713           (select 1
17714            from   pay_legislation_rules        plr2
17715            where  plr2.legislation_code        = plr.legislation_code
17716            and    plr2.rule_type               = 'SDL'
17717            and    plr2.rule_mode               = 'A') ;
17718   --
17719   cursor get_sec_date_range is
17720      select asg.effective_start_date
17721      ,      asg.effective_end_date
17722      from   per_all_assignments_f asg
17723      where  asg.assignment_id=p_assignment_id
17724      and   ((sysdate between asg.effective_start_date
17725             and asg.effective_end_date)
17726             or
17727            (sysdate<asg.effective_start_date
17728             and not exists
17729             (select 1
17730              from per_all_assignments_f asg2
17731              where asg2.person_id=asg.person_id
17732              and asg2.application_id=asg.application_id
17733              and asg2.effective_start_date<asg.effective_start_date)
17734              )
17735             );
17736   --
17737   l_sec_effective_start_date date;
17738   l_sec_effective_end_date date;
17739   --
17740   -- bug 2230915 get pay_people_group segment values where
17741   -- people_group_id is known
17742   --
17743   cursor c_pgp_segments is
17744      select segment1,
17745             segment2,
17746             segment3,
17747             segment4,
17748             segment5,
17749             segment6,
17750             segment7,
17751             segment8,
17752             segment9,
17753             segment10,
17754             segment11,
17755             segment12,
17756             segment13,
17757             segment14,
17758             segment15,
17759             segment16,
17760             segment17,
17761             segment18,
17762             segment19,
17763             segment20,
17764             segment21,
17765             segment22,
17766             segment23,
17767             segment24,
17768             segment25,
17769             segment26,
17770             segment27,
17771             segment28,
17772             segment29,
17773             segment30
17774      from   pay_people_groups
17775      where  people_group_id = l_people_group_id;
17776   --
17777   -- bug 2230915 get hr_soft_coding_keyflex segment values where
17778   -- soft_coding_keyflex_id is known
17779   --
17780   cursor c_scl_segments is
17781      select segment1,
17782             segment2,
17783             segment3,
17784             segment4,
17785             segment5,
17786             segment6,
17787             segment7,
17788             segment8,
17789             segment9,
17790             segment10,
17791             segment11,
17792             segment12,
17793             segment13,
17794             segment14,
17795             segment15,
17796             segment16,
17797             segment17,
17798             segment18,
17799             segment19,
17800             segment20,
17801             segment21,
17802             segment22,
17803             segment23,
17804             segment24,
17805             segment25,
17806             segment26,
17807             segment27,
17808             segment28,
17809             segment29,
17810             segment30
17811      from   hr_soft_coding_keyflex
17812      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
17813   --
17814   -- bug 2230915 get per_cagr_grades_def segment values where
17815   -- cagr_grade_def_id is known
17816   --
17817   cursor c_cag_segments is
17818      select segment1,
17819             segment2,
17820             segment3,
17821             segment4,
17822             segment5,
17823             segment6,
17824             segment7,
17825             segment8,
17826             segment9,
17827             segment10,
17828             segment11,
17829             segment12,
17830             segment13,
17831             segment14,
17832             segment15,
17833             segment16,
17834             segment17,
17835             segment18,
17836             segment19,
17837             segment20
17838      from   per_cagr_grades_def
17839      where  cagr_grade_def_id = l_cagr_grade_def_id;
17840 --
17841 -- fix for bug 5938120 starts here.
17842 l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
17843 
17844 cursor csr_get_assign(csr_person_id number) is
17845 select assignment_id
17846 from per_all_assignments_f
17847 where person_id=csr_person_id
17848 and business_group_id=l_business_group_id
17849 and l_effective_date between effective_start_date and effective_end_date
17850 and assignment_type not in ('B','O'); -- added for the bug 6925339
17851 -- fix for bug 5938120 ends here.
17852 l_asg_status_type_id number; --12427559
17853 --
17854 begin
17855 --
17856  if g_debug then
17857   hr_utility.set_location('Entering:'|| l_proc, 10);
17858  end if;
17859   --
17860   --Truncate the parameter p_effective_date to a local variable
17861   --
17862   l_effective_date       := trunc(p_effective_date);
17863   l_date_probation_end   := trunc(p_date_probation_end);
17864 -- Bug 944911
17865 -- Made p_group_name to be out param
17866 -- and add p_concat_segment to be IN
17867 -- in case of sec_asg alone made p_pgp_concat_segments as in param
17868 -- Replaced p_group_name by p_concat_segments
17869   l_old_group_name       := p_concat_segments;
17870 -- Bug 944911
17871 -- Amended p_scl_concatenated_segments to p_scl_concat_segments
17872   l_old_scl_conc_segments := p_scl_concat_segments;
17873   --
17874   -- Issue a savepoint.
17875   --
17876   savepoint update_apl_asg;
17877   --
17878  if g_debug then
17879   hr_utility.set_location(l_proc, 20);
17880  end if;
17881   --
17882   l_object_version_number := p_object_version_number;
17883   --
17884   -- Validation in addition to Table Handlers
17885   --
17886   -- Check mandatory arguments
17887   --
17888   hr_api.mandatory_arg_error
17889     (p_api_name       => l_proc
17890     ,p_argument       => 'assignment_id'
17891     ,p_argument_value => p_assignment_id);
17892   --
17893   hr_api.mandatory_arg_error
17894     (p_api_name       => l_proc
17895     ,p_argument       => 'effective_date'
17896     ,p_argument_value => l_effective_date);
17897   --
17898   hr_api.mandatory_arg_error
17899     (p_api_name       => l_proc
17900     ,p_argument       => 'datetrack_update_mode'
17901     ,p_argument_value => p_datetrack_update_mode);
17902   --
17903   hr_api.mandatory_arg_error
17904     (p_api_name       => l_proc
17905     ,p_argument       => 'object_version_number'
17906     ,p_argument_value => l_object_version_number);
17907   --
17908   -- Retrieve current assignment details from database.
17909   --
17910   l_api_updating := per_asg_shd.api_updating
17911     (p_assignment_id         => p_assignment_id
17912     ,p_effective_date        => l_effective_date
17913     ,p_object_version_number => l_object_version_number);
17914   --
17915  if g_debug then
17916   hr_utility.set_location(l_proc, 30);
17917  end if;
17918   --
17919   if not l_api_updating
17920   then
17921     --
17922  if g_debug then
17923     hr_utility.set_location(l_proc, 40);
17924  end if;
17925     --
17926     -- As this is an updating API, the assignment should already exist.
17927     --
17928     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
17929     hr_utility.raise_error;
17930   end if;
17931   --
17932   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
17933   -- Populate l_people_group_id from g_old_rec for upd_or_sel_key_flex
17934   -- 2230915 only populate l_people_group_id from g_old_rec
17935   -- if p_people_group_id did not enter with a value.  If it did enter with
17936   -- a value then get segment values from pay_people_groups.
17937   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
17938   -- per_cagr_grades_def
17939   --
17940   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
17941   --
17942  if g_debug then
17943   hr_utility.set_location(l_proc, 45);
17944  end if;
17945   --
17946   if l_people_group_id is null
17947   then
17948     --
17949     l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
17950     l_pgp_null_ind := 0;
17951   else
17952     -- get segment values
17953     open c_pgp_segments;
17954       fetch c_pgp_segments into l_pgp_segment1,
17955                                 l_pgp_segment2,
17956                                 l_pgp_segment3,
17957                                 l_pgp_segment4,
17958                                 l_pgp_segment5,
17959                                 l_pgp_segment6,
17960                                 l_pgp_segment7,
17961                                 l_pgp_segment8,
17962                                 l_pgp_segment9,
17963                                 l_pgp_segment10,
17964                                 l_pgp_segment11,
17965                                 l_pgp_segment12,
17966                                 l_pgp_segment13,
17967                                 l_pgp_segment14,
17968                                 l_pgp_segment15,
17969                                 l_pgp_segment16,
17970                                 l_pgp_segment17,
17971                                 l_pgp_segment18,
17972                                 l_pgp_segment19,
17973                                 l_pgp_segment20,
17974                                 l_pgp_segment21,
17975                                 l_pgp_segment22,
17976                                 l_pgp_segment23,
17977                                 l_pgp_segment24,
17978                                 l_pgp_segment25,
17979                                 l_pgp_segment26,
17980                                 l_pgp_segment27,
17981                                 l_pgp_segment28,
17982                                 l_pgp_segment29,
17983                                 l_pgp_segment30;
17984     close c_pgp_segments;
17985   end if;
17986   --  use cursor c_scl_segments to bring back segment values if
17987   --  l_soft_coding_keyflex_id has a value.
17988   if l_soft_coding_keyflex_id is not null
17989   then
17990     l_scl_null_ind := 1;
17991     open c_scl_segments;
17992       fetch c_scl_segments into l_scl_segment1,
17993                                l_scl_segment2,
17994                                l_scl_segment3,
17995                                l_scl_segment4,
17996                                l_scl_segment5,
17997                                l_scl_segment6,
17998                                l_scl_segment7,
17999                                l_scl_segment8,
18000                                l_scl_segment9,
18001                                l_scl_segment10,
18002                                l_scl_segment11,
18003                                l_scl_segment12,
18004                                l_scl_segment13,
18005                                l_scl_segment14,
18006                                l_scl_segment15,
18007                                l_scl_segment16,
18008                                l_scl_segment17,
18009                                l_scl_segment18,
18010                                l_scl_segment19,
18011                                l_scl_segment20,
18012                                l_scl_segment21,
18013                                l_scl_segment22,
18014                                l_scl_segment23,
18015                                l_scl_segment24,
18016                                l_scl_segment25,
18017                                l_scl_segment26,
18018                                l_scl_segment27,
18019                                l_scl_segment28,
18020                                l_scl_segment29,
18021                                l_scl_segment30;
18022     close c_scl_segments;
18023   else
18024     l_scl_null_ind := 0;
18025   end if;
18026   --
18027   -- if cagr_grade_def_id has a value then use it to get segment values using
18028   -- cursor cag_segments
18029   --
18030   if l_cagr_grade_def_id is not null
18031   then
18032     l_cag_null_ind := 1;
18033     open c_cag_segments;
18034       fetch c_cag_segments into l_cag_segment1,
18035                                 l_cag_segment2,
18036                                 l_cag_segment3,
18037                                 l_cag_segment4,
18038                                 l_cag_segment5,
18039                                 l_cag_segment6,
18040                                 l_cag_segment7,
18041                                 l_cag_segment8,
18042                                 l_cag_segment9,
18043                                 l_cag_segment10,
18044                                 l_cag_segment11,
18045                                 l_cag_segment12,
18046                                 l_cag_segment13,
18047                                 l_cag_segment14,
18048                                 l_cag_segment15,
18049                                 l_cag_segment16,
18050                                 l_cag_segment17,
18051                                 l_cag_segment18,
18052                                 l_cag_segment19,
18053                                 l_cag_segment20;
18054     close c_cag_segments;
18055   else
18056     l_cag_null_ind := 0;
18057   end if;
18058   --
18059  if g_debug then
18060   hr_utility.set_location(l_proc, 60);
18061  end if;
18062   --
18063   -- Check that the assignment is an applicant assignment.
18064   --
18065   if per_asg_shd.g_old_rec.assignment_type <> 'A'
18066   then
18067     --
18068  if g_debug then
18069     hr_utility.set_location(l_proc, 70);
18070  end if;
18071     --
18072     hr_utility.set_message(801, 'HR_51036_ASG_ASG_NOT_APL');
18073     hr_utility.raise_error;
18074   end if;
18075   --
18076   -- Start of API User Hook for the before hook of update_apl_asg.
18077   --
18078   begin
18079       hr_assignment_bk5.update_apl_asg_b
18080        (p_effective_date               =>     l_effective_date
18081        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
18082        ,p_assignment_id                =>     p_assignment_id
18083        ,p_object_version_number        =>     p_object_version_number
18084        ,p_grade_id                     =>     p_grade_id
18085        ,p_job_id                       =>     p_job_id
18086        ,p_payroll_id                   =>     p_payroll_id
18087        ,p_location_id                  =>     p_location_id
18088        ,p_organization_id              =>     p_organization_id
18089        ,p_position_id                  =>     p_position_id
18090        ,p_application_id               =>     p_application_id
18091        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
18092        ,p_recruiter_id                 =>     p_recruiter_id
18093        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
18094        ,p_vacancy_id                   =>     p_vacancy_id
18095        ,p_pay_basis_id                 =>     p_pay_basis_id
18096        ,p_person_referred_by_id        =>     p_person_referred_by_id
18097        ,p_supervisor_id                =>     p_supervisor_id
18098        ,p_source_organization_id       =>     p_source_organization_id
18099        ,p_change_reason                =>     p_change_reason
18100        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
18101        ,p_internal_address_line        =>     p_internal_address_line
18102        ,p_default_code_comb_id         =>     p_default_code_comb_id
18103        ,p_employment_category          =>     p_employment_category
18104        ,p_frequency                    =>     p_frequency
18105        ,p_manager_flag                 =>     p_manager_flag
18106        ,p_normal_hours                 =>     p_normal_hours
18107        ,p_perf_review_period           =>     p_perf_review_period
18108        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
18109        ,p_probation_period             =>     p_probation_period
18110        ,p_probation_unit               =>     p_probation_unit
18111        ,p_sal_review_period            =>     p_sal_review_period
18112        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
18113        ,p_set_of_books_id              =>     p_set_of_books_id
18114        ,p_source_type                  =>     p_source_type
18115        ,p_time_normal_finish           =>     p_time_normal_finish
18116        ,p_time_normal_start            =>     p_time_normal_start
18117        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
18118        ,p_comments                     =>     p_comments
18119        ,p_date_probation_end           =>     l_date_probation_end
18120        ,p_title                        =>     p_title
18121        ,p_ass_attribute_category       =>     p_ass_attribute_category
18122        ,p_ass_attribute1               =>     p_ass_attribute1
18123        ,p_ass_attribute2               =>     p_ass_attribute2
18124        ,p_ass_attribute3               =>     p_ass_attribute3
18125        ,p_ass_attribute4               =>     p_ass_attribute4
18126        ,p_ass_attribute5               =>     p_ass_attribute5
18127        ,p_ass_attribute6               =>     p_ass_attribute6
18128        ,p_ass_attribute7               =>     p_ass_attribute7
18129        ,p_ass_attribute8               =>     p_ass_attribute8
18130        ,p_ass_attribute9               =>     p_ass_attribute9
18131        ,p_ass_attribute10              =>     p_ass_attribute10
18132        ,p_ass_attribute11              =>     p_ass_attribute11
18133        ,p_ass_attribute12              =>     p_ass_attribute12
18134        ,p_ass_attribute13              =>     p_ass_attribute13
18135        ,p_ass_attribute14              =>     p_ass_attribute14
18136        ,p_ass_attribute15              =>     p_ass_attribute15
18137        ,p_ass_attribute16              =>     p_ass_attribute16
18138        ,p_ass_attribute17              =>     p_ass_attribute17
18139        ,p_ass_attribute18              =>     p_ass_attribute18
18140        ,p_ass_attribute19              =>     p_ass_attribute19
18141        ,p_ass_attribute20              =>     p_ass_attribute20
18142        ,p_ass_attribute21              =>     p_ass_attribute21
18143        ,p_ass_attribute22              =>     p_ass_attribute22
18144        ,p_ass_attribute23              =>     p_ass_attribute23
18145        ,p_ass_attribute24              =>     p_ass_attribute24
18146        ,p_ass_attribute25              =>     p_ass_attribute25
18147        ,p_ass_attribute26              =>     p_ass_attribute26
18148        ,p_ass_attribute27              =>     p_ass_attribute27
18149        ,p_ass_attribute28              =>     p_ass_attribute28
18150        ,p_ass_attribute29              =>     p_ass_attribute29
18151        ,p_ass_attribute30              =>     p_ass_attribute30
18152        ,p_scl_segment1                 =>     l_scl_segment1
18153        ,p_scl_segment2                 =>     l_scl_segment2
18154        ,p_scl_segment3                 =>     l_scl_segment3
18155        ,p_scl_segment4                 =>     l_scl_segment4
18156        ,p_scl_segment5                 =>     l_scl_segment5
18157        ,p_scl_segment6                 =>     l_scl_segment6
18158        ,p_scl_segment7                 =>     l_scl_segment7
18159        ,p_scl_segment8                 =>     l_scl_segment8
18160        ,p_scl_segment9                 =>     l_scl_segment9
18161        ,p_scl_segment10                =>     l_scl_segment10
18162        ,p_scl_segment11                =>     l_scl_segment11
18163        ,p_scl_segment12                =>     l_scl_segment12
18164        ,p_scl_segment13                =>     l_scl_segment13
18165        ,p_scl_segment14                =>     l_scl_segment14
18166        ,p_scl_segment15                =>     l_scl_segment15
18167        ,p_scl_segment16                =>     l_scl_segment16
18168        ,p_scl_segment17                =>     l_scl_segment17
18169        ,p_scl_segment18                =>     l_scl_segment18
18170        ,p_scl_segment19                =>     l_scl_segment19
18171        ,p_scl_segment20                =>     l_scl_segment20
18172        ,p_scl_segment21                =>     l_scl_segment21
18173        ,p_scl_segment22                =>     l_scl_segment22
18174        ,p_scl_segment23                =>     l_scl_segment23
18175        ,p_scl_segment24                =>     l_scl_segment24
18176        ,p_scl_segment25                =>     l_scl_segment25
18177        ,p_scl_segment26                =>     l_scl_segment26
18178        ,p_scl_segment27                =>     l_scl_segment27
18179        ,p_scl_segment28                =>     l_scl_segment28
18180        ,p_scl_segment29                =>     l_scl_segment29
18181        ,p_scl_segment30                =>     l_scl_segment30
18182 -- Bug 944911
18183 -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
18184        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
18185        ,p_pgp_segment1                 =>     l_pgp_segment1
18186        ,p_pgp_segment2                 =>     l_pgp_segment2
18187        ,p_pgp_segment3                 =>     l_pgp_segment3
18188        ,p_pgp_segment4                 =>     l_pgp_segment4
18189        ,p_pgp_segment5                 =>     l_pgp_segment5
18190        ,p_pgp_segment6                 =>     l_pgp_segment6
18191        ,p_pgp_segment7                 =>     l_pgp_segment7
18192        ,p_pgp_segment8                 =>     l_pgp_segment8
18193        ,p_pgp_segment9                 =>     l_pgp_segment9
18194        ,p_pgp_segment10                =>     l_pgp_segment10
18195        ,p_pgp_segment11                =>     l_pgp_segment11
18196        ,p_pgp_segment12                =>     l_pgp_segment12
18197        ,p_pgp_segment13                =>     l_pgp_segment13
18198        ,p_pgp_segment14                =>     l_pgp_segment14
18199        ,p_pgp_segment15                =>     l_pgp_segment15
18200        ,p_pgp_segment16                =>     l_pgp_segment16
18201        ,p_pgp_segment17                =>     l_pgp_segment17
18202        ,p_pgp_segment18                =>     l_pgp_segment18
18203        ,p_pgp_segment19                =>     l_pgp_segment19
18204        ,p_pgp_segment20                =>     l_pgp_segment20
18205        ,p_pgp_segment21                =>     l_pgp_segment21
18206        ,p_pgp_segment22                =>     l_pgp_segment22
18207        ,p_pgp_segment23                =>     l_pgp_segment23
18208        ,p_pgp_segment24                =>     l_pgp_segment24
18209        ,p_pgp_segment25                =>     l_pgp_segment25
18210        ,p_pgp_segment26                =>     l_pgp_segment26
18211        ,p_pgp_segment27                =>     l_pgp_segment27
18212        ,p_pgp_segment28                =>     l_pgp_segment28
18213        ,p_pgp_segment29                =>     l_pgp_segment29
18214        ,p_pgp_segment30                =>     l_pgp_segment30
18215        ,p_contract_id                  =>     p_contract_id
18216        ,p_establishment_id             =>     p_establishment_id
18217        ,p_collective_agreement_id      =>     p_collective_agreement_id
18218        ,p_cagr_id_flex_num             =>     p_cagr_id_flex_num
18219        ,p_cag_segment1                 =>     l_cag_segment1
18220        ,p_cag_segment2                 =>     l_cag_segment2
18221        ,p_cag_segment3                 =>     l_cag_segment3
18222        ,p_cag_segment4                 =>     l_cag_segment4
18223        ,p_cag_segment5                 =>     l_cag_segment5
18224        ,p_cag_segment6                 =>     l_cag_segment6
18225        ,p_cag_segment7                 =>     l_cag_segment7
18226        ,p_cag_segment8                 =>     l_cag_segment8
18227        ,p_cag_segment9                 =>     l_cag_segment9
18228        ,p_cag_segment10                =>     l_cag_segment10
18229        ,p_cag_segment11                =>     l_cag_segment11
18230        ,p_cag_segment12                =>     l_cag_segment12
18231        ,p_cag_segment13                =>     l_cag_segment13
18232        ,p_cag_segment14                =>     l_cag_segment14
18233        ,p_cag_segment15                =>     l_cag_segment15
18234        ,p_cag_segment16                =>     l_cag_segment16
18235        ,p_cag_segment17                =>     l_cag_segment17
18236        ,p_cag_segment18                =>     l_cag_segment18
18237        ,p_cag_segment19                =>     l_cag_segment19
18238        ,p_cag_segment20                =>     l_cag_segment20
18239        ,p_notice_period		       =>     p_notice_period
18240        ,p_notice_period_uom	       =>     p_notice_period_uom
18241        ,p_employee_category	       =>     p_employee_category
18242        ,p_work_at_home		       =>     p_work_at_home
18243        ,p_job_post_source_name	       =>     p_job_post_source_name
18244        ,p_posting_content_id           =>     p_posting_content_id
18245        ,p_applicant_rank               =>     p_applicant_rank
18246 
18247 -- Bug 944911
18248 -- Amended p_group_name to p_concat_segments
18249        ,p_concat_segments              =>     l_old_group_name
18250        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
18251        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
18252  );
18253   exception
18254      when hr_api.cannot_find_prog_unit then
18255        hr_api.cannot_find_prog_unit_error
18256          (p_module_name       => 'UPDATE_APL_ASG',
18257           p_hook_type         => 'BP'
18258          );
18259   end;
18260   --
18261   --
18262  if g_debug then
18263   hr_utility.set_location(l_proc, 80);
18264  end if;
18265   --
18266   --added validation for bug 1867720
18267   --
18268   if p_assignment_status_type_id <> hr_api.g_number then
18269     open csr_old_asg_status;
18270     fetch csr_old_asg_status into l_old_asg_status;
18271     close csr_old_asg_status;
18272     --
18273     open csr_new_asg_status;
18274     fetch csr_new_asg_status into l_new_asg_status;
18275       if csr_new_asg_status%notfound
18276         OR (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status)
18277       then
18278        fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
18279        fnd_message.set_token('SYSTYPE',l_old_asg_status);
18280        fnd_message.raise_error;
18281       end if;
18282     close csr_new_asg_status;
18283   end if;
18284   --
18285   --
18286   -- insert the profile options and effective date for the flexfield
18287   -- validation to work
18288   --
18289   if (p_organization_id=hr_api.g_number) then
18290     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
18291   else
18292     l_organization_id:=p_organization_id;
18293   end if;
18294   --
18295   if (p_location_id=hr_api.g_number) then
18296     l_location_id:=per_asg_shd.g_old_rec.location_id;
18297   else
18298     l_location_id:=p_location_id;
18299   end if;
18300   --
18301   hr_kflex_utility.set_profiles
18302   (p_business_group_id => l_business_group_id
18303   ,p_assignment_id     => p_assignment_id
18304   ,p_organization_id   => l_organization_id
18305   ,p_location_id       => l_location_id);
18306   --
18307   hr_kflex_utility.set_session_date
18308   (p_effective_date => l_effective_date
18309   ,p_session_id     => l_session_id);
18310   --
18311   -- Maintain the people group key flexfields.
18312   --
18313   open csr_grp_idsel;
18314   fetch csr_grp_idsel
18315   into l_flex_num;
18316      if csr_grp_idsel%NOTFOUND then
18317        close csr_grp_idsel;
18318           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
18319           hr_utility.set_message_token('PROCEDURE', l_proc);
18320           hr_utility.set_message_token('STEP','10');
18321           hr_utility.raise_error;
18322      end if;
18323   close csr_grp_idsel;
18324   --
18325   if l_pgp_null_ind = 0
18326   then
18327     hr_kflex_utility.upd_or_sel_keyflex_comb
18328       (p_appl_short_name        => 'PAY'
18329       ,p_flex_code              => 'GRP'
18330       ,p_flex_num               => l_flex_num
18331       ,p_segment1               => l_pgp_segment1
18332       ,p_segment2               => l_pgp_segment2
18333       ,p_segment3               => l_pgp_segment3
18334       ,p_segment4               => l_pgp_segment4
18335       ,p_segment5               => l_pgp_segment5
18336       ,p_segment6               => l_pgp_segment6
18337       ,p_segment7               => l_pgp_segment7
18338       ,p_segment8               => l_pgp_segment8
18339       ,p_segment9               => l_pgp_segment9
18340       ,p_segment10              => l_pgp_segment10
18341       ,p_segment11              => l_pgp_segment11
18342       ,p_segment12              => l_pgp_segment12
18343       ,p_segment13              => l_pgp_segment13
18344       ,p_segment14              => l_pgp_segment14
18345       ,p_segment15              => l_pgp_segment15
18346       ,p_segment16              => l_pgp_segment16
18347       ,p_segment17              => l_pgp_segment17
18348       ,p_segment18              => l_pgp_segment18
18349       ,p_segment19              => l_pgp_segment19
18350       ,p_segment20              => l_pgp_segment20
18351       ,p_segment21              => l_pgp_segment21
18352       ,p_segment22              => l_pgp_segment22
18353       ,p_segment23              => l_pgp_segment23
18354       ,p_segment24              => l_pgp_segment24
18355       ,p_segment25              => l_pgp_segment25
18356       ,p_segment26              => l_pgp_segment26
18357       ,p_segment27              => l_pgp_segment27
18358       ,p_segment28              => l_pgp_segment28
18359       ,p_segment29              => l_pgp_segment29
18360       ,p_segment30              => l_pgp_segment30
18361       ,p_concat_segments_in     => l_old_group_name
18362       ,p_ccid                   => l_people_group_id
18363       ,p_concat_segments_out    => l_group_name
18364       );
18365   end if;
18366   --
18367   -- update the combinations column
18368   --
18369   update_pgp_concat_segs
18370     (p_people_group_id        => l_people_group_id
18371     ,p_group_name             => l_group_name
18372   );
18373   --
18374   -- Update or select the soft_coding_keyflex_id
18375   --
18376   if l_soft_coding_keyflex_id is null
18377   then
18378      if   l_scl_segment1 <> hr_api.g_varchar2
18379        or l_scl_segment2 <> hr_api.g_varchar2
18380        or l_scl_segment3 <> hr_api.g_varchar2
18381        or l_scl_segment4 <> hr_api.g_varchar2
18382        or l_scl_segment5 <> hr_api.g_varchar2
18383        or l_scl_segment6 <> hr_api.g_varchar2
18384        or l_scl_segment7 <> hr_api.g_varchar2
18385        or l_scl_segment8 <> hr_api.g_varchar2
18386        or l_scl_segment9 <> hr_api.g_varchar2
18387        or l_scl_segment10 <> hr_api.g_varchar2
18388        or l_scl_segment11 <> hr_api.g_varchar2
18389        or l_scl_segment12 <> hr_api.g_varchar2
18390        or l_scl_segment13 <> hr_api.g_varchar2
18391        or l_scl_segment14 <> hr_api.g_varchar2
18392        or l_scl_segment15 <> hr_api.g_varchar2
18393        or l_scl_segment16 <> hr_api.g_varchar2
18394        or l_scl_segment17 <> hr_api.g_varchar2
18395        or l_scl_segment18 <> hr_api.g_varchar2
18396        or l_scl_segment19 <> hr_api.g_varchar2
18397        or l_scl_segment20 <> hr_api.g_varchar2
18398        or l_scl_segment21 <> hr_api.g_varchar2
18399        or l_scl_segment22 <> hr_api.g_varchar2
18400        or l_scl_segment23 <> hr_api.g_varchar2
18401        or l_scl_segment24 <> hr_api.g_varchar2
18402        or l_scl_segment25 <> hr_api.g_varchar2
18403        or l_scl_segment26 <> hr_api.g_varchar2
18404        or l_scl_segment27 <> hr_api.g_varchar2
18405        or l_scl_segment28 <> hr_api.g_varchar2
18406        or l_scl_segment29 <> hr_api.g_varchar2
18407        or l_scl_segment30 <> hr_api.g_varchar2
18408        --
18409        -- Bug 944911
18410        -- Added this additional check
18411        or p_scl_concat_segments <> hr_api.g_varchar2
18412      then
18413        -- gets flex num id from pay_legislation_rules and
18414        -- per_business_groups_perf
18415        --
18416        open csr_scl_idsel;
18417        fetch csr_scl_idsel into l_flex_num;
18418        --
18419        if csr_scl_idsel%NOTFOUND
18420        then
18421           close csr_scl_idsel;
18422           if   l_scl_segment1 is not null
18423             or l_scl_segment2 is not null
18424             or l_scl_segment3 is not null
18425             or l_scl_segment4 is not null
18426             or l_scl_segment5 is not null
18427             or l_scl_segment6 is not null
18428             or l_scl_segment7 is not null
18429             or l_scl_segment8 is not null
18430             or l_scl_segment9 is not null
18431             or l_scl_segment10 is not null
18432             or l_scl_segment11 is not null
18433             or l_scl_segment12 is not null
18434             or l_scl_segment13 is not null
18435             or l_scl_segment14 is not null
18436             or l_scl_segment15 is not null
18437             or l_scl_segment16 is not null
18438             or l_scl_segment17 is not null
18439             or l_scl_segment18 is not null
18440             or l_scl_segment19 is not null
18441             or l_scl_segment20 is not null
18442             or l_scl_segment21 is not null
18443             or l_scl_segment22 is not null
18444             or l_scl_segment23 is not null
18445             or l_scl_segment24 is not null
18446             or l_scl_segment25 is not null
18447             or l_scl_segment26 is not null
18448             or l_scl_segment27 is not null
18449             or l_scl_segment28 is not null
18450             or l_scl_segment29 is not null
18451             or l_scl_segment30 is not null
18452             --
18453             -- Bug 944911
18454             -- Added this additional check
18455             or p_scl_concat_segments is not null
18456           then
18457              hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
18458              hr_utility.set_message_token('PROCEDURE', l_proc);
18459              hr_utility.set_message_token('STEP','5');
18460              hr_utility.raise_error;
18461           end if;  -- p_scl_segment1 is not null
18462        else -- csr_scl_idsel is found
18463           close csr_scl_idsel;
18464           --
18465           -- Process Logic
18466           --
18467           --
18468           -- Update or select the soft_coding_keyflex_id
18469           --
18470           hr_kflex_utility.upd_or_sel_keyflex_comb
18471             (p_appl_short_name        => 'PER'
18472             ,p_flex_code              => 'SCL'
18473             ,p_flex_num               => l_flex_num
18474             ,p_segment1               => l_scl_segment1
18475             ,p_segment2               => l_scl_segment2
18476             ,p_segment3               => l_scl_segment3
18477             ,p_segment4               => l_scl_segment4
18478             ,p_segment5               => l_scl_segment5
18479             ,p_segment6               => l_scl_segment6
18480             ,p_segment7               => l_scl_segment7
18481             ,p_segment8               => l_scl_segment8
18482             ,p_segment9               => l_scl_segment9
18483             ,p_segment10              => l_scl_segment10
18484             ,p_segment11              => l_scl_segment11
18485             ,p_segment12              => l_scl_segment12
18486             ,p_segment13              => l_scl_segment13
18487             ,p_segment14              => l_scl_segment14
18488             ,p_segment15              => l_scl_segment15
18489             ,p_segment16              => l_scl_segment16
18490             ,p_segment17              => l_scl_segment17
18491             ,p_segment18              => l_scl_segment18
18492             ,p_segment19              => l_scl_segment19
18493             ,p_segment20              => l_scl_segment20
18494             ,p_segment21              => l_scl_segment21
18495             ,p_segment22              => l_scl_segment22
18496             ,p_segment23              => l_scl_segment23
18497             ,p_segment24              => l_scl_segment24
18498             ,p_segment25              => l_scl_segment25
18499             ,p_segment26              => l_scl_segment26
18500             ,p_segment27              => l_scl_segment27
18501             ,p_segment28              => l_scl_segment28
18502             ,p_segment29              => l_scl_segment29
18503             ,p_segment30              => l_scl_segment30
18504             ,p_concat_segments_in     => l_old_scl_conc_segments
18505             ,p_ccid                   => l_soft_coding_keyflex_id
18506             ,p_concat_segments_out    => l_scl_concatenated_segments
18507             );
18508             --
18509             -- update the combinations column
18510             --
18511             update_scl_concat_segs
18512             (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
18513             ,p_concatenated_segments   => l_scl_concatenated_segments
18514             );
18515          --
18516         end if;  -- csr_scl_idsel%NOTFOUND
18517       --
18518      end if; -- l_scl_segment1 <> hr_api.g_varchar2
18519    --
18520   end if; -- l_soft_coding_key_flex_id is null
18521   --
18522   -- need to call the lck procedure early, to fetch the old value of
18523   -- cagr_id_flex_num
18524   -- before passing it into the hr_cgd_upd.upd_or_sel function.
18525   -- This is because the user may be updating a grade definition,
18526   -- but not changing
18527   -- or specifying the cagr_id_flex_num (ie the grade structure).
18528   -- Also, need to fetch the old cagr_grade_def_id, as the
18529   -- user may be updating some
18530   -- segments, and not changing others. Passing cagr_grade_id
18531   -- into the hr_cgd_upd.upd_or_sel
18532   -- function allows that function to derive the old values.
18533   --
18534   l_cagr_id_flex_num  := p_cagr_id_flex_num;
18535   --
18536   if (p_cagr_id_flex_num  = hr_api.g_number) THEN
18537     per_asg_shd.lck
18538       (p_effective_date          => l_effective_date,
18539        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
18540        p_datetrack_mode          => p_datetrack_update_mode,
18541        p_assignment_id           => p_assignment_id,
18542        p_object_version_number   => p_object_version_number,
18543        p_validation_start_date   => l_unused_start_date,
18544        p_validation_end_date     => l_unused_end_date
18545        );
18546     l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
18547     --l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
18548   end if;
18549   --
18550   if l_cag_null_ind = 0
18551   then
18552      l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
18553      --
18554      hr_cgd_upd.upd_or_sel
18555      (p_segment1               => l_cag_segment1
18556      ,p_segment2               => l_cag_segment2
18557      ,p_segment3               => l_cag_segment3
18558      ,p_segment4               => l_cag_segment4
18559      ,p_segment5               => l_cag_segment5
18560      ,p_segment6               => l_cag_segment6
18561      ,p_segment7               => l_cag_segment7
18562      ,p_segment8               => l_cag_segment8
18563      ,p_segment9               => l_cag_segment9
18564      ,p_segment10              => l_cag_segment10
18565      ,p_segment11              => l_cag_segment11
18566      ,p_segment12              => l_cag_segment12
18567      ,p_segment13              => l_cag_segment13
18568      ,p_segment14              => l_cag_segment14
18569      ,p_segment15              => l_cag_segment15
18570      ,p_segment16              => l_cag_segment16
18571      ,p_segment17              => l_cag_segment17
18572      ,p_segment18              => l_cag_segment18
18573      ,p_segment19              => l_cag_segment19
18574      ,p_segment20              => l_cag_segment20
18575      ,p_id_flex_num            => l_cagr_id_flex_num
18576      ,p_business_group_id      => per_asg_shd.g_old_rec.business_group_id
18577      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
18578      ,p_concatenated_segments  => l_cagr_concatenated_segments
18579      );
18580      --
18581  if g_debug then
18582      hr_utility.set_location(l_proc, 90);
18583  end if;
18584      --
18585   end if; --  l_cagr_grade_def_id is null
18586   --
18587  if g_debug then
18588   hr_utility.set_location(l_proc, 95);
18589  end if;
18590   --
18591   -- Update assignment.
18592   --
18593   per_asg_upd.upd
18594     (p_assignment_id                => p_assignment_id
18595     ,p_effective_start_date         => l_effective_start_date
18596     ,p_effective_end_date           => l_effective_end_date
18597     ,p_business_group_id            => l_business_group_id
18598     ,p_grade_id                     => p_grade_id
18599     ,p_job_id                       => p_job_id
18600     ,p_assignment_status_type_id    => p_assignment_status_type_id
18601     ,p_payroll_id                   => p_payroll_id
18602     ,p_location_id                  => p_location_id
18603     ,p_organization_id              => p_organization_id
18604     ,p_people_group_id              => l_people_group_id
18605     ,p_position_id                  => p_position_id
18606     ,p_application_id               => p_application_id
18607     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
18608     ,p_recruiter_id                 => p_recruiter_id
18609     ,p_recruitment_activity_id      => p_recruitment_activity_id
18610     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
18611     ,p_vacancy_id                   => p_vacancy_id
18612     ,p_pay_basis_id                 => p_pay_basis_id
18613     ,p_person_referred_by_id        => p_person_referred_by_id
18614     ,p_supervisor_id                => p_supervisor_id
18615     ,p_source_organization_id       => p_source_organization_id
18616     ,p_change_reason                => p_change_reason
18617     ,p_internal_address_line        => p_internal_address_line
18618     ,p_default_code_comb_id         => p_default_code_comb_id
18619     ,p_employment_category          => p_employment_category
18620     ,p_frequency                    => p_frequency
18621     ,p_manager_flag                 => p_manager_flag
18622     ,p_normal_hours                 => p_normal_hours
18623     ,p_perf_review_period           => p_perf_review_period
18624     ,p_perf_review_period_frequency => p_perf_review_period_frequency
18625     ,p_probation_period             => p_probation_period
18626     ,p_probation_unit               => p_probation_unit
18627     ,p_sal_review_period            => p_sal_review_period
18628     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
18629     ,p_set_of_books_id              => p_set_of_books_id
18630     ,p_source_type                  => p_source_type
18631     ,p_time_normal_finish           => p_time_normal_finish
18632     ,p_time_normal_start            => p_time_normal_start
18633     ,p_bargaining_unit_code         => p_bargaining_unit_code
18634     ,p_comments                     => p_comments
18635     ,p_date_probation_end           => l_date_probation_end
18636     ,p_title                        => p_title
18637     ,p_ass_attribute_category       => p_ass_attribute_category
18638     ,p_ass_attribute1               => p_ass_attribute1
18639     ,p_ass_attribute2               => p_ass_attribute2
18640     ,p_ass_attribute3               => p_ass_attribute3
18641     ,p_ass_attribute4               => p_ass_attribute4
18642     ,p_ass_attribute5               => p_ass_attribute5
18643     ,p_ass_attribute6               => p_ass_attribute6
18644     ,p_ass_attribute7               => p_ass_attribute7
18645     ,p_ass_attribute8               => p_ass_attribute8
18646     ,p_ass_attribute9               => p_ass_attribute9
18647     ,p_ass_attribute10              => p_ass_attribute10
18648     ,p_ass_attribute11              => p_ass_attribute11
18649     ,p_ass_attribute12              => p_ass_attribute12
18650     ,p_ass_attribute13              => p_ass_attribute13
18651     ,p_ass_attribute14              => p_ass_attribute14
18652     ,p_ass_attribute15              => p_ass_attribute15
18653     ,p_ass_attribute16              => p_ass_attribute16
18654     ,p_ass_attribute17              => p_ass_attribute17
18655     ,p_ass_attribute18              => p_ass_attribute18
18656     ,p_ass_attribute19              => p_ass_attribute19
18657     ,p_ass_attribute20              => p_ass_attribute20
18658     ,p_ass_attribute21              => p_ass_attribute21
18659     ,p_ass_attribute22              => p_ass_attribute22
18660     ,p_ass_attribute23              => p_ass_attribute23
18661     ,p_ass_attribute24              => p_ass_attribute24
18662     ,p_ass_attribute25              => p_ass_attribute25
18663     ,p_ass_attribute26              => p_ass_attribute26
18664     ,p_ass_attribute27              => p_ass_attribute27
18665     ,p_ass_attribute28              => p_ass_attribute28
18666     ,p_ass_attribute29              => p_ass_attribute29
18667     ,p_ass_attribute30              => p_ass_attribute30
18668     ,p_contract_id                  => p_contract_id
18669     ,p_establishment_id             => p_establishment_id
18670     ,p_collective_agreement_id      => p_collective_agreement_id
18671     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
18672     ,p_cagr_id_flex_num             => l_cagr_id_flex_num
18673     ,p_notice_period		    => p_notice_period
18674     ,p_notice_period_uom	    => p_notice_period_uom
18675     ,p_employee_category	    => p_employee_category
18676     ,p_work_at_home		    => p_work_at_home
18677     ,p_job_post_source_name	    => p_job_post_source_name
18678     ,p_payroll_id_updated           => l_dummy_payroll
18679     ,p_other_manager_warning        => l_dummy_manager1
18680     ,p_no_managers_warning          => l_dummy_manager2
18681     ,p_org_now_no_manager_warning   => l_dummy_manager3
18682     ,p_comment_id                   => l_comment_id
18683     ,p_validation_start_date        => l_validation_start_date
18684     ,p_validation_end_date          => l_validation_end_date
18685     ,p_object_version_number        => l_object_version_number
18686     ,p_effective_date               => l_effective_date
18687     ,p_datetrack_mode               => p_datetrack_update_mode
18688     ,p_validate                     => FALSE
18689     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
18690     ,p_applicant_rank               => p_applicant_rank
18691     ,p_posting_content_id           => p_posting_content_id
18692     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
18693     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
18694     );
18695   --
18696   -- ***** Start new code for bug 2276928 **************
18697   -- modified the below if condition for bug 7657734
18698   IF (per_asg_shd.g_old_rec.assignment_status_type_id<>p_assignment_status_type_id AND
18699       p_assignment_status_type_id<>hr_api.g_number)
18700   -- modified for bug 9496344
18701     OR ( ( p_change_reason is null OR (p_change_reason <> hr_api.g_varchar2)) AND
18702          ( nvl(per_asg_shd.g_old_rec.change_reason, hr_api.g_varchar2) <>
18703            nvl(p_change_reason, hr_api.g_varchar2))) THEN
18704   -- end of 9496344
18705  --12427559
18706 
18707 if p_assignment_status_type_id = hr_api.g_number or p_assignment_status_type_id is null then
18708 l_asg_status_type_id := per_asg_shd.g_old_rec.assignment_status_type_id;
18709 
18710 else
18711 
18712 l_asg_status_type_id := p_assignment_status_type_id;
18713 end if;
18714 
18715     IRC_ASG_STATUS_API.create_irc_asg_status
18716     (p_assignment_id                => p_assignment_id
18717      , p_assignment_status_type_id  => l_asg_status_type_id --124275
18718      , p_status_change_date         => p_effective_date
18719      , p_status_change_reason       => p_change_reason   -- Bug 2676934
18720      , p_assignment_status_id       => l_assignment_status_id
18721      , p_object_version_number      => l_asg_status_ovn);
18722   end if;
18723   -- ***** End new code for bug 2276928 **************
18724   --
18725   -- Fix for bug 3680947 starts here.
18726   -- When the vacancy is changes, move the letter request line to a letter request
18727   -- with that vacancy.
18728   -- When the assignemnt status is changed, create new letter request lines.
18729   --
18730   IF (per_asg_shd.g_old_rec.assignment_status_type_id<>p_assignment_status_type_id
18731     AND p_assignment_status_type_id<>hr_api.g_number
18732    )
18733    OR
18734    ( nvl(per_asg_shd.g_old_rec.vacancy_id,-1) <> nvl(p_vacancy_id,-1) AND
18735      nvl(p_vacancy_id,-1) <> hr_api.g_number
18736    ) THEN
18737   --
18738   IF ( nvl(per_asg_shd.g_old_rec.vacancy_id,-1) <> nvl(p_vacancy_id,-1) AND
18739      nvl(p_vacancy_id,-1) <> hr_api.g_number ) THEN
18740     --
18741     delete from per_letter_request_lines plrl
18742     where plrl.assignment_id = p_assignment_id
18743     and   plrl.assignment_status_type_id = p_assignment_status_type_id
18744     and   exists
18745          (select null
18746           from per_letter_requests plr
18747           where plr.letter_request_id = plrl.letter_request_id
18748           and   plr.request_status = 'PENDING'
18749           and   plr.auto_or_manual = 'AUTO');
18750     --
18751  END IF;
18752   --
18753   per_app_asg_pkg.cleanup_letters
18754         ( p_assignment_id => p_assignment_id);
18755   --
18756   --
18757     delete from per_letter_requests plr
18758     where  plr.business_group_id     = l_business_group_id
18759     and    plr.request_status        = 'PENDING'
18760     and    plr.auto_or_manual        = 'AUTO'
18761     and not exists
18762      ( select 1
18763 	   from   per_letter_request_lines plrl
18764 	   where  plrl.letter_request_id = plr.letter_request_id
18765       ) ;
18766    --
18767    per_applicant_pkg.check_for_letter_requests
18768     (p_business_group_id            => l_business_group_id
18769     ,p_per_system_status            => null
18770     ,p_assignment_status_type_id    => p_assignment_status_type_id
18771     ,p_person_id                    => per_asg_shd.g_old_rec.person_id
18772     ,p_assignment_id                => p_assignment_id
18773     ,p_effective_start_date         => l_effective_start_date
18774     ,p_validation_start_date        => l_effective_start_date
18775     ,p_vacancy_id 		            => p_vacancy_id
18776     );
18777    --
18778  END IF;
18779   --
18780   -- Fix for bug 3680947 ends here.
18781   --
18782   -- insert in to security lists if neccesary
18783   --
18784   --
18785   open get_sec_date_range;
18786   fetch get_sec_date_range into l_sec_effective_start_date,
18787                                 l_sec_effective_end_date;
18788   close get_sec_date_range;
18789   --
18790   if l_effective_date between l_sec_effective_start_date
18791                           and l_sec_effective_end_date
18792   then
18793      if(per_asg_shd.g_old_rec.organization_id = l_business_group_id
18794        and p_organization_id <> l_business_group_id)
18795      then
18796         hr_security_internal.clear_from_person_list
18797                                              (per_asg_shd.g_old_rec.person_id);
18798      end if;
18799   --fix for bug 5938120 starts here
18800      open csr_get_assign(per_asg_shd.g_old_rec.person_id);
18801      LOOP
18802      fetch csr_get_assign into l_assignment_id;
18803      exit when csr_get_assign%NOTFOUND;
18804      hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
18805      end loop;
18806      --fix for bug 5938120 ends here
18807   end if;
18808   --
18809   -- Start of API User Hook for the after hook of suspend_emp_asg.
18810   --
18811   begin
18812      hr_assignment_bk5.update_apl_asg_a
18813        (p_effective_date               =>     l_effective_date
18814        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
18815        ,p_assignment_id                =>     p_assignment_id
18816        ,p_object_version_number        =>     l_object_version_number
18817        ,p_grade_id                     =>     p_grade_id
18818        ,p_job_id                       =>     p_job_id
18819        ,p_payroll_id                   =>     p_payroll_id
18820        ,p_location_id                  =>     p_location_id
18821        ,p_organization_id              =>     p_organization_id
18822        ,p_position_id                  =>     p_position_id
18823        ,p_application_id               =>     p_application_id
18824        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
18825        ,p_recruiter_id                 =>     p_recruiter_id
18826        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
18827        ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
18828        ,p_vacancy_id                   =>     p_vacancy_id
18829        ,p_pay_basis_id                 =>     p_pay_basis_id
18830        ,p_person_referred_by_id        =>     p_person_referred_by_id
18831        ,p_supervisor_id                =>     p_supervisor_id
18832        ,p_source_organization_id       =>     p_source_organization_id
18833        ,p_change_reason                =>     p_change_reason
18834        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
18835        ,p_internal_address_line        =>     p_internal_address_line
18836        ,p_default_code_comb_id         =>     p_default_code_comb_id
18837        ,p_employment_category          =>     p_employment_category
18838        ,p_frequency                    =>     p_frequency
18839        ,p_manager_flag                 =>     p_manager_flag
18840        ,p_normal_hours                 =>     p_normal_hours
18841        ,p_perf_review_period           =>     p_perf_review_period
18842        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
18843        ,p_probation_period             =>     p_probation_period
18844        ,p_probation_unit               =>     p_probation_unit
18845        ,p_sal_review_period            =>     p_sal_review_period
18846        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
18847        ,p_set_of_books_id              =>     p_set_of_books_id
18848        ,p_source_type                  =>     p_source_type
18849        ,p_time_normal_finish           =>     p_time_normal_finish
18850        ,p_time_normal_start            =>     p_time_normal_start
18851        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
18852        ,p_comments                     =>     p_comments
18853        ,p_date_probation_end           =>     l_date_probation_end
18854        ,p_title                        =>     p_title
18855        ,p_ass_attribute_category       =>     p_ass_attribute_category
18856        ,p_ass_attribute1               =>     p_ass_attribute1
18857        ,p_ass_attribute2               =>     p_ass_attribute2
18858        ,p_ass_attribute3               =>     p_ass_attribute3
18859        ,p_ass_attribute4               =>     p_ass_attribute4
18860        ,p_ass_attribute5               =>     p_ass_attribute5
18861        ,p_ass_attribute6               =>     p_ass_attribute6
18862        ,p_ass_attribute7               =>     p_ass_attribute7
18863        ,p_ass_attribute8               =>     p_ass_attribute8
18864        ,p_ass_attribute9               =>     p_ass_attribute9
18865        ,p_ass_attribute10              =>     p_ass_attribute10
18866        ,p_ass_attribute11              =>     p_ass_attribute11
18867        ,p_ass_attribute12              =>     p_ass_attribute12
18868        ,p_ass_attribute13              =>     p_ass_attribute13
18869        ,p_ass_attribute14              =>     p_ass_attribute14
18870        ,p_ass_attribute15              =>     p_ass_attribute15
18871        ,p_ass_attribute16              =>     p_ass_attribute16
18872        ,p_ass_attribute17              =>     p_ass_attribute17
18873        ,p_ass_attribute18              =>     p_ass_attribute18
18874        ,p_ass_attribute19              =>     p_ass_attribute19
18875        ,p_ass_attribute20              =>     p_ass_attribute20
18876        ,p_ass_attribute21              =>     p_ass_attribute21
18877        ,p_ass_attribute22              =>     p_ass_attribute22
18878        ,p_ass_attribute23              =>     p_ass_attribute23
18879        ,p_ass_attribute24              =>     p_ass_attribute24
18880        ,p_ass_attribute25              =>     p_ass_attribute25
18881        ,p_ass_attribute26              =>     p_ass_attribute26
18882        ,p_ass_attribute27              =>     p_ass_attribute27
18883        ,p_ass_attribute28              =>     p_ass_attribute28
18884        ,p_ass_attribute29              =>     p_ass_attribute29
18885        ,p_ass_attribute30              =>     p_ass_attribute30
18886        ,p_scl_segment1                 =>     l_scl_segment1
18887        ,p_scl_segment2                 =>     l_scl_segment2
18888        ,p_scl_segment3                 =>     l_scl_segment3
18889        ,p_scl_segment4                 =>     l_scl_segment4
18890        ,p_scl_segment5                 =>     l_scl_segment5
18891        ,p_scl_segment6                 =>     l_scl_segment6
18892        ,p_scl_segment7                 =>     l_scl_segment7
18893        ,p_scl_segment8                 =>     l_scl_segment8
18894        ,p_scl_segment9                 =>     l_scl_segment9
18895        ,p_scl_segment10                =>     l_scl_segment10
18896        ,p_scl_segment11                =>     l_scl_segment11
18897        ,p_scl_segment12                =>     l_scl_segment12
18898        ,p_scl_segment13                =>     l_scl_segment13
18899        ,p_scl_segment14                =>     l_scl_segment14
18900        ,p_scl_segment15                =>     l_scl_segment15
18901        ,p_scl_segment16                =>     l_scl_segment16
18902        ,p_scl_segment17                =>     l_scl_segment17
18903        ,p_scl_segment18                =>     l_scl_segment18
18904        ,p_scl_segment19                =>     l_scl_segment19
18905        ,p_scl_segment20                =>     l_scl_segment20
18906        ,p_scl_segment21                =>     l_scl_segment21
18907        ,p_scl_segment22                =>     l_scl_segment22
18908        ,p_scl_segment23                =>     l_scl_segment23
18909        ,p_scl_segment24                =>     l_scl_segment24
18910        ,p_scl_segment25                =>     l_scl_segment25
18911        ,p_scl_segment26                =>     l_scl_segment26
18912        ,p_scl_segment27                =>     l_scl_segment27
18913        ,p_scl_segment28                =>     l_scl_segment28
18914        ,p_scl_segment29                =>     l_scl_segment29
18915        ,p_scl_segment30                =>     l_scl_segment30
18916        --
18917        -- Amended p_scl_concatenated_segments to be p_concatenated_segments
18918        -- Bug 944911
18919        ,p_concatenated_segments        =>     l_scl_concatenated_segments
18920        ,p_pgp_segment1                 =>     l_pgp_segment1
18921        ,p_pgp_segment2                 =>     l_pgp_segment2
18922        ,p_pgp_segment3                 =>     l_pgp_segment3
18923        ,p_pgp_segment4                 =>     l_pgp_segment4
18924        ,p_pgp_segment5                 =>     l_pgp_segment5
18925        ,p_pgp_segment6                 =>     l_pgp_segment6
18926        ,p_pgp_segment7                 =>     l_pgp_segment7
18927        ,p_pgp_segment8                 =>     l_pgp_segment8
18928        ,p_pgp_segment9                 =>     l_pgp_segment9
18929        ,p_pgp_segment10                =>     l_pgp_segment10
18930        ,p_pgp_segment11                =>     l_pgp_segment11
18931        ,p_pgp_segment12                =>     l_pgp_segment12
18932        ,p_pgp_segment13                =>     l_pgp_segment13
18933        ,p_pgp_segment14                =>     l_pgp_segment14
18934        ,p_pgp_segment15                =>     l_pgp_segment15
18935        ,p_pgp_segment16                =>     l_pgp_segment16
18936        ,p_pgp_segment17                =>     l_pgp_segment17
18937        ,p_pgp_segment18                =>     l_pgp_segment18
18938        ,p_pgp_segment19                =>     l_pgp_segment19
18939        ,p_pgp_segment20                =>     l_pgp_segment20
18940        ,p_pgp_segment21                =>     l_pgp_segment21
18941        ,p_pgp_segment22                =>     l_pgp_segment22
18942        ,p_pgp_segment23                =>     l_pgp_segment23
18943        ,p_pgp_segment24                =>     l_pgp_segment24
18944        ,p_pgp_segment25                =>     l_pgp_segment25
18945        ,p_pgp_segment26                =>     l_pgp_segment26
18946        ,p_pgp_segment27                =>     l_pgp_segment27
18947        ,p_pgp_segment28                =>     l_pgp_segment28
18948        ,p_pgp_segment29                =>     l_pgp_segment29
18949        ,p_pgp_segment30                =>     l_pgp_segment30
18950        ,p_contract_id                  =>     p_contract_id
18951        ,p_establishment_id             =>     p_establishment_id
18952        ,p_collective_agreement_id      =>     p_collective_agreement_id
18953        ,p_cagr_id_flex_num             =>     l_cagr_id_flex_num
18954        ,p_cag_segment1                 =>     l_cag_segment1
18955        ,p_cag_segment2                 =>     l_cag_segment2
18956        ,p_cag_segment3                 =>     l_cag_segment3
18957        ,p_cag_segment4                 =>     l_cag_segment4
18958        ,p_cag_segment5                 =>     l_cag_segment5
18959        ,p_cag_segment6                 =>     l_cag_segment6
18960        ,p_cag_segment7                 =>     l_cag_segment7
18961        ,p_cag_segment8                 =>     l_cag_segment8
18962        ,p_cag_segment9                 =>     l_cag_segment9
18963        ,p_cag_segment10                =>     l_cag_segment10
18964        ,p_cag_segment11                =>     l_cag_segment11
18965        ,p_cag_segment12                =>     l_cag_segment12
18966        ,p_cag_segment13                =>     l_cag_segment13
18967        ,p_cag_segment14                =>     l_cag_segment14
18968        ,p_cag_segment15                =>     l_cag_segment15
18969        ,p_cag_segment16                =>     l_cag_segment16
18970        ,p_cag_segment17                =>     l_cag_segment17
18971        ,p_cag_segment18                =>     l_cag_segment18
18972        ,p_cag_segment19                =>     l_cag_segment19
18973        ,p_cag_segment20                =>     l_cag_segment20
18974        ,p_notice_period		       =>     p_notice_period
18975        ,p_notice_period_uom	       =>     p_notice_period_uom
18976        ,p_employee_category	       =>     p_employee_category
18977        ,p_work_at_home		       =>     p_work_at_home
18978        ,p_job_post_source_name	       =>     p_job_post_source_name
18979        ,p_cagr_grade_def_id            =>     l_cagr_grade_def_id
18980        ,p_cagr_concatenated_segments   =>     l_cagr_concatenated_segments
18981        ,p_group_name                   =>     l_group_name
18982        ,p_comment_id                   =>     l_comment_id
18983        ,p_people_group_id              =>     l_people_group_id
18984        ,p_effective_start_date         =>     l_effective_start_date
18985        ,p_effective_end_date           =>     l_effective_end_date
18986        ,p_applicant_rank               =>     p_applicant_rank
18987        ,p_posting_content_id           =>     p_posting_content_id
18988        --
18989        -- Bug 944911
18990        -- Added the 2 additional IN param
18991        -- Bug 944911
18992        -- Amended p_group_name to p_concat_segments
18993        --
18994        ,p_concat_segments              =>     l_old_group_name
18995        --
18996        -- Bug 944911
18997        -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
18998        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
18999        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
19000        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
19001        );
19002   exception
19003      when hr_api.cannot_find_prog_unit then
19004        hr_api.cannot_find_prog_unit_error
19005          (p_module_name       => 'UPDATE_APL_ASG',
19006           p_hook_type         => 'AP'
19007          );
19008   end;
19009   --
19010   -- End of API User Hook for the after hook of suspend_emp_asg.
19011   --
19012   --
19013   -- When in validation only mode raise the Validate_Enabled exception
19014   --
19015   if p_validate then
19016     raise hr_api.validate_enabled;
19017   end if;
19018   --
19019   -- Set all output arguments
19020   --
19021 -- Bug 944911
19022 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
19023   p_object_version_number  := l_object_version_number;
19024   p_comment_id             := l_comment_id;
19025   p_effective_start_date   := l_effective_start_date;
19026   p_effective_end_date     := l_effective_end_date;
19027   p_people_group_id        := l_people_group_id;
19028   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
19029   p_concatenated_segments  := l_scl_concatenated_segments;
19030   p_group_name             := l_group_name;
19031   --
19032   p_cagr_grade_def_id          := l_cagr_grade_def_id;
19033   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
19034   --
19035   -- remove data from the session table
19036   hr_kflex_utility.unset_session_date
19037     (p_session_id     => l_session_id);
19038   --
19039  if g_debug then
19040   hr_utility.set_location(' Leaving:'||l_proc, 6);
19041  end if;
19042 exception
19043   when hr_api.validate_enabled then
19044     --
19045     -- As the Validate_Enabled exception has been raised
19046     -- we must rollback to the savepoint
19047     --
19048     ROLLBACK TO update_apl_asg;
19049     --
19050     -- Only set output warning arguments
19051     -- (Any key or derived arguments must be set to null
19052     -- when validation only mode is being used.)
19053     --
19054     p_object_version_number  := p_object_version_number;
19055     p_comment_id             := null;
19056     p_effective_start_date   := null;
19057     p_effective_end_date     := null;
19058     --
19059     -- bug 2230915 only re-set to null if key flex ids came in as null.
19060     --
19061     if l_scl_null_ind = 0
19062     then
19063        p_soft_coding_keyflex_id  := null;
19064     end if;
19065     --
19066     if l_pgp_null_ind = 0
19067     then
19068        p_people_group_id         := null;
19069     end if;
19070     --
19071     if l_cag_null_ind = 0
19072     then
19073        p_cagr_grade_def_id       := null;
19074     end if;
19075     --
19076     -- Bug 944911
19077     -- Amended scl_concatenated_segments to be concatenated_segments
19078     p_concatenated_segments := l_old_scl_conc_segments;
19079     p_group_name            := l_old_group_name;
19080     p_cagr_concatenated_segments := null;
19081     --
19082     --
19083     when others then
19084        --
19085        -- A validation or unexpected error has occurred
19086        --
19087        -- Added as part of fix to bug 632479
19088        --
19089        p_object_version_number     := lv_object_version_number ;
19090        p_cagr_grade_def_id         := lv_cagr_grade_def_id ;
19091        p_people_group_id           := lv_people_group_id ;
19092        p_soft_coding_keyflex_id    := lv_soft_coding_keyflex_id ;
19093 
19094        p_concatenated_segments      := null;
19095        p_cagr_concatenated_segments := null;
19096        p_group_name                 := null;
19097        p_comment_id                 := null;
19098        p_effective_start_date       := null;
19099        p_effective_end_date         := null;
19100 
19101        ROLLBACK TO update_apl_asg;
19102        raise;
19103        --
19104        -- End of fix.
19105        --
19106 end update_apl_asg;
19107 --
19108 -- ----------------------------------------------------------------------------
19109 -- |--------------------------< update_apl_asg >-----R11-----------------------|
19110 -- ----------------------------------------------------------------------------
19111 --
19112 -- This is an overloaded procedure to include new parms
19113 -- for contracts and collective agreements
19114 --
19115 procedure update_apl_asg
19116   (p_validate                     in     boolean
19117   ,p_effective_date               in     date
19118   ,p_datetrack_update_mode        in     varchar2
19119   ,p_assignment_id                in     number
19120   ,p_object_version_number        in out nocopy number
19121   ,p_grade_id                     in     number
19122   ,p_job_id                       in     number
19123   ,p_location_id                  in     number
19124   ,p_organization_id              in     number
19125   ,p_position_id                  in     number
19126   ,p_application_id               in     number
19127   ,p_recruiter_id                 in     number
19128   ,p_recruitment_activity_id      in     number
19129   ,p_vacancy_id                   in     number
19130   ,p_person_referred_by_id        in     number
19131   ,p_supervisor_id                in     number
19132   ,p_source_organization_id       in     number
19133   ,p_change_reason                in     varchar2
19134   ,p_frequency                    in     varchar2
19135   ,p_manager_flag                 in     varchar2
19136   ,p_normal_hours                 in     number
19137   ,p_probation_period             in     number
19138   ,p_probation_unit               in     varchar2
19139   ,p_source_type                  in     varchar2
19140   ,p_time_normal_finish           in     varchar2
19141   ,p_time_normal_start            in     varchar2
19142   ,p_comments                     in     varchar2
19143   ,p_date_probation_end           in     date
19144   ,p_title                        in     varchar2
19145   ,p_ass_attribute_category       in     varchar2
19146   ,p_ass_attribute1               in     varchar2
19147   ,p_ass_attribute2               in     varchar2
19148   ,p_ass_attribute3               in     varchar2
19149   ,p_ass_attribute4               in     varchar2
19150   ,p_ass_attribute5               in     varchar2
19151   ,p_ass_attribute6               in     varchar2
19152   ,p_ass_attribute7               in     varchar2
19153   ,p_ass_attribute8               in     varchar2
19154   ,p_ass_attribute9               in     varchar2
19155   ,p_ass_attribute10              in     varchar2
19156   ,p_ass_attribute11              in     varchar2
19157   ,p_ass_attribute12              in     varchar2
19158   ,p_ass_attribute13              in     varchar2
19159   ,p_ass_attribute14              in     varchar2
19160   ,p_ass_attribute15              in     varchar2
19161   ,p_ass_attribute16              in     varchar2
19162   ,p_ass_attribute17              in     varchar2
19163   ,p_ass_attribute18              in     varchar2
19164   ,p_ass_attribute19              in     varchar2
19165   ,p_ass_attribute20              in     varchar2
19166   ,p_ass_attribute21              in     varchar2
19167   ,p_ass_attribute22              in     varchar2
19168   ,p_ass_attribute23              in     varchar2
19169   ,p_ass_attribute24              in     varchar2
19170   ,p_ass_attribute25              in     varchar2
19171   ,p_ass_attribute26              in     varchar2
19172   ,p_ass_attribute27              in     varchar2
19173   ,p_ass_attribute28              in     varchar2
19174   ,p_ass_attribute29              in     varchar2
19175   ,p_ass_attribute30              in     varchar2
19176   ,p_segment1                     in     varchar2
19177   ,p_segment2                     in     varchar2
19178   ,p_segment3                     in     varchar2
19179   ,p_segment4                     in     varchar2
19180   ,p_segment5                     in     varchar2
19181   ,p_segment6                     in     varchar2
19182   ,p_segment7                     in     varchar2
19183   ,p_segment8                     in     varchar2
19184   ,p_segment9                     in     varchar2
19185   ,p_segment10                    in     varchar2
19186   ,p_segment11                    in     varchar2
19187   ,p_segment12                    in     varchar2
19188   ,p_segment13                    in     varchar2
19189   ,p_segment14                    in     varchar2
19190   ,p_segment15                    in     varchar2
19191   ,p_segment16                    in     varchar2
19192   ,p_segment17                    in     varchar2
19193   ,p_segment18                    in     varchar2
19194   ,p_segment19                    in     varchar2
19195   ,p_segment20                    in     varchar2
19196   ,p_segment21                    in     varchar2
19197   ,p_segment22                    in     varchar2
19198   ,p_segment23                    in     varchar2
19199   ,p_segment24                    in     varchar2
19200   ,p_segment25                    in     varchar2
19201   ,p_segment26                    in     varchar2
19202   ,p_segment27                    in     varchar2
19203   ,p_segment28                    in     varchar2
19204   ,p_segment29                    in     varchar2
19205   ,p_segment30                    in     varchar2
19206 -- Bug 944911
19207 -- Amended p_concat_segments to be an in instead of in out
19208 -- Added p_concatenated_segments to be out
19209 -- Reverting back changes as this for compatibilty with v11
19210   --,p_concat_segments              in     varchar2
19211   ,p_supervisor_assignment_id     in     number
19212   ,p_concatenated_segments           in out nocopy varchar2
19213   ,p_comment_id                      out nocopy number
19214   ,p_people_group_id                 out nocopy number  -- in out?
19215   ,p_effective_start_date            out nocopy date
19216   ,p_effective_end_date              out nocopy date
19217  ) is
19218   --
19219   -- Declare cursors and local variables
19220   --
19221   -- Out variables
19222   --
19223   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
19224   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
19225   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
19226   l_dummy_payroll              boolean;
19227   l_dummy_manager1             boolean;
19228   l_dummy_manager2             boolean;
19229   l_dummy_manager3             boolean;
19230   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
19231   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
19232   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
19233   l_effective_date             date;
19234   l_date_probation_end         date;
19235   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
19236   l_concatenated_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
19237   l_cagr_concatenated_segments varchar2(2000);
19238   l_cagr_grade_def_id          per_cagr_grades_def.cagr_grade_def_id%TYPE;
19239 --
19240 
19241 -- Bug 944911
19242 -- added an new var to handle in and out
19243   l_concat_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
19244   l_soft_coding_keyflex_id      hr_soft_coding_keyflex.soft_coding_keyflex_id%TYPE;
19245   --
19246   -- Internal working variables
19247   --
19248   l_business_group_id          per_business_groups.business_group_id%TYPE;
19249   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
19250   l_group_name                 pay_people_groups.group_name%TYPE;
19251   l_proc                       varchar2(72);
19252   l_api_updating               boolean;
19253   --
19254 begin
19255  if g_debug then
19256   l_proc := g_package||'update_apl_asg';
19257   hr_utility.set_location('Entering:'|| l_proc, 1);
19258  end if;
19259   --
19260   l_object_version_number := p_object_version_number ;
19261 -- bug 944911
19262 -- made concatenated to concat
19263 -- changing p_concat to p_concatenated
19264   l_concat_segments := p_concatenated_segments;
19265   --
19266   -- Call the new code
19267 -- bug 944911
19268 -- made no changes to p_group_name as it is out , while in is
19269   hr_assignment_api.update_apl_asg(
19270    p_validate                     => p_validate
19271   ,p_effective_date               => p_effective_date
19272   ,p_datetrack_update_mode        => p_datetrack_update_mode
19273   ,p_assignment_id                => p_assignment_id
19274   ,p_object_version_number        => l_object_version_number
19275   ,p_grade_id                     => p_grade_id
19276   ,p_job_id                       => p_job_id
19277   ,p_location_id                  => p_location_id
19278   ,p_organization_id              => p_organization_id
19279   ,p_position_id                  => p_position_id
19280   ,p_application_id               => p_application_id
19281   ,p_recruiter_id                 => p_recruiter_id
19282   ,p_recruitment_activity_id      => p_recruitment_activity_id
19283   ,p_vacancy_id                   => p_vacancy_id
19284   ,p_person_referred_by_id        => p_person_referred_by_id
19285   ,p_supervisor_id                => p_supervisor_id
19286   ,p_source_organization_id       => p_source_organization_id
19287   ,p_change_reason                => p_change_reason
19288   ,p_frequency                    => p_frequency
19289   ,p_manager_flag                 => p_manager_flag
19290   ,p_normal_hours                 => p_normal_hours
19291   ,p_probation_period             => p_probation_period
19292   ,p_probation_unit               => p_probation_unit
19293   ,p_source_type                  => p_source_type
19294   ,p_time_normal_finish           => p_time_normal_finish
19295   ,p_time_normal_start            => p_time_normal_start
19296   ,p_comments                     => p_comments
19297   ,p_date_probation_end           => p_date_probation_end
19298   ,p_title                        => p_title
19299   ,p_ass_attribute_category       => p_ass_attribute_category
19300   ,p_ass_attribute1               => p_ass_attribute1
19301   ,p_ass_attribute2               => p_ass_attribute2
19302   ,p_ass_attribute3               => p_ass_attribute3
19303   ,p_ass_attribute4               => p_ass_attribute4
19304   ,p_ass_attribute5               => p_ass_attribute5
19305   ,p_ass_attribute6               => p_ass_attribute6
19306   ,p_ass_attribute7               => p_ass_attribute7
19307   ,p_ass_attribute8               => p_ass_attribute8
19308   ,p_ass_attribute9               => p_ass_attribute9
19309   ,p_ass_attribute10              => p_ass_attribute10
19310   ,p_ass_attribute11              => p_ass_attribute11
19311   ,p_ass_attribute12              => p_ass_attribute12
19312   ,p_ass_attribute13              => p_ass_attribute13
19313   ,p_ass_attribute14              => p_ass_attribute14
19314   ,p_ass_attribute15              => p_ass_attribute15
19315   ,p_ass_attribute16              => p_ass_attribute16
19316   ,p_ass_attribute17              => p_ass_attribute17
19317   ,p_ass_attribute18              => p_ass_attribute18
19318   ,p_ass_attribute19              => p_ass_attribute19
19319   ,p_ass_attribute20              => p_ass_attribute20
19320   ,p_ass_attribute21              => p_ass_attribute21
19321   ,p_ass_attribute22              => p_ass_attribute22
19322   ,p_ass_attribute23              => p_ass_attribute23
19323   ,p_ass_attribute24              => p_ass_attribute24
19324   ,p_ass_attribute25              => p_ass_attribute25
19325   ,p_ass_attribute26              => p_ass_attribute26
19326   ,p_ass_attribute27              => p_ass_attribute27
19327   ,p_ass_attribute28              => p_ass_attribute28
19328   ,p_ass_attribute29              => p_ass_attribute29
19329   ,p_ass_attribute30              => p_ass_attribute30
19330   ,p_scl_segment1                     => p_segment1
19331   ,p_scl_segment2                     => p_segment2
19332   ,p_scl_segment3                     => p_segment3
19333   ,p_scl_segment4                     => p_segment4
19334   ,p_scl_segment5                     => p_segment5
19335   ,p_scl_segment6                     => p_segment6
19336   ,p_scl_segment7                     => p_segment7
19337   ,p_scl_segment8                     => p_segment8
19338   ,p_scl_segment9                     => p_segment9
19339   ,p_scl_segment10                    => p_segment10
19340   ,p_scl_segment11                    => p_segment11
19341   ,p_scl_segment12                    => p_segment12
19342   ,p_scl_segment13                    => p_segment13
19343   ,p_scl_segment14                    => p_segment14
19344   ,p_scl_segment15                    => p_segment15
19345   ,p_scl_segment16                    => p_segment16
19346   ,p_scl_segment17                    => p_segment17
19347   ,p_scl_segment18                    => p_segment18
19348   ,p_scl_segment19                    => p_segment19
19349   ,p_scl_segment20                    => p_segment20
19350   ,p_scl_segment21                    => p_segment21
19351   ,p_scl_segment22                    => p_segment22
19352   ,p_scl_segment23                    => p_segment23
19353   ,p_scl_segment24                    => p_segment24
19354   ,p_scl_segment25                    => p_segment25
19355   ,p_scl_segment26                    => p_segment26
19356   ,p_scl_segment27                    => p_segment27
19357   ,p_scl_segment28                    => p_segment28
19358   ,p_scl_segment29                    => p_segment29
19359   ,p_scl_segment30                    => p_segment30
19360   ,p_comment_id                   => l_comment_id
19361   ,p_people_group_id              => l_people_group_id
19362   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
19363   ,p_effective_start_date         => l_effective_start_date
19364   ,p_effective_end_date           => l_effective_end_date
19365   ,p_group_name                   => l_group_name
19366   ,p_scl_concat_segments    => l_concat_segments
19367   ,p_concatenated_segments    => l_concatenated_segments
19368   ,p_cagr_grade_def_id            =>     l_cagr_grade_def_id
19369   ,p_cagr_concatenated_segments   =>     l_cagr_concatenated_segments
19370   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
19371   );
19372   -- Set all output arguments
19373   -- Ignore the overloaded out arguments
19374   --
19375   p_object_version_number  := l_object_version_number;
19376   p_comment_id             := l_comment_id;
19377   p_effective_start_date   := l_effective_start_date;
19378   p_effective_end_date     := l_effective_end_date;
19379   p_people_group_id        := l_people_group_id;
19380   --
19381  if g_debug then
19382   hr_utility.set_location(' Leaving:'||l_proc, 6);
19383  end if;
19384 end update_apl_asg;
19385 --
19386 -- OLD
19387 -- ----------------------------------------------------------------------------
19388 -- |---------------------< create_secondary_apl_asg >-------------------------|
19389 -- ----------------------------------------------------------------------------
19390 procedure create_secondary_apl_asg
19391   (p_validate                     in     boolean
19392   ,p_effective_date               in     date
19393   ,p_person_id                    in     number
19394   ,p_organization_id              in     number
19395   ,p_recruiter_id                 in     number
19396   ,p_grade_id                     in     number
19397   ,p_position_id                  in     number
19398   ,p_job_id                       in     number
19399   ,p_assignment_status_type_id    in     number
19400   ,p_payroll_id                   in     number
19401   ,p_location_id                  in     number
19402   ,p_person_referred_by_id        in     number
19403   ,p_supervisor_id                in     number
19404   ,p_special_ceiling_step_id      in     number
19405   ,p_recruitment_activity_id      in     number
19406   ,p_source_organization_id       in     number
19407   ,p_vacancy_id                   in     number
19408   ,p_pay_basis_id                 in     number
19409   ,p_change_reason                in     varchar2
19410   ,p_comments                     in     varchar2
19411   ,p_date_probation_end           in     date
19412   ,p_default_code_comb_id         in     number
19413   ,p_employment_category          in     varchar2
19414   ,p_frequency                    in     varchar2
19415   ,p_internal_address_line        in     varchar2
19416   ,p_manager_flag                 in     varchar2
19417   ,p_normal_hours                 in     number
19418   ,p_perf_review_period           in     number
19419   ,p_perf_review_period_frequency in     varchar2
19420   ,p_probation_period             in     number
19421   ,p_probation_unit               in     varchar2
19422   ,p_sal_review_period            in     number
19423   ,p_sal_review_period_frequency  in     varchar2
19424   ,p_set_of_books_id              in     number
19425   ,p_source_type                  in     varchar2
19426   ,p_time_normal_finish           in     varchar2
19427   ,p_time_normal_start            in     varchar2
19428   ,p_bargaining_unit_code         in     varchar2
19429   ,p_ass_attribute_category       in     varchar2
19430   ,p_ass_attribute1               in     varchar2
19431   ,p_ass_attribute2               in     varchar2
19432   ,p_ass_attribute3               in     varchar2
19433   ,p_ass_attribute4               in     varchar2
19434   ,p_ass_attribute5               in     varchar2
19435   ,p_ass_attribute6               in     varchar2
19436   ,p_ass_attribute7               in     varchar2
19437   ,p_ass_attribute8               in     varchar2
19438   ,p_ass_attribute9               in     varchar2
19439   ,p_ass_attribute10              in     varchar2
19440   ,p_ass_attribute11              in     varchar2
19441   ,p_ass_attribute12              in     varchar2
19442   ,p_ass_attribute13              in     varchar2
19443   ,p_ass_attribute14              in     varchar2
19444   ,p_ass_attribute15              in     varchar2
19445   ,p_ass_attribute16              in     varchar2
19446   ,p_ass_attribute17              in     varchar2
19447   ,p_ass_attribute18              in     varchar2
19448   ,p_ass_attribute19              in     varchar2
19449   ,p_ass_attribute20              in     varchar2
19450   ,p_ass_attribute21              in     varchar2
19451   ,p_ass_attribute22              in     varchar2
19452   ,p_ass_attribute23              in     varchar2
19453   ,p_ass_attribute24              in     varchar2
19454   ,p_ass_attribute25              in     varchar2
19455   ,p_ass_attribute26              in     varchar2
19456   ,p_ass_attribute27              in     varchar2
19457   ,p_ass_attribute28              in     varchar2
19458   ,p_ass_attribute29              in     varchar2
19459   ,p_ass_attribute30              in     varchar2
19460   ,p_title                        in     varchar2
19461   ,p_scl_segment1                 in     varchar2
19462   ,p_scl_segment2                 in     varchar2
19463   ,p_scl_segment3                 in     varchar2
19464   ,p_scl_segment4                 in     varchar2
19465   ,p_scl_segment5                 in     varchar2
19466   ,p_scl_segment6                 in     varchar2
19467   ,p_scl_segment7                 in     varchar2
19468   ,p_scl_segment8                 in     varchar2
19469   ,p_scl_segment9                 in     varchar2
19470   ,p_scl_segment10                in     varchar2
19471   ,p_scl_segment11                in     varchar2
19472   ,p_scl_segment12                in     varchar2
19473   ,p_scl_segment13                in     varchar2
19474   ,p_scl_segment14                in     varchar2
19475   ,p_scl_segment15                in     varchar2
19476   ,p_scl_segment16                in     varchar2
19477   ,p_scl_segment17                in     varchar2
19478   ,p_scl_segment18                in     varchar2
19479   ,p_scl_segment19                in     varchar2
19480   ,p_scl_segment20                in     varchar2
19481   ,p_scl_segment21                in     varchar2
19482   ,p_scl_segment22                in     varchar2
19483   ,p_scl_segment23                in     varchar2
19484   ,p_scl_segment24                in     varchar2
19485   ,p_scl_segment25                in     varchar2
19486   ,p_scl_segment26                in     varchar2
19487   ,p_scl_segment27                in     varchar2
19488   ,p_scl_segment28                in     varchar2
19489   ,p_scl_segment29                in     varchar2
19490   ,p_scl_segment30                in     varchar2
19491   ,p_scl_concat_segments          in     varchar2
19492   ,p_concatenated_segments           out nocopy varchar2
19493   ,p_pgp_segment1                 in     varchar2
19494   ,p_pgp_segment2                 in     varchar2
19495   ,p_pgp_segment3                 in     varchar2
19496   ,p_pgp_segment4                 in     varchar2
19497   ,p_pgp_segment5                 in     varchar2
19498   ,p_pgp_segment6                 in     varchar2
19499   ,p_pgp_segment7                 in     varchar2
19500   ,p_pgp_segment8                 in     varchar2
19501   ,p_pgp_segment9                 in     varchar2
19502   ,p_pgp_segment10                in     varchar2
19503   ,p_pgp_segment11                in     varchar2
19504   ,p_pgp_segment12                in     varchar2
19505   ,p_pgp_segment13                in     varchar2
19506   ,p_pgp_segment14                in     varchar2
19507   ,p_pgp_segment15                in     varchar2
19508   ,p_pgp_segment16                in     varchar2
19509   ,p_pgp_segment17                in     varchar2
19510   ,p_pgp_segment18                in     varchar2
19511   ,p_pgp_segment19                in     varchar2
19512   ,p_pgp_segment20                in     varchar2
19513   ,p_pgp_segment21                in     varchar2
19514   ,p_pgp_segment22                in     varchar2
19515   ,p_pgp_segment23                in     varchar2
19516   ,p_pgp_segment24                in     varchar2
19517   ,p_pgp_segment25                in     varchar2
19518   ,p_pgp_segment26                in     varchar2
19519   ,p_pgp_segment27                in     varchar2
19520   ,p_pgp_segment28                in     varchar2
19521   ,p_pgp_segment29                in     varchar2
19522   ,p_pgp_segment30                in     varchar2
19523   ,p_concat_segments		  in     varchar2
19524   ,p_contract_id                  in     number
19525   ,p_establishment_id             in     number
19526   ,p_collective_agreement_id      in     number
19527   ,p_cagr_id_flex_num             in     number
19528   ,p_cag_segment1                 in     varchar2
19529   ,p_cag_segment2                 in     varchar2
19530   ,p_cag_segment3                 in     varchar2
19531   ,p_cag_segment4                 in     varchar2
19532   ,p_cag_segment5                 in     varchar2
19533   ,p_cag_segment6                 in     varchar2
19534   ,p_cag_segment7                 in     varchar2
19535   ,p_cag_segment8                 in     varchar2
19536   ,p_cag_segment9                 in     varchar2
19537   ,p_cag_segment10                in     varchar2
19538   ,p_cag_segment11                in     varchar2
19539   ,p_cag_segment12                in     varchar2
19540   ,p_cag_segment13                in     varchar2
19541   ,p_cag_segment14                in     varchar2
19542   ,p_cag_segment15                in     varchar2
19543   ,p_cag_segment16                in     varchar2
19544   ,p_cag_segment17                in     varchar2
19545   ,p_cag_segment18                in     varchar2
19546   ,p_cag_segment19                in     varchar2
19547   ,p_cag_segment20                in     varchar2
19548   ,p_notice_period		  in	 number
19549   ,p_notice_period_uom		  in     varchar2
19550   ,p_employee_category		  in     varchar2
19551   ,p_work_at_home		  in	 varchar2
19552   ,p_job_post_source_name         in     varchar2
19553   ,p_applicant_rank               in     number
19554   ,p_posting_content_id           in     number
19555   ,p_grade_ladder_pgm_id          in     number
19556   ,p_supervisor_assignment_id     in     number
19557   ,p_cagr_grade_def_id            in out nocopy number
19558   ,p_cagr_concatenated_segments      out nocopy varchar2
19559   ,p_group_name                      out nocopy varchar2
19560   ,p_assignment_id                   out nocopy number
19561   ,p_people_group_id              in out nocopy number
19562   ,p_soft_coding_keyflex_id       in out nocopy number
19563   ,p_comment_id                      out nocopy number
19564   ,p_object_version_number           out nocopy number
19565   ,p_effective_start_date            out nocopy date
19566   ,p_effective_end_date              out nocopy date
19567   ,p_assignment_sequence             out nocopy number
19568   ) is
19569   l_warning boolean;
19570 BEGIN
19571  create_secondary_apl_asg
19572   (p_validate                     => p_validate
19573   ,p_effective_date               => p_effective_date
19574   ,p_person_id                    => p_person_id
19575   ,p_organization_id              => p_organization_id
19576   ,p_recruiter_id                 => p_recruiter_id
19577   ,p_grade_id                     => p_grade_id
19578   ,p_position_id                  =>  p_position_id
19579   ,p_job_id                       => p_job_id
19580   ,p_assignment_status_type_id    => p_assignment_status_type_id
19581   ,p_payroll_id                   => p_payroll_id
19582   ,p_location_id                  => p_location_id
19583   ,p_person_referred_by_id        => p_person_referred_by_id
19584   ,p_supervisor_id                => p_supervisor_id
19585   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
19586   ,p_recruitment_activity_id      => p_recruitment_activity_id
19587   ,p_source_organization_id       => p_source_organization_id
19588   ,p_vacancy_id                   => p_vacancy_id
19589   ,p_pay_basis_id                 => p_pay_basis_id
19590   ,p_change_reason                => p_change_reason
19591   ,p_comments                     => p_comments
19592   ,p_date_probation_end           => p_date_probation_end
19593   ,p_default_code_comb_id         => p_default_code_comb_id
19594   ,p_employment_category          => p_employment_category
19595   ,p_frequency                    => p_frequency
19596   ,p_internal_address_line        => p_internal_address_line
19597   ,p_manager_flag                 => p_manager_flag
19598   ,p_normal_hours                 => p_normal_hours
19599   ,p_perf_review_period           => p_perf_review_period
19600   ,p_perf_review_period_frequency => p_perf_review_period_frequency
19601   ,p_probation_period             => p_probation_period
19602   ,p_probation_unit               => p_probation_unit
19603   ,p_sal_review_period            => p_sal_review_period
19604   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
19605   ,p_set_of_books_id              => p_set_of_books_id
19606   ,p_source_type                  => p_source_type
19607   ,p_time_normal_finish           => p_time_normal_finish
19608   ,p_time_normal_start            => p_time_normal_start
19609   ,p_bargaining_unit_code         => p_bargaining_unit_code
19610   ,p_ass_attribute_category       => p_ass_attribute_category
19611   ,p_ass_attribute1               => p_ass_attribute1
19612   ,p_ass_attribute2               => p_ass_attribute2
19613   ,p_ass_attribute3               => p_ass_attribute3
19614   ,p_ass_attribute4               => p_ass_attribute4
19615   ,p_ass_attribute5               => p_ass_attribute5
19616   ,p_ass_attribute6               => p_ass_attribute6
19617   ,p_ass_attribute7               => p_ass_attribute7
19618   ,p_ass_attribute8               => p_ass_attribute8
19619   ,p_ass_attribute9               => p_ass_attribute9
19620   ,p_ass_attribute10              => p_ass_attribute10
19621   ,p_ass_attribute11              => p_ass_attribute11
19622   ,p_ass_attribute12              => p_ass_attribute12
19623   ,p_ass_attribute13              => p_ass_attribute13
19624   ,p_ass_attribute14              => p_ass_attribute14
19625   ,p_ass_attribute15              => p_ass_attribute15
19626   ,p_ass_attribute16              => p_ass_attribute16
19627   ,p_ass_attribute17              => p_ass_attribute17
19628   ,p_ass_attribute18              => p_ass_attribute18
19629   ,p_ass_attribute19              => p_ass_attribute19
19630   ,p_ass_attribute20              => p_ass_attribute20
19631   ,p_ass_attribute21              => p_ass_attribute21
19632   ,p_ass_attribute22              => p_ass_attribute22
19633   ,p_ass_attribute23              => p_ass_attribute23
19634   ,p_ass_attribute24              => p_ass_attribute24
19635   ,p_ass_attribute25              => p_ass_attribute25
19636   ,p_ass_attribute26              => p_ass_attribute26
19637   ,p_ass_attribute27              => p_ass_attribute27
19638   ,p_ass_attribute28              => p_ass_attribute28
19639   ,p_ass_attribute29              => p_ass_attribute29
19640   ,p_ass_attribute30              => p_ass_attribute30
19641   ,p_title                        => p_title
19642   ,p_scl_segment1                 => p_scl_segment1
19643   ,p_scl_segment2                 => p_scl_segment2
19644   ,p_scl_segment3                 => p_scl_segment3
19645   ,p_scl_segment4                 => p_scl_segment4
19646   ,p_scl_segment5                 => p_scl_segment5
19647   ,p_scl_segment6                 => p_scl_segment6
19648   ,p_scl_segment7                 => p_scl_segment7
19649   ,p_scl_segment8                 => p_scl_segment8
19650   ,p_scl_segment9                 => p_scl_segment9
19651   ,p_scl_segment10                => p_scl_segment10
19652   ,p_scl_segment11                => p_scl_segment11
19653   ,p_scl_segment12                => p_scl_segment12
19654   ,p_scl_segment13                => p_scl_segment13
19655   ,p_scl_segment14                => p_scl_segment14
19656   ,p_scl_segment15                => p_scl_segment15
19657   ,p_scl_segment16                => p_scl_segment16
19658   ,p_scl_segment17                => p_scl_segment17
19659   ,p_scl_segment18                => p_scl_segment18
19660   ,p_scl_segment19                => p_scl_segment19
19661   ,p_scl_segment20                => p_scl_segment20
19662   ,p_scl_segment21                => p_scl_segment21
19663   ,p_scl_segment22                => p_scl_segment22
19664   ,p_scl_segment23                => p_scl_segment23
19665   ,p_scl_segment24                => p_scl_segment24
19666   ,p_scl_segment25                => p_scl_segment25
19667   ,p_scl_segment26                => p_scl_segment26
19668   ,p_scl_segment27                => p_scl_segment27
19669   ,p_scl_segment28                => p_scl_segment28
19670   ,p_scl_segment29                => p_scl_segment29
19671   ,p_scl_segment30                => p_scl_segment30
19672   ,p_scl_concat_segments          => p_scl_concat_segments
19673   ,p_concatenated_segments        => p_concatenated_segments
19674   ,p_pgp_segment1                 => p_pgp_segment1
19675   ,p_pgp_segment2                 => p_pgp_segment2
19676   ,p_pgp_segment3                 => p_pgp_segment3
19677   ,p_pgp_segment4                 => p_pgp_segment4
19678   ,p_pgp_segment5                 => p_pgp_segment5
19679   ,p_pgp_segment6                 => p_pgp_segment6
19680   ,p_pgp_segment7                 => p_pgp_segment7
19681   ,p_pgp_segment8                 => p_pgp_segment8
19682   ,p_pgp_segment9                 => p_pgp_segment9
19683   ,p_pgp_segment10                => p_pgp_segment10
19684   ,p_pgp_segment11                => p_pgp_segment11
19685   ,p_pgp_segment12                => p_pgp_segment12
19686   ,p_pgp_segment13                => p_pgp_segment13
19687   ,p_pgp_segment14                => p_pgp_segment14
19688   ,p_pgp_segment15                => p_pgp_segment15
19689   ,p_pgp_segment16                => p_pgp_segment16
19690   ,p_pgp_segment17                => p_pgp_segment17
19691   ,p_pgp_segment18                => p_pgp_segment18
19692   ,p_pgp_segment19                => p_pgp_segment19
19693   ,p_pgp_segment20                => p_pgp_segment20
19694   ,p_pgp_segment21                => p_pgp_segment21
19695   ,p_pgp_segment22                => p_pgp_segment22
19696   ,p_pgp_segment23                => p_pgp_segment23
19697   ,p_pgp_segment24                => p_pgp_segment24
19698   ,p_pgp_segment25                => p_pgp_segment25
19699   ,p_pgp_segment26                => p_pgp_segment26
19700   ,p_pgp_segment27                => p_pgp_segment27
19701   ,p_pgp_segment28                => p_pgp_segment28
19702   ,p_pgp_segment29                => p_pgp_segment29
19703   ,p_pgp_segment30                => p_pgp_segment30
19704   ,p_concat_segments		      => p_concat_segments
19705   ,p_contract_id                  => p_contract_id
19706   ,p_establishment_id             => p_establishment_id
19707   ,p_collective_agreement_id      => p_collective_agreement_id
19708   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
19709   ,p_cag_segment1                 => p_cag_segment1
19710   ,p_cag_segment2                 => p_cag_segment2
19711   ,p_cag_segment3                 => p_cag_segment3
19712   ,p_cag_segment4                 => p_cag_segment4
19713   ,p_cag_segment5                 => p_cag_segment5
19714   ,p_cag_segment6                 => p_cag_segment6
19715   ,p_cag_segment7                 => p_cag_segment7
19716   ,p_cag_segment8                 => p_cag_segment8
19717   ,p_cag_segment9                 => p_cag_segment9
19718   ,p_cag_segment10                => p_cag_segment10
19719   ,p_cag_segment11                => p_cag_segment11
19720   ,p_cag_segment12                => p_cag_segment12
19721   ,p_cag_segment13                => p_cag_segment13
19722   ,p_cag_segment14                => p_cag_segment14
19723   ,p_cag_segment15                => p_cag_segment15
19724   ,p_cag_segment16                => p_cag_segment16
19725   ,p_cag_segment17                => p_cag_segment17
19726   ,p_cag_segment18                => p_cag_segment18
19727   ,p_cag_segment19                => p_cag_segment19
19728   ,p_cag_segment20                => p_cag_segment20
19729   ,p_notice_period		          => p_notice_period
19730   ,p_notice_period_uom		      => p_notice_period_uom
19731   ,p_employee_category		      => p_employee_category
19732   ,p_work_at_home		          => p_work_at_home
19733   ,p_job_post_source_name         => p_job_post_source_name
19734   ,p_applicant_rank               => p_applicant_rank
19735   ,p_posting_content_id           => p_posting_content_id
19736   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
19737   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
19738   ,p_cagr_grade_def_id            => p_cagr_grade_def_id
19739   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
19740   ,p_group_name                   => p_group_name
19741   ,p_assignment_id                => p_assignment_id
19742   ,p_people_group_id              => p_people_group_id
19743   ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
19744   ,p_comment_id                   => p_comment_id
19745   ,p_object_version_number        => p_object_version_number
19746   ,p_effective_start_date         => p_effective_start_date
19747   ,p_effective_end_date           => p_effective_end_date
19748   ,p_assignment_sequence          => p_assignment_sequence
19749   ,p_appl_override_warning        => l_warning
19750   );
19751 
19752 END;
19753 -- NEW
19754 -- ----------------------------------------------------------------------------
19755 -- |---------------------< create_secondary_apl_asg >-------------------------|
19756 -- ----------------------------------------------------------------------------
19757 -- NEW
19758 procedure create_secondary_apl_asg
19759   (p_validate                     in     boolean
19760   ,p_effective_date               in     date
19761   ,p_person_id                    in     number
19762   ,p_organization_id              in     number
19763   ,p_recruiter_id                 in     number
19764   ,p_grade_id                     in     number
19765   ,p_position_id                  in     number
19766   ,p_job_id                       in     number
19767   ,p_assignment_status_type_id    in     number
19768   ,p_payroll_id                   in     number
19769   ,p_location_id                  in     number
19770   ,p_person_referred_by_id        in     number
19771   ,p_supervisor_id                in     number
19772   ,p_special_ceiling_step_id      in     number
19773   ,p_recruitment_activity_id      in     number
19774   ,p_source_organization_id       in     number
19775   ,p_vacancy_id                   in     number
19776   ,p_pay_basis_id                 in     number
19777   ,p_change_reason                in     varchar2
19778   ,p_comments                     in     varchar2
19779   ,p_date_probation_end           in     date
19780   ,p_default_code_comb_id         in     number
19781   ,p_employment_category          in     varchar2
19782   ,p_frequency                    in     varchar2
19783   ,p_internal_address_line        in     varchar2
19784   ,p_manager_flag                 in     varchar2
19785   ,p_normal_hours                 in     number
19786   ,p_perf_review_period           in     number
19787   ,p_perf_review_period_frequency in     varchar2
19788   ,p_probation_period             in     number
19789   ,p_probation_unit               in     varchar2
19790   ,p_sal_review_period            in     number
19791   ,p_sal_review_period_frequency  in     varchar2
19792   ,p_set_of_books_id              in     number
19793   ,p_source_type                  in     varchar2
19794   ,p_time_normal_finish           in     varchar2
19795   ,p_time_normal_start            in     varchar2
19796   ,p_bargaining_unit_code         in     varchar2
19797   ,p_ass_attribute_category       in     varchar2
19798   ,p_ass_attribute1               in     varchar2
19799   ,p_ass_attribute2               in     varchar2
19800   ,p_ass_attribute3               in     varchar2
19801   ,p_ass_attribute4               in     varchar2
19802   ,p_ass_attribute5               in     varchar2
19803   ,p_ass_attribute6               in     varchar2
19804   ,p_ass_attribute7               in     varchar2
19805   ,p_ass_attribute8               in     varchar2
19806   ,p_ass_attribute9               in     varchar2
19807   ,p_ass_attribute10              in     varchar2
19808   ,p_ass_attribute11              in     varchar2
19809   ,p_ass_attribute12              in     varchar2
19810   ,p_ass_attribute13              in     varchar2
19811   ,p_ass_attribute14              in     varchar2
19812   ,p_ass_attribute15              in     varchar2
19813   ,p_ass_attribute16              in     varchar2
19814   ,p_ass_attribute17              in     varchar2
19815   ,p_ass_attribute18              in     varchar2
19816   ,p_ass_attribute19              in     varchar2
19817   ,p_ass_attribute20              in     varchar2
19818   ,p_ass_attribute21              in     varchar2
19819   ,p_ass_attribute22              in     varchar2
19820   ,p_ass_attribute23              in     varchar2
19821   ,p_ass_attribute24              in     varchar2
19822   ,p_ass_attribute25              in     varchar2
19823   ,p_ass_attribute26              in     varchar2
19824   ,p_ass_attribute27              in     varchar2
19825   ,p_ass_attribute28              in     varchar2
19826   ,p_ass_attribute29              in     varchar2
19827   ,p_ass_attribute30              in     varchar2
19828   ,p_title                        in     varchar2
19829   ,p_scl_segment1                 in     varchar2
19830   ,p_scl_segment2                 in     varchar2
19831   ,p_scl_segment3                 in     varchar2
19832   ,p_scl_segment4                 in     varchar2
19833   ,p_scl_segment5                 in     varchar2
19834   ,p_scl_segment6                 in     varchar2
19835   ,p_scl_segment7                 in     varchar2
19836   ,p_scl_segment8                 in     varchar2
19837   ,p_scl_segment9                 in     varchar2
19838   ,p_scl_segment10                in     varchar2
19839   ,p_scl_segment11                in     varchar2
19840   ,p_scl_segment12                in     varchar2
19841   ,p_scl_segment13                in     varchar2
19842   ,p_scl_segment14                in     varchar2
19843   ,p_scl_segment15                in     varchar2
19844   ,p_scl_segment16                in     varchar2
19845   ,p_scl_segment17                in     varchar2
19846   ,p_scl_segment18                in     varchar2
19847   ,p_scl_segment19                in     varchar2
19848   ,p_scl_segment20                in     varchar2
19849   ,p_scl_segment21                in     varchar2
19850   ,p_scl_segment22                in     varchar2
19851   ,p_scl_segment23                in     varchar2
19852   ,p_scl_segment24                in     varchar2
19853   ,p_scl_segment25                in     varchar2
19854   ,p_scl_segment26                in     varchar2
19855   ,p_scl_segment27                in     varchar2
19856   ,p_scl_segment28                in     varchar2
19857   ,p_scl_segment29                in     varchar2
19858   ,p_scl_segment30                in     varchar2
19859 -- Bug 944911
19860 -- Amended p_scl_concatenated_segments to be an out instead of in out
19861 -- Added new param p_scl_concat_segments
19862 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
19863   ,p_scl_concat_segments          in     varchar2
19864   ,p_concatenated_segments           out nocopy varchar2
19865   ,p_pgp_segment1                 in     varchar2
19866   ,p_pgp_segment2                 in     varchar2
19867   ,p_pgp_segment3                 in     varchar2
19868   ,p_pgp_segment4                 in     varchar2
19869   ,p_pgp_segment5                 in     varchar2
19870   ,p_pgp_segment6                 in     varchar2
19871   ,p_pgp_segment7                 in     varchar2
19872   ,p_pgp_segment8                 in     varchar2
19873   ,p_pgp_segment9                 in     varchar2
19874   ,p_pgp_segment10                in     varchar2
19875   ,p_pgp_segment11                in     varchar2
19876   ,p_pgp_segment12                in     varchar2
19877   ,p_pgp_segment13                in     varchar2
19878   ,p_pgp_segment14                in     varchar2
19879   ,p_pgp_segment15                in     varchar2
19880   ,p_pgp_segment16                in     varchar2
19881   ,p_pgp_segment17                in     varchar2
19882   ,p_pgp_segment18                in     varchar2
19883   ,p_pgp_segment19                in     varchar2
19884   ,p_pgp_segment20                in     varchar2
19885   ,p_pgp_segment21                in     varchar2
19886   ,p_pgp_segment22                in     varchar2
19887   ,p_pgp_segment23                in     varchar2
19888   ,p_pgp_segment24                in     varchar2
19889   ,p_pgp_segment25                in     varchar2
19890   ,p_pgp_segment26                in     varchar2
19891   ,p_pgp_segment27                in     varchar2
19892   ,p_pgp_segment28                in     varchar2
19893   ,p_pgp_segment29                in     varchar2
19894   ,p_pgp_segment30                in     varchar2
19895 -- Bug 944911
19896 -- Made p_group_name to be out param
19897 -- and add p_concat_segment to be IN
19898 -- in case of sec_asg alone made p_pgp_concat_segments as in param
19899   ,p_concat_segments		  in     varchar2
19900   ,p_contract_id                  in     number
19901   ,p_establishment_id             in     number
19902   ,p_collective_agreement_id      in     number
19903   ,p_cagr_id_flex_num             in     number
19904   ,p_cag_segment1                 in     varchar2
19905   ,p_cag_segment2                 in     varchar2
19906   ,p_cag_segment3                 in     varchar2
19907   ,p_cag_segment4                 in     varchar2
19908   ,p_cag_segment5                 in     varchar2
19909   ,p_cag_segment6                 in     varchar2
19910   ,p_cag_segment7                 in     varchar2
19911   ,p_cag_segment8                 in     varchar2
19912   ,p_cag_segment9                 in     varchar2
19913   ,p_cag_segment10                in     varchar2
19914   ,p_cag_segment11                in     varchar2
19915   ,p_cag_segment12                in     varchar2
19916   ,p_cag_segment13                in     varchar2
19917   ,p_cag_segment14                in     varchar2
19918   ,p_cag_segment15                in     varchar2
19919   ,p_cag_segment16                in     varchar2
19920   ,p_cag_segment17                in     varchar2
19921   ,p_cag_segment18                in     varchar2
19922   ,p_cag_segment19                in     varchar2
19923   ,p_cag_segment20                in     varchar2
19924   ,p_notice_period		  in	 number
19925   ,p_notice_period_uom		  in     varchar2
19926   ,p_employee_category		  in     varchar2
19927   ,p_work_at_home		  in	 varchar2
19928   ,p_job_post_source_name         in     varchar2
19929   ,p_applicant_rank               in     number
19930   ,p_posting_content_id           in     number
19931   ,p_grade_ladder_pgm_id          in     number
19932   ,p_supervisor_assignment_id     in     number
19933   ,p_cagr_grade_def_id            in out nocopy number
19934   ,p_cagr_concatenated_segments      out nocopy varchar2
19935   ,p_group_name                      out nocopy varchar2
19936   ,p_assignment_id                   out nocopy number
19937   ,p_people_group_id              in out nocopy number
19938   ,p_soft_coding_keyflex_id       in out nocopy number
19939   ,p_comment_id                      out nocopy number
19940   ,p_object_version_number           out nocopy number
19941   ,p_effective_start_date            out nocopy date
19942   ,p_effective_end_date              out nocopy date
19943   ,p_assignment_sequence             out nocopy number
19944   ,p_appl_override_warning           OUT NOCOPY boolean  -- 3652025
19945   ) is
19946   --
19947   -- Declare cursors and local variables
19948   --
19949   -- Out variables
19950   --
19951   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
19952   l_people_group_id        per_all_assignments_f.people_group_id%TYPE := p_people_group_id;
19953   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
19954   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
19955   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
19956   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
19957   l_comment_id             per_all_assignments_f.comment_id%TYPE;
19958   l_group_name             pay_people_groups.group_name%TYPE;
19959   l_old_group_name         pay_people_groups.group_name%TYPE;
19960   --
19961   l_application_id         per_applications.application_id%TYPE;
19962   l_business_group_id      per_business_groups.business_group_id%TYPE;
19963   l_legislation_code       per_business_groups.legislation_code%TYPE;
19964   l_period_of_service_id   per_all_assignments_f.period_of_service_id%TYPE;
19965   l_proc                 varchar2(72) := g_package||'create_secondary_apl_asg';
19966   l_effective_date         date;
19967   l_date_probation_end     date;
19968   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
19969   l_scl_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE  ;
19970   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
19971   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
19972   l_session_id             number;
19973   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE := p_cagr_grade_def_id;
19974   l_cagr_concatenated_segments varchar2(2000);
19975   l_appl_date_end          per_applications.date_end%TYPE;
19976   --
19977   -- bug 2230915 new variables to indicate whether key flex id parameters
19978   -- enter the program with a value.
19979   --
19980   l_pgp_null_ind               number(1) := 0;
19981   l_scl_null_ind               number(1) := 0;
19982   l_cag_null_ind               number(1) := 0;
19983   --
19984   -- Bug 2230915 new variables for derived values where key flex id is known.
19985   --
19986   l_scl_segment1               varchar2(60) := p_scl_segment1;
19987   l_scl_segment2               varchar2(60) := p_scl_segment2;
19988   l_scl_segment3               varchar2(60) := p_scl_segment3;
19989   l_scl_segment4               varchar2(60) := p_scl_segment4;
19990   l_scl_segment5               varchar2(60) := p_scl_segment5;
19991   l_scl_segment6               varchar2(60) := p_scl_segment6;
19992   l_scl_segment7               varchar2(60) := p_scl_segment7;
19993   l_scl_segment8               varchar2(60) := p_scl_segment8;
19994   l_scl_segment9               varchar2(60) := p_scl_segment9;
19995   l_scl_segment10              varchar2(60) := p_scl_segment10;
19996   l_scl_segment11              varchar2(60) := p_scl_segment11;
19997   l_scl_segment12              varchar2(60) := p_scl_segment12;
19998   l_scl_segment13              varchar2(60) := p_scl_segment13;
19999   l_scl_segment14              varchar2(60) := p_scl_segment14;
20000   l_scl_segment15              varchar2(60) := p_scl_segment15;
20001   l_scl_segment16              varchar2(60) := p_scl_segment16;
20002   l_scl_segment17              varchar2(60) := p_scl_segment17;
20003   l_scl_segment18              varchar2(60) := p_scl_segment18;
20004   l_scl_segment19              varchar2(60) := p_scl_segment19;
20005   l_scl_segment20              varchar2(60) := p_scl_segment20;
20006   l_scl_segment21              varchar2(60) := p_scl_segment21;
20007   l_scl_segment22              varchar2(60) := p_scl_segment22;
20008   l_scl_segment23              varchar2(60) := p_scl_segment23;
20009   l_scl_segment24              varchar2(60) := p_scl_segment24;
20010   l_scl_segment25              varchar2(60) := p_scl_segment25;
20011   l_scl_segment26              varchar2(60) := p_scl_segment26;
20012   l_scl_segment27              varchar2(60) := p_scl_segment27;
20013   l_scl_segment28              varchar2(60) := p_scl_segment28;
20014   l_scl_segment29              varchar2(60) := p_scl_segment29;
20015   l_scl_segment30              varchar2(60) := p_scl_segment30;
20016   --
20017   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
20018   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
20019   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
20020   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
20021   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
20022   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
20023   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
20024   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
20025   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
20026   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
20027   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
20028   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
20029   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
20030   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
20031   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
20032   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
20033   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
20034   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
20035   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
20036   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
20037   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
20038   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
20039   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
20040   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
20041   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
20042   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
20043   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
20044   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
20045   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
20046   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
20047   --
20048   l_cag_segment1               varchar2(60) := p_cag_segment1;
20049   l_cag_segment2               varchar2(60) := p_cag_segment2;
20050   l_cag_segment3               varchar2(60) := p_cag_segment3;
20051   l_cag_segment4               varchar2(60) := p_cag_segment4;
20052   l_cag_segment5               varchar2(60) := p_cag_segment5;
20053   l_cag_segment6               varchar2(60) := p_cag_segment6;
20054   l_cag_segment7               varchar2(60) := p_cag_segment7;
20055   l_cag_segment8               varchar2(60) := p_cag_segment8;
20056   l_cag_segment9               varchar2(60) := p_cag_segment9;
20057   l_cag_segment10              varchar2(60) := p_cag_segment10;
20058   l_cag_segment11              varchar2(60) := p_cag_segment11;
20059   l_cag_segment12              varchar2(60) := p_cag_segment12;
20060   l_cag_segment13              varchar2(60) := p_cag_segment13;
20061   l_cag_segment14              varchar2(60) := p_cag_segment14;
20062   l_cag_segment15              varchar2(60) := p_cag_segment15;
20063   l_cag_segment16              varchar2(60) := p_cag_segment16;
20064   l_cag_segment17              varchar2(60) := p_cag_segment17;
20065   l_cag_segment18              varchar2(60) := p_cag_segment18;
20066   l_cag_segment19              varchar2(60) := p_cag_segment19;
20067   l_cag_segment20              varchar2(60) := p_cag_segment20;
20068   --
20069   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
20070   lv_people_group_id           number := p_people_group_id ;
20071   lv_soft_coding_keyflex_id    number := p_people_group_id ;
20072   --
20073   l_applicant_number          per_all_people_f.applicant_number%TYPE;
20074   l_per_object_version_number per_all_people_f.object_version_number%TYPE;
20075   l_appl_override_warning     boolean;
20076   l_per_effective_start_date  per_all_people_f.effective_start_date%TYPE;
20077   l_per_effective_end_date    per_all_people_f.effective_end_date%TYPE;
20078   l_apl_object_version_number per_applications.object_version_number%TYPE;
20079   --
20080 
20081   cursor csr_get_derived_details is
20082     select bus.business_group_id
20083          , bus.legislation_code
20084          , per.applicant_number, per.object_version_number  --3652025
20085       from per_all_people_f    per
20086          , per_business_groups_perf bus
20087      where per.person_id         = p_person_id
20088      and   l_effective_date      between per.effective_start_date
20089                                  and     per.effective_end_date
20090      and   bus.business_group_id = per.business_group_id;
20091   --
20092   -- 3652025 >>
20093   cursor csr_get_application is
20094    select apl.application_id, apl.date_end
20095      from per_applications apl
20096     where apl.person_id = p_person_id
20097       and l_effective_date between apl.date_received
20098                                and nvl(apl.date_end,hr_api.g_eot);
20099   -- <<
20100   cursor csr_get_apl_asg is
20101     select asg.application_id
20102       from per_all_assignments_f asg
20103      where asg.person_id    = p_person_id
20104      and   l_effective_date between asg.effective_start_date
20105                             and     asg.effective_end_date
20106      and   asg.assignment_type = 'A';
20107   --
20108   --
20109   cursor csr_grp_idsel is
20110     select bus.people_group_structure
20111      from  per_business_groups_perf bus
20112      where bus.business_group_id = l_business_group_id;
20113   --
20114   cursor csr_scl_idsel is
20115     select plr.rule_mode                       id_flex_num
20116     from   pay_legislation_rules               plr,
20117            per_business_groups_perf            pgr
20118     where  plr.legislation_code                = pgr.legislation_code
20119     and    pgr.business_group_id               = l_business_group_id
20120     and    plr.rule_type                       = 'S'
20121     and    exists
20122           (select 1
20123            from   fnd_segment_attribute_values fsav
20124            where  to_char(fsav.id_flex_num)    = plr.rule_mode   -- Fix For Bug# 12813119
20125            and    fsav.application_id          = 800
20126            and    fsav.id_flex_code            = 'SCL'
20127            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
20128            and    fsav.attribute_value         = 'Y')
20129     and    exists
20130           (select 1
20131            from   pay_legislation_rules        plr2
20132            where  plr2.legislation_code        = plr.legislation_code
20133            and    plr2.rule_type               = 'SDL'
20134            and    plr2.rule_mode               = 'A') ;
20135   --
20136   --
20137   -- bug 2230915 get pay_people_group segment values where
20138   -- people_group_id is known
20139   --
20140   cursor c_pgp_segments is
20141      select segment1,
20142             segment2,
20143             segment3,
20144             segment4,
20145             segment5,
20146             segment6,
20147             segment7,
20148             segment8,
20149             segment9,
20150             segment10,
20151             segment11,
20152             segment12,
20153             segment13,
20154             segment14,
20155             segment15,
20156             segment16,
20157             segment17,
20158             segment18,
20159             segment19,
20160             segment20,
20161             segment21,
20162             segment22,
20163             segment23,
20164             segment24,
20165             segment25,
20166             segment26,
20167             segment27,
20168             segment28,
20169             segment29,
20170             segment30
20171      from   pay_people_groups
20172      where  people_group_id = l_people_group_id;
20173   --
20174   -- bug 2230915 get hr_soft_coding_keyflex segment values where
20175   -- soft_coding_keyflex_id is known
20176   --
20177   cursor c_scl_segments is
20178      select segment1,
20179             segment2,
20180             segment3,
20181             segment4,
20182             segment5,
20183             segment6,
20184             segment7,
20185             segment8,
20186             segment9,
20187             segment10,
20188             segment11,
20189             segment12,
20190             segment13,
20191             segment14,
20192             segment15,
20193             segment16,
20194             segment17,
20195             segment18,
20196             segment19,
20197             segment20,
20198             segment21,
20199             segment22,
20200             segment23,
20201             segment24,
20202             segment25,
20203             segment26,
20204             segment27,
20205             segment28,
20206             segment29,
20207             segment30
20208      from   hr_soft_coding_keyflex
20209      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
20210   --
20211   -- bug 2230915 get per_cagr_grades_def segment values where
20212   -- cagr_grade_def_id is known
20213   --
20214   cursor c_cag_segments is
20215      select segment1,
20216             segment2,
20217             segment3,
20218             segment4,
20219             segment5,
20220             segment6,
20221             segment7,
20222             segment8,
20223             segment9,
20224             segment10,
20225             segment11,
20226             segment12,
20227             segment13,
20228             segment14,
20229             segment15,
20230             segment16,
20231             segment17,
20232             segment18,
20233             segment19,
20234             segment20
20235      from   per_cagr_grades_def
20236      where  cagr_grade_def_id = l_cagr_grade_def_id;
20237   --
20238   l_assignment_status_type_id  per_all_assignments_f.assignment_status_type_id%TYPE;
20239 --
20240 begin
20241 --
20242  if g_debug then
20243   hr_utility.set_location('Entering:'|| l_proc, 5);
20244  end if;
20245   --
20246   -- Truncate date value p_effective_date to remove time element.
20247   --
20248   l_effective_date := trunc(p_effective_date);
20249   l_date_probation_end := trunc(p_date_probation_end);
20250 -- Bug 944911
20251 -- Made p_group_name to be out param
20252 -- and add p_concat_segment to be IN
20253 -- in case of sec_asg alone made p_pgp_concat_segments as in param
20254 -- replaced p_group_name by p_concat_segments
20255   l_old_group_name       := p_concat_segments;
20256 -- Bug 944911
20257 -- Amended p_scl_concatenated_segments to p_scl_concat_segments
20258   l_old_scl_conc_segments := p_scl_concat_segments;
20259   --
20260   -- Issue a savepoint.
20261   --
20262   savepoint create_secondary_apl_asg;
20263   --
20264  if g_debug then
20265   hr_utility.set_location(l_proc, 10);
20266  end if;
20267   --
20268   -- Validation in addition to Table Handlers
20269   --
20270   -- Get person details.
20271   --
20272   hr_api.mandatory_arg_error
20273      (p_api_name       => l_proc
20274      ,p_argument       => 'person_id'
20275      ,p_argument_value => p_person_id
20276      );
20277   --
20278   hr_api.mandatory_arg_error
20279      (p_api_name       => l_proc
20280      ,p_argument       => 'effective_date'
20281      ,p_argument_value => l_effective_date
20282      );
20283   --
20284   -- Validate the person_id exists, if it does get the business group and
20285   -- legislation code.
20286   --
20287   open  csr_get_derived_details;
20288   fetch csr_get_derived_details
20289    into l_business_group_id
20290       , l_legislation_code, l_applicant_number, l_per_object_version_number;
20291   --
20292   if csr_get_derived_details%NOTFOUND then
20293     --
20294     close csr_get_derived_details;
20295     --
20296  if g_debug then
20297     hr_utility.set_location(l_proc, 15);
20298  end if;
20299     --
20300     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
20301     hr_utility.raise_error;
20302   end if;
20303   --
20304   close csr_get_derived_details;
20305   --
20306   -- Bug 2230915 - if p_people_group_id enters with
20307   -- a value then get segment values from pay_people_groups.
20308   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
20309   -- per_cagr_grades_def
20310   --
20311   --
20312  if g_debug then
20313   hr_utility.set_location(l_proc, 20);
20314  end if;
20315   --
20316   if l_people_group_id is not null
20317   then
20318      l_pgp_null_ind := 1;
20319      --
20320      open c_pgp_segments;
20321        fetch c_pgp_segments into l_pgp_segment1,
20322                                  l_pgp_segment2,
20323                                  l_pgp_segment3,
20324                                  l_pgp_segment4,
20325                                  l_pgp_segment5,
20326                                  l_pgp_segment6,
20327                                  l_pgp_segment7,
20328                                  l_pgp_segment8,
20329                                  l_pgp_segment9,
20330                                  l_pgp_segment10,
20331                                  l_pgp_segment11,
20332                                  l_pgp_segment12,
20333                                  l_pgp_segment13,
20334                                  l_pgp_segment14,
20335                                  l_pgp_segment15,
20336                                  l_pgp_segment16,
20337                                  l_pgp_segment17,
20338                                  l_pgp_segment18,
20339                                  l_pgp_segment19,
20340                                  l_pgp_segment20,
20341                                  l_pgp_segment21,
20342                                  l_pgp_segment22,
20343                                  l_pgp_segment23,
20344                                  l_pgp_segment24,
20345                                  l_pgp_segment25,
20346                                  l_pgp_segment26,
20347                                  l_pgp_segment27,
20348                                  l_pgp_segment28,
20349                                  l_pgp_segment29,
20350                                  l_pgp_segment30;
20351      close c_pgp_segments;
20352   else
20353      l_pgp_null_ind := 0;
20354   end if;
20355   --  use cursor c_scl_segments to bring back segment values if
20356   --  l_soft_coding_keyflex has a value.
20357   if l_soft_coding_keyflex_id is not null
20358   then
20359      l_scl_null_ind := 1;
20360      open c_scl_segments;
20361        fetch c_scl_segments into l_scl_segment1,
20362                                  l_scl_segment2,
20363                                  l_scl_segment3,
20364                                  l_scl_segment4,
20365                                  l_scl_segment5,
20366                                  l_scl_segment6,
20367                                  l_scl_segment7,
20368                                  l_scl_segment8,
20369                                  l_scl_segment9,
20370                                  l_scl_segment10,
20371                                  l_scl_segment11,
20372                                  l_scl_segment12,
20373                                  l_scl_segment13,
20374                                  l_scl_segment14,
20375                                  l_scl_segment15,
20376                                  l_scl_segment16,
20377                                  l_scl_segment17,
20378                                  l_scl_segment18,
20379                                  l_scl_segment19,
20380                                  l_scl_segment20,
20381                                  l_scl_segment21,
20382                                  l_scl_segment22,
20383                                  l_scl_segment23,
20384                                  l_scl_segment24,
20385                                  l_scl_segment25,
20386                                  l_scl_segment26,
20387                                  l_scl_segment27,
20388                                  l_scl_segment28,
20389                                  l_scl_segment29,
20390                                  l_scl_segment30;
20391      close c_scl_segments;
20392   else
20393      l_scl_null_ind := 0;
20394   end if;
20395   --
20396   -- if cagr_grade_def_id has a value then use it to get segment values using
20397   -- cursor cag_segments
20398   --
20399   if l_cagr_grade_def_id is not null
20400   then
20401      l_cag_null_ind := 1;
20402      open c_cag_segments;
20403        fetch c_cag_segments into l_cag_segment1,
20404                                  l_cag_segment2,
20405                                  l_cag_segment3,
20406                                  l_cag_segment4,
20407                                  l_cag_segment5,
20408                                  l_cag_segment6,
20409                                  l_cag_segment7,
20410                                  l_cag_segment8,
20411                                  l_cag_segment9,
20412                                  l_cag_segment10,
20413                                  l_cag_segment11,
20414                                  l_cag_segment12,
20415                                  l_cag_segment13,
20416                                  l_cag_segment14,
20417                                  l_cag_segment15,
20418                                  l_cag_segment16,
20419                                  l_cag_segment17,
20420                                  l_cag_segment18,
20421                                  l_cag_segment19,
20422                                  l_cag_segment20;
20423      close c_cag_segments;
20424   else
20425      l_cag_null_ind := 0;
20426   end if;
20427   --
20428   -- Start of API User Hook for the before hook of create_secondary_apl_asg.
20429   --
20430   begin
20431      hr_assignment_bk8.create_secondary_apl_asg_b
20432        (p_effective_date               =>     l_effective_date
20433        ,p_person_id                    =>     p_person_id
20434        ,p_organization_id              =>     p_organization_id
20435        ,p_recruiter_id                 =>     p_recruiter_id
20436        ,p_grade_id                     =>     p_grade_id
20437        ,p_position_id                  =>     p_position_id
20438        ,p_job_id                       =>     p_job_id
20439        ,p_payroll_id                   =>     p_payroll_id
20440        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
20441        ,p_location_id                  =>     p_location_id
20442        ,p_person_referred_by_id        =>     p_person_referred_by_id
20443        ,p_supervisor_id                =>     p_supervisor_id
20444        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
20445        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
20446        ,p_source_organization_id       =>     p_source_organization_id
20447        ,p_vacancy_id                   =>     p_vacancy_id
20448        ,p_pay_basis_id                 =>     p_pay_basis_id
20449        ,p_change_reason                =>     p_change_reason
20450        ,p_internal_address_line        =>     p_internal_address_line
20451        ,p_comments                     =>     p_comments
20452        ,p_date_probation_end           =>     l_date_probation_end
20453        ,p_default_code_comb_id         =>     p_default_code_comb_id
20454        ,p_employment_category          =>     p_employment_category
20455        ,p_frequency                    =>     p_frequency
20456        ,p_manager_flag                 =>     p_manager_flag
20457        ,p_normal_hours                 =>     p_normal_hours
20458        ,p_perf_review_period           =>     p_perf_review_period
20459        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
20460        ,p_probation_period             =>     p_probation_period
20461        ,p_probation_unit               =>     p_probation_unit
20462        ,p_sal_review_period            =>     p_sal_review_period
20463        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
20464        ,p_set_of_books_id              =>     p_set_of_books_id
20465        ,p_source_type                  =>     p_source_type
20466        ,p_time_normal_finish           =>     p_time_normal_finish
20467        ,p_time_normal_start            =>     p_time_normal_start
20468        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
20469        ,p_ass_attribute_category       =>     p_ass_attribute_category
20470        ,p_ass_attribute1               =>     p_ass_attribute1
20471        ,p_ass_attribute2               =>     p_ass_attribute2
20472        ,p_ass_attribute3               =>     p_ass_attribute3
20473        ,p_ass_attribute4               =>     p_ass_attribute4
20474        ,p_ass_attribute5               =>     p_ass_attribute5
20475        ,p_ass_attribute6               =>     p_ass_attribute6
20476        ,p_ass_attribute7               =>     p_ass_attribute7
20477        ,p_ass_attribute8               =>     p_ass_attribute8
20478        ,p_ass_attribute9               =>     p_ass_attribute9
20479        ,p_ass_attribute10              =>     p_ass_attribute10
20480        ,p_ass_attribute11              =>     p_ass_attribute11
20481        ,p_ass_attribute12              =>     p_ass_attribute12
20482        ,p_ass_attribute13              =>     p_ass_attribute13
20483        ,p_ass_attribute14              =>     p_ass_attribute14
20484        ,p_ass_attribute15              =>     p_ass_attribute15
20485        ,p_ass_attribute16              =>     p_ass_attribute16
20486        ,p_ass_attribute17              =>     p_ass_attribute17
20487        ,p_ass_attribute18              =>     p_ass_attribute18
20488        ,p_ass_attribute19              =>     p_ass_attribute19
20489        ,p_ass_attribute20              =>     p_ass_attribute20
20490        ,p_ass_attribute21              =>     p_ass_attribute21
20491        ,p_ass_attribute22              =>     p_ass_attribute22
20492        ,p_ass_attribute23              =>     p_ass_attribute23
20493        ,p_ass_attribute24              =>     p_ass_attribute24
20494        ,p_ass_attribute25              =>     p_ass_attribute25
20495        ,p_ass_attribute26              =>     p_ass_attribute26
20496        ,p_ass_attribute27              =>     p_ass_attribute27
20497        ,p_ass_attribute28              =>     p_ass_attribute28
20498        ,p_ass_attribute29              =>     p_ass_attribute29
20499        ,p_ass_attribute30              =>     p_ass_attribute30
20500        ,p_title                        =>     p_title
20501        --
20502        -- Bug 2230915
20503        -- Amended p_scl/pgp/cag_segments to be l_scl/pgp/cag_segments
20504        --
20505        ,p_scl_segment1                 =>     l_scl_segment1
20506        ,p_scl_segment2                 =>     l_scl_segment2
20507        ,p_scl_segment3                 =>     l_scl_segment3
20508        ,p_scl_segment4                 =>     l_scl_segment4
20509        ,p_scl_segment5                 =>     l_scl_segment5
20510        ,p_scl_segment6                 =>     l_scl_segment6
20511        ,p_scl_segment7                 =>     l_scl_segment7
20512        ,p_scl_segment8                 =>     l_scl_segment8
20513        ,p_scl_segment9                 =>     l_scl_segment9
20514        ,p_scl_segment10                =>     l_scl_segment10
20515        ,p_scl_segment11                =>     l_scl_segment11
20516        ,p_scl_segment12                =>     l_scl_segment12
20517        ,p_scl_segment13                =>     l_scl_segment13
20518        ,p_scl_segment14                =>     l_scl_segment14
20519        ,p_scl_segment15                =>     l_scl_segment15
20520        ,p_scl_segment16                =>     l_scl_segment16
20521        ,p_scl_segment17                =>     l_scl_segment17
20522        ,p_scl_segment18                =>     l_scl_segment18
20523        ,p_scl_segment19                =>     l_scl_segment19
20524        ,p_scl_segment20                =>     l_scl_segment20
20525        ,p_scl_segment21                =>     l_scl_segment21
20526        ,p_scl_segment22                =>     l_scl_segment22
20527        ,p_scl_segment23                =>     l_scl_segment23
20528        ,p_scl_segment24                =>     l_scl_segment24
20529        ,p_scl_segment25                =>     l_scl_segment25
20530        ,p_scl_segment26                =>     l_scl_segment26
20531        ,p_scl_segment27                =>     l_scl_segment27
20532        ,p_scl_segment28                =>     l_scl_segment28
20533        ,p_scl_segment29                =>     l_scl_segment29
20534        ,p_scl_segment30                =>     l_scl_segment30
20535        --
20536        -- Bug 944911
20537        -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
20538        --
20539        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
20540        ,p_pgp_segment1                 =>     l_pgp_segment1
20541        ,p_pgp_segment2                 =>     l_pgp_segment2
20542        ,p_pgp_segment3                 =>     l_pgp_segment3
20543        ,p_pgp_segment4                 =>     l_pgp_segment4
20544        ,p_pgp_segment5                 =>     l_pgp_segment5
20545        ,p_pgp_segment6                 =>     l_pgp_segment6
20546        ,p_pgp_segment7                 =>     l_pgp_segment7
20547        ,p_pgp_segment8                 =>     l_pgp_segment8
20548        ,p_pgp_segment9                 =>     l_pgp_segment9
20549        ,p_pgp_segment10                =>     l_pgp_segment10
20550        ,p_pgp_segment11                =>     l_pgp_segment11
20551        ,p_pgp_segment12                =>     l_pgp_segment12
20552        ,p_pgp_segment13                =>     l_pgp_segment13
20553        ,p_pgp_segment14                =>     l_pgp_segment14
20554        ,p_pgp_segment15                =>     l_pgp_segment15
20555        ,p_pgp_segment16                =>     l_pgp_segment16
20556        ,p_pgp_segment17                =>     l_pgp_segment17
20557        ,p_pgp_segment18                =>     l_pgp_segment18
20558        ,p_pgp_segment19                =>     l_pgp_segment19
20559        ,p_pgp_segment20                =>     l_pgp_segment20
20560        ,p_pgp_segment21                =>     l_pgp_segment21
20561        ,p_pgp_segment22                =>     l_pgp_segment22
20562        ,p_pgp_segment23                =>     l_pgp_segment23
20563        ,p_pgp_segment24                =>     l_pgp_segment24
20564        ,p_pgp_segment25                =>     l_pgp_segment25
20565        ,p_pgp_segment26                =>     l_pgp_segment26
20566        ,p_pgp_segment27                =>     l_pgp_segment27
20567        ,p_pgp_segment28                =>     l_pgp_segment28
20568        ,p_pgp_segment29                =>     l_pgp_segment29
20569        ,p_pgp_segment30                =>     l_pgp_segment30
20570        --
20571        -- Bug 944911
20572        -- Amended p_group_name to be p_concat_segments
20573        --
20574        ,p_concat_segments              => l_old_group_name
20575        ,p_business_group_id            => l_business_group_id
20576        ,p_contract_id                  => p_contract_id
20577        ,p_establishment_id             => p_establishment_id
20578        ,p_collective_agreement_id      => p_collective_agreement_id
20579        ,p_cagr_id_flex_num             => p_cagr_id_flex_num
20580        ,p_cag_segment1                 => l_cag_segment1
20581        ,p_cag_segment2                 => l_cag_segment2
20582        ,p_cag_segment3                 => l_cag_segment3
20583        ,p_cag_segment4                 => l_cag_segment4
20584        ,p_cag_segment5                 => l_cag_segment5
20585        ,p_cag_segment6                 => l_cag_segment6
20586        ,p_cag_segment7                 => l_cag_segment7
20587        ,p_cag_segment8                 => l_cag_segment8
20588        ,p_cag_segment9                 => l_cag_segment9
20589        ,p_cag_segment10                => l_cag_segment10
20590        ,p_cag_segment11                => l_cag_segment11
20591        ,p_cag_segment12                => l_cag_segment12
20592        ,p_cag_segment13                => l_cag_segment13
20593        ,p_cag_segment14                => l_cag_segment14
20594        ,p_cag_segment15                => l_cag_segment15
20595        ,p_cag_segment16                => l_cag_segment16
20596        ,p_cag_segment17                => l_cag_segment17
20597        ,p_cag_segment18                => l_cag_segment18
20598        ,p_cag_segment19                => l_cag_segment19
20599        ,p_cag_segment20                => l_cag_segment20
20600        ,p_notice_period		       => p_notice_period
20601        ,p_notice_period_uom	       => p_notice_period_uom
20602        ,p_employee_category	       => p_employee_category
20603        ,p_work_at_home		       => p_work_at_home
20604        ,p_job_post_source_name	       => p_job_post_source_name
20605        ,p_applicant_rank               => p_applicant_rank
20606        ,p_posting_content_id           => p_posting_content_id
20607        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
20608        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
20609        );
20610   exception
20611      when hr_api.cannot_find_prog_unit then
20612        hr_api.cannot_find_prog_unit_error
20613          (p_module_name       => 'CREATE_SECONDARY_APL_ASG',
20614           p_hook_type         => 'BP'
20615          );
20616   end;
20617   --
20618   --
20619  if g_debug then
20620   hr_utility.set_location(l_proc, 20);
20621  end if;
20622   --
20623   -- Process Logic
20624   --
20625   -- Get the application_id from an existing applicant assignment for the
20626   -- person specified. If no applicant assignment exists then this person
20627   -- cannot be an applicant.
20628   --
20629   -- 3652025 >>
20630   --open  csr_get_apl_asg;
20631   --fetch csr_get_apl_asg
20632    --into l_application_id;
20633   --
20634   open csr_get_application;
20635   fetch csr_get_application into l_application_id, l_appl_date_end;
20636 
20637   if csr_get_application%NOTFOUND then
20638     --
20639     close csr_get_application;
20640     --
20641     if g_debug then
20642        hr_utility.set_location(l_proc, 25);
20643     end if;
20644     --
20645     hr_utility.set_message(801,'HR_51231_ASG_MISSING_ASG');
20646     hr_utility.raise_error;
20647   end if;
20648   --
20649   close csr_get_application;
20650   -- <<
20651  if g_debug then
20652   hr_utility.set_location(l_proc, 30);
20653  end if;
20654   --
20655   --
20656   -- insert the profile options and effective date for the flexfield
20657   -- validation to work
20658   --
20659   --
20660   hr_kflex_utility.set_profiles
20661   (p_business_group_id => l_business_group_id
20662   ,p_assignment_id     => l_assignment_id
20663   ,p_organization_id   => p_organization_id
20664   ,p_location_id       => p_location_id);
20665   --
20666   hr_kflex_utility.set_session_date
20667   (p_effective_date => l_effective_date
20668   ,p_session_id     => l_session_id);
20669   --
20670   -- Maintain the people group key flexfields.
20671   --
20672   open csr_grp_idsel;
20673   fetch csr_grp_idsel
20674   into l_flex_num;
20675      if csr_grp_idsel%NOTFOUND then
20676        close csr_grp_idsel;
20677           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
20678           hr_utility.set_message_token('PROCEDURE', l_proc);
20679           hr_utility.set_message_token('STEP','10');
20680           hr_utility.raise_error;
20681      end if;
20682   close csr_grp_idsel;
20683   --
20684   --
20685   -- Maintain the people group key flexfields.
20686   --
20687   open csr_grp_idsel;
20688   fetch csr_grp_idsel
20689   into l_flex_num;
20690      if csr_grp_idsel%NOTFOUND then
20691        close csr_grp_idsel;
20692           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
20693           hr_utility.set_message_token('PROCEDURE', l_proc);
20694           hr_utility.set_message_token('STEP','10');
20695           hr_utility.raise_error;
20696      end if;
20697   close csr_grp_idsel;
20698   --
20699   -- Bug 2230915 - if key flex parameters have a value then derive segment
20700   -- values from them
20701   --
20702   if l_people_group_id is null
20703   then
20704      --
20705      hr_kflex_utility.upd_or_sel_keyflex_comb
20706        (p_appl_short_name        => 'PAY'
20707        ,p_flex_code              => 'GRP'
20708        ,p_flex_num               => l_flex_num
20709        ,p_segment1               => l_pgp_segment1
20710        ,p_segment2               => l_pgp_segment2
20711        ,p_segment3               => l_pgp_segment3
20712        ,p_segment4               => l_pgp_segment4
20713        ,p_segment5               => l_pgp_segment5
20714        ,p_segment6               => l_pgp_segment6
20715        ,p_segment7               => l_pgp_segment7
20716        ,p_segment8               => l_pgp_segment8
20717        ,p_segment9               => l_pgp_segment9
20718        ,p_segment10              => l_pgp_segment10
20719        ,p_segment11              => l_pgp_segment11
20720        ,p_segment12              => l_pgp_segment12
20721        ,p_segment13              => l_pgp_segment13
20722        ,p_segment14              => l_pgp_segment14
20723        ,p_segment15              => l_pgp_segment15
20724        ,p_segment16              => l_pgp_segment16
20725        ,p_segment17              => l_pgp_segment17
20726        ,p_segment18              => l_pgp_segment18
20727        ,p_segment19              => l_pgp_segment19
20728        ,p_segment20              => l_pgp_segment20
20729        ,p_segment21              => l_pgp_segment21
20730        ,p_segment22              => l_pgp_segment22
20731        ,p_segment23              => l_pgp_segment23
20732        ,p_segment24              => l_pgp_segment24
20733        ,p_segment25              => l_pgp_segment25
20734        ,p_segment26              => l_pgp_segment26
20735        ,p_segment27              => l_pgp_segment27
20736        ,p_segment28              => l_pgp_segment28
20737        ,p_segment29              => l_pgp_segment29
20738        ,p_segment30              => l_pgp_segment30
20739        ,p_concat_segments_in     => l_old_group_name
20740        ,p_ccid                   => l_people_group_id
20741        ,p_concat_segments_out    => l_group_name
20742        );
20743   end if;
20744   --
20745   -- update the combinations column
20746   --
20747   update_pgp_concat_segs
20748     (p_people_group_id        => l_people_group_id
20749     ,p_group_name             => l_group_name
20750     );
20751   --
20752   -- select or insert the Collective Agreement grade
20753   --
20754  if g_debug then
20755   hr_utility.set_location(l_proc, 36);
20756  end if;
20757   --
20758   if l_cagr_grade_def_id is null
20759   then
20760      hr_cgd_ins.ins_or_sel
20761      (p_segment1               => l_cag_segment1
20762      ,p_segment2               => l_cag_segment2
20763      ,p_segment3               => l_cag_segment3
20764      ,p_segment4               => l_cag_segment4
20765      ,p_segment5               => l_cag_segment5
20766      ,p_segment6               => l_cag_segment6
20767      ,p_segment7               => l_cag_segment7
20768      ,p_segment8               => l_cag_segment8
20769      ,p_segment9               => l_cag_segment9
20770      ,p_segment10              => l_cag_segment10
20771      ,p_segment11              => l_cag_segment11
20772      ,p_segment12              => l_cag_segment12
20773      ,p_segment13              => l_cag_segment13
20774      ,p_segment14              => l_cag_segment14
20775      ,p_segment15              => l_cag_segment15
20776      ,p_segment16              => l_cag_segment16
20777      ,p_segment17              => l_cag_segment17
20778      ,p_segment18              => l_cag_segment18
20779      ,p_segment19              => l_cag_segment19
20780      ,p_segment20              => l_cag_segment20
20781      ,p_id_flex_num            => p_cagr_id_flex_num
20782      ,p_business_group_id      => l_business_group_id
20783      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
20784      ,p_concatenated_segments  => l_cagr_concatenated_segments
20785       );
20786   end if;
20787      --
20788   if l_soft_coding_keyflex_id is null
20789   then
20790      --
20791      if   l_scl_segment1 is not null
20792        or l_scl_segment2 is not null
20793        or l_scl_segment3 is not null
20794        or l_scl_segment4 is not null
20795        or l_scl_segment5 is not null
20796        or l_scl_segment6 is not null
20797        or l_scl_segment7 is not null
20798        or l_scl_segment8 is not null
20799        or l_scl_segment9 is not null
20800        or l_scl_segment10 is not null
20801        or l_scl_segment11 is not null
20802        or l_scl_segment12 is not null
20803        or l_scl_segment13 is not null
20804        or l_scl_segment14 is not null
20805        or l_scl_segment15 is not null
20806        or l_scl_segment16 is not null
20807        or l_scl_segment17 is not null
20808        or l_scl_segment18 is not null
20809        or l_scl_segment19 is not null
20810        or l_scl_segment20 is not null
20811        or l_scl_segment21 is not null
20812        or l_scl_segment22 is not null
20813        or l_scl_segment23 is not null
20814        or l_scl_segment24 is not null
20815        or l_scl_segment25 is not null
20816        or l_scl_segment26 is not null
20817        or l_scl_segment27 is not null
20818        or l_scl_segment28 is not null
20819        or l_scl_segment29 is not null
20820        or l_scl_segment30 is not null
20821        --
20822        -- bug 944911
20823        -- Added this additional check
20824        --
20825        or p_scl_concat_segments is not null
20826      then
20827         open csr_scl_idsel;
20828         fetch csr_scl_idsel into l_flex_num;
20829         if csr_scl_idsel%NOTFOUND
20830         then
20831            close csr_scl_idsel;
20832  if g_debug then
20833            hr_utility.set_location(l_proc, 28);
20834  end if;
20835            --
20836            hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
20837            hr_utility.set_message_token('PROCEDURE', l_proc);
20838            hr_utility.set_message_token('STEP','10');
20839            hr_utility.raise_error;
20840         else
20841            close csr_scl_idsel;
20842            --
20843            --
20844  if g_debug then
20845            hr_utility.set_location(l_proc, 30);
20846  end if;
20847            --
20848            -- Insert or select the soft_coding_keyflex_id
20849            --
20850            hr_kflex_utility.ins_or_sel_keyflex_comb
20851            (p_appl_short_name        => 'PER'
20852            ,p_flex_code              => 'SCL'
20853            ,p_flex_num               => l_flex_num
20854            ,p_segment1               => l_scl_segment1
20855            ,p_segment2               => l_scl_segment2
20856            ,p_segment3               => l_scl_segment3
20857            ,p_segment4               => l_scl_segment4
20858            ,p_segment5               => l_scl_segment5
20859            ,p_segment6               => l_scl_segment6
20860            ,p_segment7               => l_scl_segment7
20861            ,p_segment8               => l_scl_segment8
20862            ,p_segment9               => l_scl_segment9
20863            ,p_segment10              => l_scl_segment10
20864            ,p_segment11              => l_scl_segment11
20865            ,p_segment12              => l_scl_segment12
20866            ,p_segment13              => l_scl_segment13
20867            ,p_segment14              => l_scl_segment14
20868            ,p_segment15              => l_scl_segment15
20869            ,p_segment16              => l_scl_segment16
20870            ,p_segment17              => l_scl_segment17
20871            ,p_segment18              => l_scl_segment18
20872            ,p_segment19              => l_scl_segment19
20873            ,p_segment20              => l_scl_segment20
20874            ,p_segment21              => l_scl_segment21
20875            ,p_segment22              => l_scl_segment22
20876            ,p_segment23              => l_scl_segment23
20877            ,p_segment24              => l_scl_segment24
20878            ,p_segment25              => l_scl_segment25
20879            ,p_segment26              => l_scl_segment26
20880            ,p_segment27              => l_scl_segment27
20881            ,p_segment28              => l_scl_segment28
20882            ,p_segment29              => l_scl_segment29
20883            ,p_segment30              => l_scl_segment30
20884            ,p_concat_segments_in     => l_old_scl_conc_segments
20885            ,p_ccid                   => l_soft_coding_keyflex_id
20886            ,p_concat_segments_out    => l_scl_concatenated_segments
20887            );
20888            --
20889            -- update the combinations column
20890            --
20891            update_scl_concat_segs
20892            (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
20893            ,p_concatenated_segments   => l_scl_concatenated_segments
20894            );
20895         --
20896        end if;
20897      --
20898     end if;
20899    --
20900   end if;
20901   --
20902  if g_debug then
20903   hr_utility.set_location(l_proc, 35);
20904  end if;
20905   --
20906   -- 3652025: if application is end dated then call internal procedure
20907   --
20908   if l_appl_date_end is not null then
20909   --
20910   -- Application is end dated
20911   --
20912       if g_debug then
20913         hr_utility.set_location(l_proc, 40);
20914       end if;
20915 
20916       hr_applicant_internal.create_applicant_anytime
20917         (p_effective_date                => l_effective_date
20918         ,p_person_id                     => p_person_id
20919         ,p_applicant_number              => l_applicant_number
20920         ,p_per_object_version_number     => l_per_object_version_number
20921         ,p_vacancy_id                    => p_vacancy_id
20922         ,p_person_type_id                => null
20923         ,p_assignment_status_type_id     => p_assignment_status_type_id
20924         ,p_application_id                => l_application_id
20925         ,p_assignment_id                 => l_assignment_id
20926         ,p_apl_object_version_number     => l_apl_object_version_number
20927         ,p_asg_object_version_number     => l_object_version_number
20928         ,p_assignment_sequence           => l_assignment_sequence
20929         ,p_per_effective_start_date      => l_per_effective_start_date
20930         ,p_per_effective_end_date        => l_per_effective_end_date
20931         ,p_appl_override_warning         => l_appl_override_warning
20932         );
20933 
20934       if g_debug then
20935         hr_utility.set_location(l_proc, 45);
20936       end if;
20937       --
20938       -- 3972045: If p_assignment_status_type_id is null, derive default status for
20939       -- person's business group.
20940       --
20941       if p_assignment_status_type_id is null then
20942          per_people3_pkg.get_default_person_type
20943            (p_required_type     => 'ACTIVE_APL'
20944            ,p_business_group_id => l_business_group_id
20945            ,p_legislation_code  => l_legislation_code
20946            ,p_person_type       => l_assignment_status_type_id
20947           );
20948       else
20949          l_assignment_status_type_id := p_assignment_status_type_id;
20950       end if;
20951       --
20952       hr_assignment_api.update_apl_asg
20953             (p_validate                    => FALSE
20954             ,p_effective_date              => l_effective_date
20955             ,p_datetrack_update_mode       => hr_api.g_correction
20956             ,p_assignment_id               => l_assignment_id
20957             ,p_object_version_number       => l_object_version_number
20958             ,p_recruiter_id                => p_recruiter_id
20959             ,p_grade_id                    => p_grade_id
20960             ,p_position_id                 => p_position_id
20961             ,p_job_id                      => p_job_id
20962             ,p_payroll_id                  => p_payroll_id
20963             ,p_location_id                 => p_location_id
20964             ,p_person_referred_by_id       => p_person_referred_by_id
20965             ,p_supervisor_id               => p_supervisor_id
20966             ,p_special_ceiling_step_id     => p_special_ceiling_step_id
20967             ,p_recruitment_activity_id     => p_recruitment_activity_id
20968             ,p_source_organization_id      => p_source_organization_id
20969             ,p_organization_id             => p_organization_id
20970             ,p_vacancy_id                  => p_vacancy_id
20971             ,p_pay_basis_id                => p_pay_basis_id
20972             ,p_application_id              => l_application_id
20973             ,p_change_reason               => p_change_reason
20974             ,p_assignment_status_type_id   => l_assignment_status_type_id
20975             ,p_comments                    => p_comments
20976             ,p_date_probation_end          => l_date_probation_end
20977             ,p_default_code_comb_id        => p_default_code_comb_id
20978             ,p_employment_category         => p_employment_category
20979             ,p_frequency                    => p_frequency
20980             ,p_internal_address_line        => p_internal_address_line
20981             ,p_manager_flag                 => p_manager_flag
20982             ,p_normal_hours                 => p_normal_hours
20983             ,p_perf_review_period           => p_perf_review_period
20984             ,p_perf_review_period_frequency => p_perf_review_period_frequency
20985             ,p_probation_period             => p_probation_period
20986             ,p_probation_unit               => p_probation_unit
20987             ,p_sal_review_period            => p_sal_review_period
20988             ,p_sal_review_period_frequency  => p_sal_review_period_frequency
20989             ,p_set_of_books_id              => p_set_of_books_id
20990             ,p_source_type                  => p_source_type
20991             ,p_time_normal_finish           => p_time_normal_finish
20992             ,p_time_normal_start            => p_time_normal_start
20993             ,p_bargaining_unit_code         => p_bargaining_unit_code
20994             ,p_ass_attribute_category       => p_ass_attribute_category
20995             ,p_ass_attribute1               => p_ass_attribute1
20996             ,p_ass_attribute2               => p_ass_attribute2
20997             ,p_ass_attribute3               => p_ass_attribute3
20998             ,p_ass_attribute4               => p_ass_attribute4
20999             ,p_ass_attribute5               => p_ass_attribute5
21000             ,p_ass_attribute6               => p_ass_attribute6
21001             ,p_ass_attribute7               => p_ass_attribute7
21002             ,p_ass_attribute8               => p_ass_attribute8
21003             ,p_ass_attribute9               => p_ass_attribute9
21004             ,p_ass_attribute10              => p_ass_attribute10
21005             ,p_ass_attribute11              => p_ass_attribute11
21006             ,p_ass_attribute12              => p_ass_attribute12
21007             ,p_ass_attribute13              => p_ass_attribute13
21008             ,p_ass_attribute14              => p_ass_attribute14
21009             ,p_ass_attribute15              => p_ass_attribute15
21010             ,p_ass_attribute16              => p_ass_attribute16
21011             ,p_ass_attribute17              => p_ass_attribute17
21012             ,p_ass_attribute18              => p_ass_attribute18
21013             ,p_ass_attribute19              => p_ass_attribute19
21014             ,p_ass_attribute20              => p_ass_attribute20
21015             ,p_ass_attribute21              => p_ass_attribute21
21016             ,p_ass_attribute22              => p_ass_attribute22
21017             ,p_ass_attribute23              => p_ass_attribute23
21018             ,p_ass_attribute24              => p_ass_attribute24
21019             ,p_ass_attribute25              => p_ass_attribute25
21020             ,p_ass_attribute26              => p_ass_attribute26
21021             ,p_ass_attribute27              => p_ass_attribute27
21022             ,p_ass_attribute28              => p_ass_attribute28
21023             ,p_ass_attribute29              => p_ass_attribute29
21024             ,p_ass_attribute30              => p_ass_attribute30
21025             ,p_scl_segment1                 =>     l_scl_segment1
21026             ,p_scl_segment2                 =>     l_scl_segment2
21027             ,p_scl_segment3                 =>     l_scl_segment3
21028             ,p_scl_segment4                 =>     l_scl_segment4
21029             ,p_scl_segment5                 =>     l_scl_segment5
21030             ,p_scl_segment6                 =>     l_scl_segment6
21031             ,p_scl_segment7                 =>     l_scl_segment7
21032             ,p_scl_segment8                 =>     l_scl_segment8
21033             ,p_scl_segment9                 =>     l_scl_segment9
21034             ,p_scl_segment10                =>     l_scl_segment10
21035             ,p_scl_segment11                =>     l_scl_segment11
21036             ,p_scl_segment12                =>     l_scl_segment12
21037             ,p_scl_segment13                =>     l_scl_segment13
21038             ,p_scl_segment14                =>     l_scl_segment14
21039             ,p_scl_segment15                =>     l_scl_segment15
21040             ,p_scl_segment16                =>     l_scl_segment16
21041             ,p_scl_segment17                =>     l_scl_segment17
21042             ,p_scl_segment18                =>     l_scl_segment18
21043             ,p_scl_segment19                =>     l_scl_segment19
21044             ,p_scl_segment20                =>     l_scl_segment20
21045             ,p_scl_segment21                =>     l_scl_segment21
21046             ,p_scl_segment22                =>     l_scl_segment22
21047             ,p_scl_segment23                =>     l_scl_segment23
21048             ,p_scl_segment24                =>     l_scl_segment24
21049             ,p_scl_segment25                =>     l_scl_segment25
21050             ,p_scl_segment26                =>     l_scl_segment26
21051             ,p_scl_segment27                =>     l_scl_segment27
21052             ,p_scl_segment28                => l_scl_segment28
21053             ,p_scl_segment29                => l_scl_segment29
21054             ,p_scl_segment30                => l_scl_segment30
21055             ,p_scl_concat_segments          => l_old_scl_conc_segments
21056             ,p_concatenated_segments        => l_scl_concatenated_segments
21057             ,p_pgp_segment1                 =>     l_pgp_segment1
21058             ,p_pgp_segment2                 =>     l_pgp_segment2
21059             ,p_pgp_segment3                 =>     l_pgp_segment3
21060             ,p_pgp_segment4                 =>     l_pgp_segment4
21061             ,p_pgp_segment5                 =>     l_pgp_segment5
21062             ,p_pgp_segment6                 =>     l_pgp_segment6
21063             ,p_pgp_segment7                 =>     l_pgp_segment7
21064             ,p_pgp_segment8                 =>     l_pgp_segment8
21065             ,p_pgp_segment9                 =>     l_pgp_segment9
21066             ,p_pgp_segment10                =>     l_pgp_segment10
21067             ,p_pgp_segment11                =>     l_pgp_segment11
21068             ,p_pgp_segment12                =>     l_pgp_segment12
21069             ,p_pgp_segment13                =>     l_pgp_segment13
21070             ,p_pgp_segment14                =>     l_pgp_segment14
21071             ,p_pgp_segment15                =>     l_pgp_segment15
21072             ,p_pgp_segment16                =>     l_pgp_segment16
21073             ,p_pgp_segment17                =>     l_pgp_segment17
21074             ,p_pgp_segment18                =>     l_pgp_segment18
21075             ,p_pgp_segment19                =>     l_pgp_segment19
21076             ,p_pgp_segment20                =>     l_pgp_segment20
21077             ,p_pgp_segment21                =>     l_pgp_segment21
21078             ,p_pgp_segment22                =>     l_pgp_segment22
21079             ,p_pgp_segment23                =>     l_pgp_segment23
21080             ,p_pgp_segment24                =>     l_pgp_segment24
21081             ,p_pgp_segment25                =>     l_pgp_segment25
21082             ,p_pgp_segment26                =>     l_pgp_segment26
21083             ,p_pgp_segment27                =>     l_pgp_segment27
21084             ,p_pgp_segment28                =>     l_pgp_segment28
21085             ,p_pgp_segment29                =>     l_pgp_segment29
21086             ,p_pgp_segment30                =>     l_pgp_segment30
21087             ,p_concat_segments              => l_old_group_name
21088             ,p_contract_id                  => p_contract_id
21089             ,p_establishment_id             => p_establishment_id
21090             ,p_collective_agreement_id      => p_collective_agreement_id
21091             ,p_cagr_id_flex_num             => p_cagr_id_flex_num
21092             ,p_cag_segment1                 => l_cag_segment1
21093             ,p_cag_segment2                 => l_cag_segment2
21094             ,p_cag_segment3                 => l_cag_segment3
21095             ,p_cag_segment4                 => l_cag_segment4
21096             ,p_cag_segment5                 => l_cag_segment5
21097             ,p_cag_segment6                 => l_cag_segment6
21098             ,p_cag_segment7                 => l_cag_segment7
21099             ,p_cag_segment8                 => l_cag_segment8
21100             ,p_cag_segment9                 => l_cag_segment9
21101             ,p_cag_segment10                => l_cag_segment10
21102             ,p_cag_segment11                => l_cag_segment11
21103             ,p_cag_segment12                => l_cag_segment12
21104             ,p_cag_segment13                => l_cag_segment13
21105             ,p_cag_segment14                => l_cag_segment14
21106             ,p_cag_segment15                => l_cag_segment15
21107             ,p_cag_segment16                => l_cag_segment16
21108             ,p_cag_segment17                => l_cag_segment17
21109             ,p_cag_segment18                => l_cag_segment18
21110             ,p_cag_segment19                => l_cag_segment19
21111             ,p_cag_segment20                => l_cag_segment20
21112             ,p_title                        => p_title
21113             ,p_notice_period                    => p_notice_period
21114             ,p_notice_period_uom                => p_notice_period_uom
21115             ,p_employee_category                => p_employee_category
21116             ,p_work_at_home                         => p_work_at_home
21117             ,p_job_post_source_name             => p_job_post_source_name
21118             ,p_cagr_grade_def_id            => l_cagr_grade_def_id
21119             ,p_effective_start_date         => l_effective_start_date
21120             ,p_effective_end_date           => l_effective_end_date
21121             ,p_comment_id                   => l_comment_id
21122             ,p_applicant_rank               => p_applicant_rank
21123             ,p_posting_content_id           => p_posting_content_id
21124             ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
21125             ,p_supervisor_assignment_id     => p_supervisor_assignment_id
21126             ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
21127             ,p_group_name                   => l_group_name
21128             ,p_people_group_id              => l_people_group_id
21129             ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
21130          );
21131 
21132       if g_debug then
21133         hr_utility.set_location(l_proc, 50);
21134       end if;
21135   else -- application is not end dated
21136   --
21137   -- Insert secondary assignment
21138   --
21139     hr_assignment_internal.create_apl_asg
21140     (p_effective_date               => l_effective_date
21141     ,p_legislation_code             => l_legislation_code
21142     ,p_business_group_id            => l_business_group_id
21143     ,p_person_id                    => p_person_id
21144     ,p_organization_id              => p_organization_id
21145     ,p_application_id               => l_application_id
21146     ,p_recruiter_id                 => p_recruiter_id
21147     ,p_grade_id                     => p_grade_id
21148     ,p_position_id                  => p_position_id
21149     ,p_job_id                       => p_job_id
21150     ,p_assignment_status_type_id    => p_assignment_status_type_id
21151     ,p_payroll_id                   => p_payroll_id
21152     ,p_location_id                  => p_location_id
21153     ,p_person_referred_by_id        => p_person_referred_by_id
21154     ,p_supervisor_id                => p_supervisor_id
21155     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
21156     ,p_recruitment_activity_id      => p_recruitment_activity_id
21157     ,p_source_organization_id       => p_source_organization_id
21158     ,p_people_group_id              => l_people_group_id
21159     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
21160     ,p_vacancy_id                   => p_vacancy_id
21161     ,p_pay_basis_id                 => p_pay_basis_id
21162     ,p_change_reason                => p_change_reason
21163     ,p_comments                     => p_comments
21164     ,p_date_probation_end           => l_date_probation_end
21165     ,p_default_code_comb_id         => p_default_code_comb_id
21166     ,p_employment_category          => p_employment_category
21167     ,p_frequency                    => p_frequency
21168     ,p_internal_address_line        => p_internal_address_line
21169     ,p_manager_flag                 => p_manager_flag
21170     ,p_normal_hours                 => p_normal_hours
21171     ,p_perf_review_period           => p_perf_review_period
21172     ,p_perf_review_period_frequency => p_perf_review_period_frequency
21173     ,p_probation_period             => p_probation_period
21174     ,p_probation_unit               => p_probation_unit
21175     ,p_sal_review_period            => p_sal_review_period
21176     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
21177     ,p_set_of_books_id              => p_set_of_books_id
21178     ,p_source_type                  => p_source_type
21179     ,p_time_normal_finish           => p_time_normal_finish
21180     ,p_time_normal_start            => p_time_normal_start
21181     ,p_bargaining_unit_code         => p_bargaining_unit_code
21182     ,p_ass_attribute_category       => p_ass_attribute_category
21183     ,p_ass_attribute1               => p_ass_attribute1
21184     ,p_ass_attribute2               => p_ass_attribute2
21185     ,p_ass_attribute3               => p_ass_attribute3
21186     ,p_ass_attribute4               => p_ass_attribute4
21187     ,p_ass_attribute5               => p_ass_attribute5
21188     ,p_ass_attribute6               => p_ass_attribute6
21189     ,p_ass_attribute7               => p_ass_attribute7
21190     ,p_ass_attribute8               => p_ass_attribute8
21191     ,p_ass_attribute9               => p_ass_attribute9
21192     ,p_ass_attribute10              => p_ass_attribute10
21193     ,p_ass_attribute11              => p_ass_attribute11
21194     ,p_ass_attribute12              => p_ass_attribute12
21195     ,p_ass_attribute13              => p_ass_attribute13
21196     ,p_ass_attribute14              => p_ass_attribute14
21197     ,p_ass_attribute15              => p_ass_attribute15
21198     ,p_ass_attribute16              => p_ass_attribute16
21199     ,p_ass_attribute17              => p_ass_attribute17
21200     ,p_ass_attribute18              => p_ass_attribute18
21201     ,p_ass_attribute19              => p_ass_attribute19
21202     ,p_ass_attribute20              => p_ass_attribute20
21203     ,p_ass_attribute21              => p_ass_attribute21
21204     ,p_ass_attribute22              => p_ass_attribute22
21205     ,p_ass_attribute23              => p_ass_attribute23
21206     ,p_ass_attribute24              => p_ass_attribute24
21207     ,p_ass_attribute25              => p_ass_attribute25
21208     ,p_ass_attribute26              => p_ass_attribute26
21209     ,p_ass_attribute27              => p_ass_attribute27
21210     ,p_ass_attribute28              => p_ass_attribute28
21211     ,p_ass_attribute29              => p_ass_attribute29
21212     ,p_ass_attribute30              => p_ass_attribute30
21213     ,p_title                        => p_title
21214     ,p_contract_id                  => p_contract_id
21215     ,p_establishment_id             => p_establishment_id
21216     ,p_collective_agreement_id      => p_collective_agreement_id
21217     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
21218     ,p_notice_period		    => p_notice_period
21219     ,p_notice_period_uom	    => p_notice_period_uom
21220     ,p_employee_category	    => p_employee_category
21221     ,p_work_at_home		    => p_work_at_home
21222     ,p_job_post_source_name	    => p_job_post_source_name
21223     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
21224     ,p_assignment_id                => l_assignment_id
21225     ,p_object_version_number        => l_object_version_number
21226     ,p_effective_start_date         => l_effective_start_date
21227     ,p_effective_end_date           => l_effective_end_date
21228     ,p_assignment_sequence          => l_assignment_sequence
21229     ,p_comment_id                   => l_comment_id
21230     ,p_applicant_rank               => p_applicant_rank
21231     ,p_posting_content_id           => p_posting_content_id
21232     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
21233     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
21234     );
21235   --
21236  if g_debug then
21237   hr_utility.set_location(l_proc, 40);
21238  end if;
21239 
21240   end if; -- application is end dated?
21241   --
21242   -- add to the security list if neccesary
21243   --
21244   if(l_effective_date<=sysdate) then
21245     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
21246   end if;
21247   --
21248   --
21249   -- Start of API User Hook for the after hook of create_secondary_apl_asg.
21250   --
21251   begin
21252      hr_assignment_bk8.create_secondary_apl_asg_a
21253        (p_effective_date               =>     l_effective_date
21254        ,p_person_id                    =>     p_person_id
21255        ,p_organization_id              =>     p_organization_id
21256        ,p_recruiter_id                 =>     p_recruiter_id
21257        ,p_grade_id                     =>     p_grade_id
21258        ,p_position_id                  =>     p_position_id
21259        ,p_job_id                       =>     p_job_id
21260        ,p_payroll_id                   =>     p_payroll_id
21261        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21262        ,p_location_id                  =>     p_location_id
21263        ,p_person_referred_by_id        =>     p_person_referred_by_id
21264        ,p_supervisor_id                =>     p_supervisor_id
21265        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
21266        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
21267        ,p_source_organization_id       =>     p_source_organization_id
21268        ,p_vacancy_id                   =>     p_vacancy_id
21269        ,p_pay_basis_id                 =>     p_pay_basis_id
21270        ,p_change_reason                =>     p_change_reason
21271        ,p_internal_address_line        =>     p_internal_address_line
21272        ,p_comments                     =>     p_comments
21273        ,p_date_probation_end           =>     l_date_probation_end
21274        ,p_default_code_comb_id         =>     p_default_code_comb_id
21275        ,p_employment_category          =>     p_employment_category
21276        ,p_frequency                    =>     p_frequency
21277        ,p_manager_flag                 =>     p_manager_flag
21278        ,p_normal_hours                 =>     p_normal_hours
21279        ,p_perf_review_period           =>     p_perf_review_period
21280        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
21281        ,p_probation_period             =>     p_probation_period
21282        ,p_probation_unit               =>     p_probation_unit
21283        ,p_sal_review_period            =>     p_sal_review_period
21284        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
21285        ,p_set_of_books_id              =>     p_set_of_books_id
21286        ,p_source_type                  =>     p_source_type
21287        ,p_time_normal_finish           =>     p_time_normal_finish
21288        ,p_time_normal_start            =>     p_time_normal_start
21289        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
21290        ,p_ass_attribute_category       =>     p_ass_attribute_category
21291        ,p_ass_attribute1               =>     p_ass_attribute1
21292        ,p_ass_attribute2               =>     p_ass_attribute2
21293        ,p_ass_attribute3               =>     p_ass_attribute3
21294        ,p_ass_attribute4               =>     p_ass_attribute4
21295        ,p_ass_attribute5               =>     p_ass_attribute5
21296        ,p_ass_attribute6               =>     p_ass_attribute6
21297        ,p_ass_attribute7               =>     p_ass_attribute7
21298        ,p_ass_attribute8               =>     p_ass_attribute8
21299        ,p_ass_attribute9               =>     p_ass_attribute9
21300        ,p_ass_attribute10              =>     p_ass_attribute10
21301        ,p_ass_attribute11              =>     p_ass_attribute11
21302        ,p_ass_attribute12              =>     p_ass_attribute12
21303        ,p_ass_attribute13              =>     p_ass_attribute13
21304        ,p_ass_attribute14              =>     p_ass_attribute14
21305        ,p_ass_attribute15              =>     p_ass_attribute15
21306        ,p_ass_attribute16              =>     p_ass_attribute16
21307        ,p_ass_attribute17              =>     p_ass_attribute17
21308        ,p_ass_attribute18              =>     p_ass_attribute18
21309        ,p_ass_attribute19              =>     p_ass_attribute19
21310        ,p_ass_attribute20              =>     p_ass_attribute20
21311        ,p_ass_attribute21              =>     p_ass_attribute21
21312        ,p_ass_attribute22              =>     p_ass_attribute22
21313        ,p_ass_attribute23              =>     p_ass_attribute23
21314        ,p_ass_attribute24              =>     p_ass_attribute24
21315        ,p_ass_attribute25              =>     p_ass_attribute25
21316        ,p_ass_attribute26              =>     p_ass_attribute26
21317        ,p_ass_attribute27              =>     p_ass_attribute27
21318        ,p_ass_attribute28              =>     p_ass_attribute28
21319        ,p_ass_attribute29              =>     p_ass_attribute29
21320        ,p_ass_attribute30              =>     p_ass_attribute30
21321        ,p_title                        =>     p_title
21322        ,p_scl_segment1                 =>     l_scl_segment1
21323        ,p_scl_segment2                 =>     l_scl_segment2
21324        ,p_scl_segment3                 =>     l_scl_segment3
21325        ,p_scl_segment4                 =>     l_scl_segment4
21326        ,p_scl_segment5                 =>     l_scl_segment5
21327        ,p_scl_segment6                 =>     l_scl_segment6
21328        ,p_scl_segment7                 =>     l_scl_segment7
21329        ,p_scl_segment8                 =>     l_scl_segment8
21330        ,p_scl_segment9                 =>     l_scl_segment9
21331        ,p_scl_segment10                =>     l_scl_segment10
21332        ,p_scl_segment11                =>     l_scl_segment11
21333        ,p_scl_segment12                =>     l_scl_segment12
21334        ,p_scl_segment13                =>     l_scl_segment13
21335        ,p_scl_segment14                =>     l_scl_segment14
21336        ,p_scl_segment15                =>     l_scl_segment15
21337        ,p_scl_segment16                =>     l_scl_segment16
21338        ,p_scl_segment17                =>     l_scl_segment17
21339        ,p_scl_segment18                =>     l_scl_segment18
21340        ,p_scl_segment19                =>     l_scl_segment19
21341        ,p_scl_segment20                =>     l_scl_segment20
21342        ,p_scl_segment21                =>     l_scl_segment21
21343        ,p_scl_segment22                =>     l_scl_segment22
21344        ,p_scl_segment23                =>     l_scl_segment23
21345        ,p_scl_segment24                =>     l_scl_segment24
21346        ,p_scl_segment25                =>     l_scl_segment25
21347        ,p_scl_segment26                =>     l_scl_segment26
21348        ,p_scl_segment27                =>     l_scl_segment27
21349        ,p_scl_segment28                =>     l_scl_segment28
21350        ,p_scl_segment29                =>     l_scl_segment29
21351        ,p_scl_segment30                =>     l_scl_segment30
21352 -- Bug 944911
21353 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
21354        ,p_concatenated_segments        =>     l_scl_concatenated_segments
21355        ,p_pgp_segment1                 =>     l_pgp_segment1
21356        ,p_pgp_segment2                 =>     l_pgp_segment2
21357        ,p_pgp_segment3                 =>     l_pgp_segment3
21358        ,p_pgp_segment4                 =>     l_pgp_segment4
21359        ,p_pgp_segment5                 =>     l_pgp_segment5
21360        ,p_pgp_segment6                 =>     l_pgp_segment6
21361        ,p_pgp_segment7                 =>     l_pgp_segment7
21362        ,p_pgp_segment8                 =>     l_pgp_segment8
21363        ,p_pgp_segment9                 =>     l_pgp_segment9
21364        ,p_pgp_segment10                =>     l_pgp_segment10
21365        ,p_pgp_segment11                =>     l_pgp_segment11
21366        ,p_pgp_segment12                =>     l_pgp_segment12
21367        ,p_pgp_segment13                =>     l_pgp_segment13
21368        ,p_pgp_segment14                =>     l_pgp_segment14
21369        ,p_pgp_segment15                =>     l_pgp_segment15
21370        ,p_pgp_segment16                =>     l_pgp_segment16
21371        ,p_pgp_segment17                =>     l_pgp_segment17
21372        ,p_pgp_segment18                =>     l_pgp_segment18
21373        ,p_pgp_segment19                =>     l_pgp_segment19
21374        ,p_pgp_segment20                =>     l_pgp_segment20
21375        ,p_pgp_segment21                =>     l_pgp_segment21
21376        ,p_pgp_segment22                =>     l_pgp_segment22
21377        ,p_pgp_segment23                =>     l_pgp_segment23
21378        ,p_pgp_segment24                =>     l_pgp_segment24
21379        ,p_pgp_segment25                =>     l_pgp_segment25
21380        ,p_pgp_segment26                =>     l_pgp_segment26
21381        ,p_pgp_segment27                =>     l_pgp_segment27
21382        ,p_pgp_segment28                =>     l_pgp_segment28
21383        ,p_pgp_segment29                =>     l_pgp_segment29
21384        ,p_pgp_segment30                =>     l_pgp_segment30
21385        ,p_group_name                   =>     l_group_name
21386        ,p_assignment_id                =>     l_assignment_id
21387        ,p_object_version_number        =>     l_object_version_number
21388        ,p_effective_start_date         =>     l_effective_start_date
21389        ,p_effective_end_date           =>     l_effective_end_date
21390        ,p_assignment_sequence          =>     l_assignment_sequence
21391        ,p_comment_id                   =>     l_comment_id
21392        ,p_people_group_id              =>     l_people_group_id
21393        ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
21394        ,p_business_group_id            =>     l_business_group_id
21395        ,p_contract_id                  => p_contract_id
21396        ,p_establishment_id             => p_establishment_id
21397        ,p_collective_agreement_id      => p_collective_agreement_id
21398        ,p_cagr_id_flex_num             => p_cagr_id_flex_num
21399        ,p_cag_segment1                 => l_cag_segment1
21400        ,p_cag_segment2                 => l_cag_segment2
21401        ,p_cag_segment3                 => l_cag_segment3
21402        ,p_cag_segment4                 => l_cag_segment4
21403        ,p_cag_segment5                 => l_cag_segment5
21404        ,p_cag_segment6                 => l_cag_segment6
21405        ,p_cag_segment7                 => l_cag_segment7
21406        ,p_cag_segment8                 => l_cag_segment8
21407        ,p_cag_segment9                 => l_cag_segment9
21408        ,p_cag_segment10                => l_cag_segment10
21409        ,p_cag_segment11                => l_cag_segment11
21410        ,p_cag_segment12                => l_cag_segment12
21411        ,p_cag_segment13                => l_cag_segment13
21412        ,p_cag_segment14                => l_cag_segment14
21413        ,p_cag_segment15                => l_cag_segment15
21414        ,p_cag_segment16                => l_cag_segment16
21415        ,p_cag_segment17                => l_cag_segment17
21416        ,p_cag_segment18                => l_cag_segment18
21417        ,p_cag_segment19                => l_cag_segment19
21418        ,p_cag_segment20                => l_cag_segment20
21419        ,p_notice_period		       => p_notice_period
21420        ,p_notice_period_uom	       => p_notice_period_uom
21421        ,p_employee_category	       => p_employee_category
21422        ,p_work_at_home		       => p_work_at_home
21423        ,p_job_post_source_name	       => p_job_post_source_name
21424        ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
21425        ,p_cagr_grade_def_id            => l_cagr_grade_def_id
21426 -- Added the 2 new in params
21427 -- Bug 944911
21428 -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
21429        ,p_scl_concat_segments          => l_old_scl_conc_segments
21430 -- Bug 944911
21431 -- Amended p_group_name to be p_concat_segments
21432        ,p_concat_segments              => l_old_group_name
21433        ,p_applicant_rank               => p_applicant_rank
21434        ,p_posting_content_id           => p_posting_content_id
21435        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
21436        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
21437  );
21438   exception
21439      when hr_api.cannot_find_prog_unit then
21440        hr_api.cannot_find_prog_unit_error
21441          (p_module_name       => 'CREATE_SECONDARY_APL_ASG',
21442           p_hook_type         => 'AP'
21443          );
21444   end;
21445   --
21446   -- End of API User Hook for the after hook of create_secondary_apl_asg.
21447   --
21448   --
21449   -- When in validation only mode raise the Validate_Enabled exception
21450   --
21451   if p_validate then
21452     raise hr_api.validate_enabled;
21453   end if;
21454   --
21455   -- Set remaining output arguments
21456   --
21457   p_assignment_id          := l_assignment_id;
21458   p_people_group_id        := l_people_group_id;
21459   p_object_version_number  := l_object_version_number;
21460   p_effective_start_date   := l_effective_start_date;
21461   p_effective_end_date     := l_effective_end_date;
21462   p_assignment_sequence    := l_assignment_sequence;
21463   p_comment_id             := l_comment_id;
21464   p_group_name             := l_group_name;
21465   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
21466   p_appl_override_warning  := l_appl_override_warning; -- 3652025
21467 -- Bug 944911
21468 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
21469   p_concatenated_segments  := l_scl_concatenated_segments;
21470   p_cagr_grade_def_id           := l_cagr_grade_def_id;
21471   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
21472 
21473   --
21474   --
21475   -- remove data from the session table
21476   hr_kflex_utility.unset_session_date
21477     (p_session_id     => l_session_id);
21478   --
21479  if g_debug then
21480   hr_utility.set_location(' Leaving:'||l_proc, 50);
21481  end if;
21482 exception
21483   when hr_api.validate_enabled then
21484     --
21485     -- As the Validate_Enabled exception has been raised
21486     -- we must rollback to the savepoint
21487     --
21488     ROLLBACK TO create_secondary_apl_asg;
21489     --
21490     -- Only set output warning arguments
21491     -- (Any key or derived arguments must be set to null
21492     -- when validation only mode is being used.)
21493     --
21494     p_assignment_id          := null;
21495     p_object_version_number  := null;
21496     p_effective_start_date   := null;
21497     p_effective_end_date     := null;
21498     p_assignment_sequence    := null;
21499     p_comment_id             := null;
21500     --
21501     -- bug 2230915 only re-set to null if key flex ids came in as null.
21502     --
21503     if l_pgp_null_ind = 0
21504     then
21505        p_people_group_id           := null;
21506     end if;
21507     --
21508     p_group_name                   := l_old_group_name;
21509     --
21510     if l_scl_null_ind = 0
21511     then
21512        p_soft_coding_keyflex_id    := null;
21513     end if;
21514     --
21515     --Bug 944911
21516     p_concatenated_segments        := l_old_scl_conc_segments;
21517     --
21518     if l_cag_null_ind = 0
21519     then
21520        p_cagr_grade_def_id         := null;
21521     end if;
21522     --
21523     p_cagr_concatenated_segments   := null;
21524     --
21525   when others then
21526     --
21527     -- A validation or unexpected error has occurred
21528     --
21529     -- Added as part of fix to bug 632479
21530     --
21531 
21532     p_cagr_grade_def_id         := lv_cagr_grade_def_id ;
21533     p_people_group_id           := lv_people_group_id ;
21534     p_soft_coding_keyflex_id    := lv_people_group_id ;
21535 
21536     p_concatenated_segments           := null;
21537     p_cagr_concatenated_segments      := null;
21538     p_group_name                      := null;
21539     p_assignment_id                   := null;
21540     p_comment_id                      := null;
21541     p_object_version_number           := null;
21542     p_effective_start_date            := null;
21543     p_effective_end_date              := null;
21544     p_assignment_sequence             := null;
21545 
21546     ROLLBACK TO create_secondary_apl_asg;
21547     raise;
21548     --
21549     -- End of fix.
21550     --
21551 end create_secondary_apl_asg;
21552 --
21553 -- ----------------------------------------------------------------------------
21554 -- |---------------------< create_secondary_apl_asg >--R11---------------------|
21555 -- ----------------------------------------------------------------------------
21556 --
21557 procedure create_secondary_apl_asg
21558   (p_validate                     in     boolean
21559   ,p_effective_date               in     date
21560   ,p_person_id                    in     number
21561   ,p_organization_id              in     number
21562   ,p_recruiter_id                 in     number
21563   ,p_grade_id                     in     number
21564   ,p_position_id                  in     number
21565   ,p_job_id                       in     number
21566   ,p_assignment_status_type_id    in     number
21567   ,p_location_id                  in     number
21568   ,p_person_referred_by_id        in     number
21569   ,p_supervisor_id                in     number
21570   ,p_recruitment_activity_id      in     number
21571   ,p_source_organization_id       in     number
21572   ,p_vacancy_id                   in     number
21573   ,p_change_reason                in     varchar2
21574   ,p_comments                     in     varchar2
21575   ,p_date_probation_end           in     date
21576   ,p_frequency                    in     varchar2
21577   ,p_manager_flag                 in     varchar2
21578   ,p_normal_hours                 in     number
21579   ,p_probation_period             in     number
21580   ,p_probation_unit               in     varchar2
21581   ,p_source_type                  in     varchar2
21582   ,p_time_normal_finish           in     varchar2
21583   ,p_time_normal_start            in     varchar2
21584   ,p_ass_attribute_category       in     varchar2
21585   ,p_ass_attribute1               in     varchar2
21586   ,p_ass_attribute2               in     varchar2
21587   ,p_ass_attribute3               in     varchar2
21588   ,p_ass_attribute4               in     varchar2
21589   ,p_ass_attribute5               in     varchar2
21590   ,p_ass_attribute6               in     varchar2
21591   ,p_ass_attribute7               in     varchar2
21592   ,p_ass_attribute8               in     varchar2
21593   ,p_ass_attribute9               in     varchar2
21594   ,p_ass_attribute10              in     varchar2
21595   ,p_ass_attribute11              in     varchar2
21596   ,p_ass_attribute12              in     varchar2
21597   ,p_ass_attribute13              in     varchar2
21598   ,p_ass_attribute14              in     varchar2
21599   ,p_ass_attribute15              in     varchar2
21600   ,p_ass_attribute16              in     varchar2
21601   ,p_ass_attribute17              in     varchar2
21602   ,p_ass_attribute18              in     varchar2
21603   ,p_ass_attribute19              in     varchar2
21604   ,p_ass_attribute20              in     varchar2
21605   ,p_ass_attribute21              in     varchar2
21606   ,p_ass_attribute22              in     varchar2
21607   ,p_ass_attribute23              in     varchar2
21608   ,p_ass_attribute24              in     varchar2
21609   ,p_ass_attribute25              in     varchar2
21610   ,p_ass_attribute26              in     varchar2
21611   ,p_ass_attribute27              in     varchar2
21612   ,p_ass_attribute28              in     varchar2
21613   ,p_ass_attribute29              in     varchar2
21614   ,p_ass_attribute30              in     varchar2
21615   ,p_title                        in     varchar2
21616   ,p_segment1                     in     varchar2
21617   ,p_segment2                     in     varchar2
21618   ,p_segment3                     in     varchar2
21619   ,p_segment4                     in     varchar2
21620   ,p_segment5                     in     varchar2
21621   ,p_segment6                     in     varchar2
21622   ,p_segment7                     in     varchar2
21623   ,p_segment8                     in     varchar2
21624   ,p_segment9                     in     varchar2
21625   ,p_segment10                    in     varchar2
21626   ,p_segment11                    in     varchar2
21627   ,p_segment12                    in     varchar2
21628   ,p_segment13                    in     varchar2
21629   ,p_segment14                    in     varchar2
21630   ,p_segment15                    in     varchar2
21631   ,p_segment16                    in     varchar2
21632   ,p_segment17                    in     varchar2
21633   ,p_segment18                    in     varchar2
21634   ,p_segment19                    in     varchar2
21635   ,p_segment20                    in     varchar2
21636   ,p_segment21                    in     varchar2
21637   ,p_segment22                    in     varchar2
21638   ,p_segment23                    in     varchar2
21639   ,p_segment24                    in     varchar2
21640   ,p_segment25                    in     varchar2
21641   ,p_segment26                    in     varchar2
21642   ,p_segment27                    in     varchar2
21643   ,p_segment28                    in     varchar2
21644   ,p_segment29                    in     varchar2
21645   ,p_segment30                    in     varchar2
21646 -- Bug 944911
21647 -- Made p_group_name to be out param
21648 -- and add p_concat_segment to be IN
21649 -- in case of sec_asg alone made p_pgp_concat_segments as in param
21650 -- Reverting changes are it is for R11
21651   -- ,p_concat_segments              in     varchar2
21652   ,p_supervisor_assignment_id     in     number
21653   ,p_group_name                   in out nocopy varchar2
21654   ,p_assignment_id                   out nocopy number
21655   ,p_object_version_number           out nocopy number
21656   ,p_effective_start_date            out nocopy date
21657   ,p_effective_end_date              out nocopy date
21658   ,p_assignment_sequence             out nocopy number
21659   ,p_comment_id                      out nocopy number
21660   ,p_people_group_id                 out nocopy number
21661   ) is
21662   --
21663   -- Declare cursors and local variables
21664   --
21665   -- Out variables
21666   --
21667   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
21668   l_people_group_id        per_all_assignments_f.people_group_id%TYPE;
21669   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
21670   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
21671   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
21672   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
21673   l_comment_id             per_all_assignments_f.comment_id%TYPE;
21674   l_group_name             pay_people_groups.group_name%TYPE;
21675   l_flex_num	           fnd_id_flex_segments.id_flex_num%TYPE;
21676   l_application_id         per_applications.application_id%TYPE;
21677   l_business_group_id      per_business_groups.business_group_id%TYPE;
21678   l_legislation_code       per_business_groups.legislation_code%TYPE;
21679   l_period_of_service_id   per_all_assignments_f.period_of_service_id%TYPE;
21680   l_proc                   varchar2(72);
21681   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
21682   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
21683   l_effective_date         date;
21684   l_date_probation_end     date;
21685   l_cagr_concatenated_segments varchar2(3000);
21686   l_cagr_grade_def_id      number;
21687 
21688   --
21689 begin
21690   --
21691  if g_debug then
21692  l_proc := g_package||'create_secondary_apl_asg';
21693   hr_utility.set_location('Entering:'|| l_proc, 5);
21694  end if;
21695    -- Call the new code
21696 -- Bug 944911
21697 -- No change to call point as all outs are present while the ins have defaults
21698   hr_assignment_api.create_secondary_apl_asg(
21699    p_validate                     => p_validate
21700   ,p_effective_date               => p_effective_date
21701   ,p_person_id                    => p_person_id
21702   ,p_organization_id              => p_organization_id
21703   ,p_recruiter_id                 => p_recruiter_id
21704   ,p_grade_id                     => p_grade_id
21705   ,p_position_id                  => p_position_id
21706   ,p_job_id                       => p_job_id
21707   ,p_assignment_status_type_id    => p_assignment_status_type_id
21708   ,p_location_id                  => p_location_id
21709   ,p_person_referred_by_id        => p_person_referred_by_id
21710   ,p_supervisor_id                => p_supervisor_id
21711   ,p_recruitment_activity_id      => p_recruitment_activity_id
21712   ,p_source_organization_id       => p_source_organization_id
21713   ,p_vacancy_id                   => p_vacancy_id
21714   ,p_change_reason                => p_change_reason
21715   ,p_comments                     => p_comments
21716   ,p_date_probation_end           => p_date_probation_end
21717   ,p_frequency                    => p_frequency
21718   ,p_manager_flag                 => p_manager_flag
21719   ,p_normal_hours                 => p_normal_hours
21720   ,p_probation_period             => p_probation_period
21721   ,p_probation_unit               => p_probation_unit
21722   ,p_source_type                  => p_source_type
21723   ,p_time_normal_finish           => p_time_normal_finish
21724   ,p_time_normal_start            => p_time_normal_start
21725   ,p_ass_attribute_category       => p_ass_attribute_category
21726   ,p_ass_attribute1               => p_ass_attribute1
21727   ,p_ass_attribute2               => p_ass_attribute2
21728   ,p_ass_attribute3               => p_ass_attribute3
21729   ,p_ass_attribute4               => p_ass_attribute4
21730   ,p_ass_attribute5               => p_ass_attribute5
21731   ,p_ass_attribute6               => p_ass_attribute6
21732   ,p_ass_attribute7               => p_ass_attribute7
21733   ,p_ass_attribute8               => p_ass_attribute8
21734   ,p_ass_attribute9               => p_ass_attribute9
21735   ,p_ass_attribute10              => p_ass_attribute10
21736   ,p_ass_attribute11              => p_ass_attribute11
21737   ,p_ass_attribute12              => p_ass_attribute12
21738   ,p_ass_attribute13              => p_ass_attribute13
21739   ,p_ass_attribute14              => p_ass_attribute14
21740   ,p_ass_attribute15              => p_ass_attribute15
21741   ,p_ass_attribute16              => p_ass_attribute16
21742   ,p_ass_attribute17              => p_ass_attribute17
21743   ,p_ass_attribute18              => p_ass_attribute18
21744   ,p_ass_attribute19              => p_ass_attribute19
21745   ,p_ass_attribute20              => p_ass_attribute20
21746   ,p_ass_attribute21              => p_ass_attribute21
21747   ,p_ass_attribute22              => p_ass_attribute22
21748   ,p_ass_attribute23              => p_ass_attribute23
21749   ,p_ass_attribute24              => p_ass_attribute24
21750   ,p_ass_attribute25              => p_ass_attribute25
21751   ,p_ass_attribute26              => p_ass_attribute26
21752   ,p_ass_attribute27              => p_ass_attribute27
21753   ,p_ass_attribute28              => p_ass_attribute28
21754   ,p_ass_attribute29              => p_ass_attribute29
21755   ,p_ass_attribute30              => p_ass_attribute30
21756   ,p_title                        => p_title
21757   ,p_pgp_segment1                     => p_segment1
21758   ,p_pgp_segment2                     => p_segment2
21759   ,p_pgp_segment3                     => p_segment3
21760   ,p_pgp_segment4                     => p_segment4
21761   ,p_pgp_segment5                     => p_segment5
21762   ,p_pgp_segment6                     => p_segment6
21763   ,p_pgp_segment7                     => p_segment7
21764   ,p_pgp_segment8                     => p_segment8
21765   ,p_pgp_segment9                     => p_segment9
21766   ,p_pgp_segment10                    => p_segment10
21767   ,p_pgp_segment11                    => p_segment11
21768   ,p_pgp_segment12                    => p_segment12
21769   ,p_pgp_segment13                    => p_segment13
21770   ,p_pgp_segment14                    => p_segment14
21771   ,p_pgp_segment15                    => p_segment15
21772   ,p_pgp_segment16                    => p_segment16
21773   ,p_pgp_segment17                    => p_segment17
21774   ,p_pgp_segment18                    => p_segment18
21775   ,p_pgp_segment19                    => p_segment19
21776   ,p_pgp_segment20                    => p_segment20
21777   ,p_pgp_segment21                    => p_segment21
21778   ,p_pgp_segment22                    => p_segment22
21779   ,p_pgp_segment23                    => p_segment23
21780   ,p_pgp_segment24                    => p_segment24
21781   ,p_pgp_segment25                    => p_segment25
21782   ,p_pgp_segment26                    => p_segment26
21783   ,p_pgp_segment27                    => p_segment27
21784   ,p_pgp_segment28                    => p_segment28
21785   ,p_pgp_segment29                    => p_segment29
21786   ,p_pgp_segment30                    => p_segment30
21787   ,p_assignment_id                => l_assignment_id
21788   ,p_people_group_id              => l_people_group_id
21789   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
21790   ,p_comment_id                   => l_comment_id
21791   ,p_object_version_number        => l_object_version_number
21792   ,p_effective_start_date         => l_effective_start_date
21793   ,p_effective_end_date           => l_effective_end_date
21794   ,p_group_name                   => l_group_name
21795 -- Bug 944911
21796   ,p_concatenated_segments    => l_concatenated_segments
21797   ,p_assignment_sequence          => l_assignment_sequence
21798   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
21799   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
21800   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
21801   );
21802   -- Set remaining output arguments
21803   -- Ignore the new out parameters
21804   --
21805   p_assignment_id          := l_assignment_id;
21806   p_people_group_id        := l_people_group_id;
21807   p_object_version_number  := l_object_version_number;
21808   p_effective_start_date   := l_effective_start_date;
21809   p_effective_end_date     := l_effective_end_date;
21810   p_assignment_sequence    := l_assignment_sequence;
21811   p_comment_id             := l_comment_id;
21812   p_group_name             := l_group_name;
21813   --
21814  if g_debug then
21815   hr_utility.set_location(' Leaving:'||l_proc, 50);
21816  end if;
21817 end create_secondary_apl_asg;
21818 --
21819 -- ----------------------------------------------------------------------------
21820 -- |---------------------------< offer_apl_asg >------------------------------|
21821 -- ----------------------------------------------------------------------------
21822 --
21823 procedure offer_apl_asg
21824   (p_validate                     in     boolean
21825   ,p_effective_date               in     date
21826   ,p_datetrack_update_mode        in     varchar2
21827   ,p_assignment_id                in     number
21828   ,p_object_version_number        in out nocopy number
21829   ,p_assignment_status_type_id    in     number
21830   ,p_change_reason                in     varchar2
21831   ,p_effective_start_date            out nocopy date
21832   ,p_effective_end_date              out nocopy date
21833   ) is
21834   --
21835   -- Declare cursors and local variables
21836   --
21837   l_object_version_number_orig number;
21838   l_effective_date             date;
21839   --
21840   -- Out variables
21841   --
21842   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
21843   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
21844   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
21845   --
21846   lv_object_version_number     number := p_object_version_number ;
21847   --
21848   l_proc                 varchar2(72);
21849   --
21850 begin
21851  if g_debug then
21852   l_proc := g_package||'offer_apl_asg';
21853   hr_utility.set_location('Entering:'|| l_proc, 5);
21854  end if;
21855   --
21856   -- Initialise local variable - added 25-Aug-97. RMF.
21857   --
21858   l_effective_date := trunc(p_effective_date);
21859   --
21860   -- Issue a savepoint.
21861   --
21862   savepoint offer_apl_asg;
21863   --
21864   -- Preserve IN OUT parameters for later use
21865   --
21866   l_object_version_number_orig := p_object_version_number;
21867   l_object_version_number      := p_object_version_number;
21868   --
21869  if g_debug then
21870   hr_utility.set_location(l_proc, 10);
21871  end if;
21872   --
21873   -- Process Logic
21874   --
21875   --
21876   -- Start of API User Hook for the before hook of offer_apl_asg.
21877   --
21878   begin
21879      hr_assignment_bk9.offer_apl_asg_b
21880        (p_effective_date               =>     l_effective_date
21881        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21882        ,p_assignment_id                =>     p_assignment_id
21883        ,p_object_version_number        =>     p_object_version_number
21884        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21885        ,p_change_reason                =>     p_change_reason
21886        );
21887   exception
21888      when hr_api.cannot_find_prog_unit then
21889        hr_api.cannot_find_prog_unit_error
21890          (p_module_name       => 'OFFER_APL_ASG',
21891           p_hook_type         => 'BP'
21892          );
21893   end;
21894   --
21895   hr_assignment_internal.update_status_type_apl_asg
21896       (p_effective_date            => l_effective_date
21897       ,p_datetrack_update_mode     => p_datetrack_update_mode
21898       ,p_assignment_id             => p_assignment_id
21899       ,p_object_version_number     => l_object_version_number
21900       ,p_expected_system_status    => 'OFFER'
21901       ,p_assignment_status_type_id => p_assignment_status_type_id
21902       ,p_change_reason             => p_change_reason
21903       ,p_effective_start_date      => l_effective_start_date
21904       ,p_effective_end_date        => l_effective_end_date
21905       );
21906   --
21907  if g_debug then
21908   hr_utility.set_location(l_proc, 20);
21909  end if;
21910   --
21911   -- Start of API User Hook for the after hook of offer_apl_asg.
21912   --
21913   begin
21914      hr_assignment_bk9.offer_apl_asg_a
21915        (p_effective_date               =>     l_effective_date
21916        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21917        ,p_assignment_id                =>     p_assignment_id
21918        ,p_object_version_number        =>     l_object_version_number
21919        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21920        ,p_change_reason                =>     p_change_reason
21921        ,p_effective_start_date         =>     l_effective_start_date
21922        ,p_effective_end_date           =>     l_effective_end_date
21923        );
21924   exception
21925      when hr_api.cannot_find_prog_unit then
21926        hr_api.cannot_find_prog_unit_error
21927          (p_module_name       => 'OFFER_APL_ASG',
21928           p_hook_type         => 'AP'
21929          );
21930   end;
21931   --
21932   -- End of API User Hook for the after hook of offer_apl_asg.
21933   --
21934   --
21935   -- When in validation only mode raise the Validate_Enabled exception
21936   --
21937   if p_validate then
21938     raise hr_api.validate_enabled;
21939   end if;
21940   --
21941   -- Set remaining output arguments
21942   --
21943   p_object_version_number  := l_object_version_number;
21944   p_effective_start_date   := l_effective_start_date;
21945   p_effective_end_date     := l_effective_end_date;
21946  --
21947  if g_debug then
21948   hr_utility.set_location(' Leaving:'||l_proc, 50);
21949  end if;
21950 exception
21951   when hr_api.validate_enabled then
21952     --
21953     -- As the Validate_Enabled exception has been raised
21954     -- we must rollback to the savepoint
21955     --
21956     ROLLBACK TO offer_apl_asg;
21957     --
21958     -- Only set output warning arguments
21959     -- (Any key or derived arguments must be set to null
21960     -- when validation only mode is being used.)
21961     --
21962     p_object_version_number  := l_object_version_number_orig;
21963     p_effective_start_date   := null;
21964     p_effective_end_date     := null;
21965     --
21966   when others then
21967     --
21968     -- A validation or unexpected error has occurred
21969     --
21970     -- Added as part of fix to bug 632479
21971     --
21972     p_object_version_number := lv_object_version_number;
21973     p_effective_start_date   := null;
21974     p_effective_end_date     := null;
21975 
21976     ROLLBACK TO offer_apl_asg;
21977     raise;
21978     --
21979     -- End of fix.
21980     --
21981 end offer_apl_asg;
21982 --
21983 
21984 -- ----------------------------------------------------------------------------
21985 -- |---------------------------< accept_apl_asg >------------------------------|
21986 -- ----------------------------------------------------------------------------
21987 --
21988 procedure accept_apl_asg
21989   (p_validate                     in     boolean
21990   ,p_effective_date               in     date
21991   ,p_datetrack_update_mode        in     varchar2
21992   ,p_assignment_id                in     number
21993   ,p_object_version_number        in out nocopy number
21994   ,p_assignment_status_type_id    in     number
21995   ,p_change_reason                in     varchar2
21996   ,p_effective_start_date            out nocopy date
21997   ,p_effective_end_date              out nocopy date
21998   ) is
21999   --
22000   -- Declare cursors and local variables
22001   --
22002   l_object_version_number_orig number;
22003   l_effective_date             date;
22004   --
22005   -- Out variables
22006   --
22007   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
22008   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
22009   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
22010   --
22011   lv_object_version_number     number := p_object_version_number ;
22012   --
22013 l_proc                 varchar2(72);
22014   --
22015 begin
22016  if g_debug then
22017  l_proc := g_package||'accept_apl_asg';
22018   hr_utility.set_location('Entering:'|| l_proc, 5);
22019  end if;
22020   --
22021   --
22022   l_effective_date := trunc(p_effective_date);
22023   --
22024     savepoint accept_apl_asg;
22025   --
22026   -- Preserve IN OUT parameters for later use
22027   --
22028   l_object_version_number_orig := p_object_version_number;
22029   l_object_version_number      := p_object_version_number;
22030   --
22031  if g_debug then
22032   hr_utility.set_location(l_proc, 10);
22033  end if;
22034   --
22035   -- Process Logic
22036   --
22037   -- Start of API User Hook for the before hook of accept_apl_asg.
22038   --
22039   begin
22040      hr_assignment_bkb.accept_apl_asg_b
22041        (p_effective_date               =>     l_effective_date
22042        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
22043        ,p_assignment_id                =>     p_assignment_id
22044        ,p_object_version_number        =>     p_object_version_number
22045        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
22046        ,p_change_reason                =>     p_change_reason
22047        );
22048   exception
22049      when hr_api.cannot_find_prog_unit then
22050        hr_api.cannot_find_prog_unit_error
22051          (p_module_name       => 'ACCEPT_APL_ASG',
22052           p_hook_type         => 'BP'
22053          );
22054   end;
22055   -- End of API User Hook for the before hook of accept_apl_asg.
22056 
22057   --
22058   hr_assignment_internal.update_status_type_apl_asg
22059       (p_effective_date            => l_effective_date
22060       ,p_datetrack_update_mode     => p_datetrack_update_mode
22061       ,p_assignment_id             => p_assignment_id
22062     ,p_object_version_number     => l_object_version_number
22063       ,p_expected_system_status    => 'ACCEPTED'
22064       ,p_assignment_status_type_id => p_assignment_status_type_id
22065       ,p_change_reason             => p_change_reason
22066       ,p_effective_start_date      => l_effective_start_date
22067       ,p_effective_end_date        => l_effective_end_date
22068       );
22069   --
22070  if g_debug then
22071   hr_utility.set_location(l_proc, 20);
22072  end if;
22073   --
22074   -- Start of API User Hook for the after hook of accept_apl_asg.
22075   --
22076   begin
22077      hr_assignment_bkb.accept_apl_asg_a
22078        (p_effective_date               =>     l_effective_date
22079        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
22080        ,p_assignment_id                =>     p_assignment_id
22081        ,p_object_version_number        =>     l_object_version_number
22082        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
22083        ,p_change_reason                =>     p_change_reason
22084        ,p_effective_start_date         =>     l_effective_start_date
22085        ,p_effective_end_date           =>     l_effective_end_date
22086        );
22087   exception
22088      when hr_api.cannot_find_prog_unit then
22089        hr_api.cannot_find_prog_unit_error
22090          (p_module_name       => 'OFFER_APL_ASG',
22091           p_hook_type         => 'AP'
22092          );
22093   end;
22094   --
22095   -- End of API User Hook for the after hook of accept_apl_asg.
22096   --
22097 
22098 --
22099   -- When in validation only mode raise the Validate_Enabled exception
22100   --
22101   if p_validate then
22102     raise hr_api.validate_enabled;
22103   end if;
22104   --
22105   -- Set remaining output arguments
22106   --
22107   p_object_version_number  := l_object_version_number;
22108   p_effective_start_date   := l_effective_start_date;
22109   p_effective_end_date     := l_effective_end_date;
22110  --
22111  if g_debug then
22112   hr_utility.set_location(' Leaving:'||l_proc, 50);
22113  end if;
22114 exception
22115   when hr_api.validate_enabled then
22116 -- As the Validate_Enabled exception has been raised
22117     -- we must rollback to the savepoint
22118     --
22119     ROLLBACK TO accept_apl_asg;
22120     --
22121     -- Only set output warning arguments
22122     -- (Any key or derived arguments must be set to null
22123     -- when validation only mode is being used.)
22124     --
22125     p_object_version_number  := l_object_version_number_orig;
22126     p_effective_start_date   := null;
22127     p_effective_end_date     := null;
22128 
22129   When others then
22130 
22131     p_object_version_number := lv_object_version_number;
22132     p_effective_start_date   := null;
22133     p_effective_end_date     := null;
22134 
22135       ROLLBACK TO accept_apl_asg;
22136        raise;
22137 end accept_apl_asg;
22138 --
22139 -- -----------------------------------------------------------------------------
22140 -- |--------------------------< activate_apl_asg >-----------------------------|
22141 -- -----------------------------------------------------------------------------
22142 --
22143 PROCEDURE activate_apl_asg
22144   (p_validate                     IN     BOOLEAN
22145   ,p_effective_date               IN     DATE
22146   ,p_datetrack_update_mode        IN     VARCHAR2
22147   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
22148   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22149   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
22150   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
22151   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22152   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22153   )
22154 IS
22155   --
22156   -- Local variables
22157   --
22158   l_proc                         VARCHAR2(72);
22159   --
22160   l_effective_date               DATE;
22161   --
22162   l_object_version_number        CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
22163   --
22164   l_expected_system_status       per_assignment_status_types.per_system_status%TYPE    := 'ACTIVE_APL';
22165   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
22166   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
22167  --
22168  lv_object_version_number     number := p_object_version_number ;
22169  --
22170 --
22171 BEGIN
22172   --
22173  if g_debug then
22174   l_proc := g_package||'activate_apl_asg';
22175   hr_utility.set_location('Entering:'||l_proc,10);
22176  end if;
22177   --
22178   -- Truncate all date parameters passed in
22179   --
22180   l_effective_date := TRUNC(p_effective_date);
22181   --
22182   -- Issue savepoint
22183   --
22184   SAVEPOINT activate_apl_asg;
22185   --
22186  if g_debug then
22187   hr_utility.set_location(l_proc,20);
22188  end if;
22189   --
22190   -- Call Before Process User Hook
22191   --
22192   BEGIN
22193      hr_assignment_bkc.activate_apl_asg_b
22194        (p_effective_date               => l_effective_date
22195        ,p_datetrack_update_mode        => p_datetrack_update_mode
22196        ,p_assignment_id                => p_assignment_id
22197        ,p_object_version_number        => p_object_version_number
22198        ,p_assignment_status_type_id    => p_assignment_status_type_id
22199        ,p_change_reason                => p_change_reason
22200        );
22201   EXCEPTION
22202      WHEN hr_api.cannot_find_prog_unit
22203      THEN
22204        hr_api.cannot_find_prog_unit_error
22205          (p_module_name       => 'ACTIVATE_APL_ASG',
22206           p_hook_type         => 'BP'
22207          );
22208   END;
22209   --
22210  if g_debug then
22211   hr_utility.set_location(l_proc,30);
22212  end if;
22213   --
22214   -- Call business support process to update status type
22215   --
22216   hr_assignment_internal.update_status_type_apl_asg
22217     (p_effective_date               => l_effective_date
22218     ,p_datetrack_update_mode        => p_datetrack_update_mode
22219     ,p_assignment_id                => p_assignment_id
22220     ,p_object_version_number        => p_object_version_number
22221     ,p_expected_system_status       => l_expected_system_status
22222     ,p_assignment_status_type_id    => p_assignment_status_type_id
22223     ,p_change_reason                => p_change_reason
22224     ,p_effective_start_date         => l_effective_start_date
22225     ,p_effective_end_date           => l_effective_end_date
22226     );
22227   --
22228  if g_debug then
22229   hr_utility.set_location(l_proc,40);
22230  end if;
22231   --
22232   -- Call After Process User Hook
22233   --
22234   BEGIN
22235      hr_assignment_bkc.activate_apl_asg_a
22236        (p_effective_date               => l_effective_date
22237        ,p_datetrack_update_mode        => p_datetrack_update_mode
22238        ,p_assignment_id                => p_assignment_id
22239        ,p_object_version_number        => p_object_version_number
22240        ,p_assignment_status_type_id    => p_assignment_status_type_id
22241        ,p_change_reason                => p_change_reason
22242        ,p_effective_start_date         => l_effective_start_date
22243        ,p_effective_end_date           => l_effective_end_date
22244        );
22245   EXCEPTION
22246      WHEN hr_api.cannot_find_prog_unit
22247      THEN
22248        hr_api.cannot_find_prog_unit_error
22249          (p_module_name => 'ACTIVATE_APL_ASG',
22250           p_hook_type   => 'AP'
22251          );
22252   END;
22253   --
22254  if g_debug then
22255   hr_utility.set_location(l_proc,50);
22256  end if;
22257   --
22258   -- When in validation only mode raise validate_enabled exception
22259   --
22260   IF p_validate
22261   THEN
22262     RAISE hr_api.validate_enabled;
22263   END IF;
22264   --
22265   -- Set OUT parameters
22266   --
22267   p_effective_start_date         := l_effective_start_date;
22268   p_effective_end_date           := l_effective_end_date;
22269   --
22270  if g_debug then
22271   hr_utility.set_location(' Leaving:'||l_proc,100);
22272  end if;
22273 --
22274 EXCEPTION
22275   WHEN hr_api.validate_enabled
22276   THEN
22277     --
22278     -- In validation only mode
22279     -- Rollback to savepoint
22280     -- Set relevant output warning arguments
22281     -- Reset any key or derived arguments
22282     --
22283     ROLLBACK TO activate_apl_asg;
22284     p_object_version_number        := l_object_version_number;
22285     p_effective_start_date         := NULL;
22286     p_effective_end_date           := NULL;
22287   --
22288   WHEN OTHERS
22289   THEN
22290     --
22291     -- Validation or unexpected error occured
22292     -- Rollback to savepoint
22293     -- Re-raise exception
22294     --
22295     p_object_version_number := lv_object_version_number;
22296     p_effective_start_date   := null;
22297     p_effective_end_date     := null;
22298 
22299     ROLLBACK TO activate_apl_asg;
22300     RAISE;
22301 --
22302 END activate_apl_asg;
22303 --
22304 -- -----------------------------------------------------------------------------
22305 -- |-------------------------< terminate_apl_asg >-----------------------------|
22306 -- -----------------------------------------------------------------------------
22307 --
22308 PROCEDURE terminate_apl_asg
22309   (p_validate                     IN     BOOLEAN
22310   ,p_effective_date               IN     DATE
22311   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
22312   ,p_assignment_status_type_id    IN  per_all_assignments_f.assignment_status_type_id%TYPE
22313   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22314   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22315   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22316   )
22317 IS
22318 BEGIN
22319    hr_assignment_api.terminate_apl_asg
22320   (p_validate                   => p_validate
22321   ,p_effective_date             => p_effective_date
22322   ,p_assignment_id              => p_assignment_id
22323   ,p_assignment_status_type_id  => p_assignment_status_type_id
22324   ,p_object_version_number      => p_object_version_number
22325   ,p_effective_start_date       => p_effective_start_date
22326   ,p_effective_end_date         => p_effective_end_date
22327   ,p_change_reason              => NULL -- 4066579
22328   );
22329 END;
22330 --
22331 -- -----------------------------------------------------------------------------
22332 -- |-----------------------< terminate_apl_asg(NEW) >---------------------------|
22333 -- -----------------------------------------------------------------------------
22334 --
22335 PROCEDURE terminate_apl_asg
22336   (p_validate                     IN     BOOLEAN
22337   ,p_effective_date               IN     DATE
22338   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
22339   ,p_assignment_status_type_id    IN  per_all_assignments_f.assignment_status_type_id%TYPE
22340   ,p_change_reason                IN  per_all_assignments_f.change_reason%TYPE -- 4066579
22341   ,p_status_change_comments       IN  irc_assignment_statuses.status_change_comments%TYPE  -- bug 8732296
22342   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22343   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22344   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22345   )
22346 IS
22347   --
22348   -- Local variables
22349   --
22350   l_proc                         VARCHAR2(72) := g_package||'terminate_apl_asg';
22351   --
22352   l_effective_date               DATE;
22353   --
22354   l_object_version_number        CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
22355   --
22356   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
22357   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
22358   --
22359   l_assignment_status_type_id    per_all_assignments_f.assignment_status_type_id%TYPE;
22360   l_business_group_id            hr_all_organization_units.organization_id%TYPE;
22361   l_validation_start_date        DATE;
22362   l_validation_end_date          DATE;
22363   l_org_now_no_manager_warning   BOOLEAN;
22364   --
22365   lv_object_version_number     number;
22366   --
22367   l_assignment_status_id  irc_assignment_statuses.assignment_status_id%type;
22368   l_asg_status_ovn        irc_assignment_statuses.object_version_number%type;
22369   -- 3652025 >>
22370   l_new_application_id          per_applications.application_id%TYPE;
22371   l_fut_asg_start_date          date;
22372   l_fut_asg_end_date            date;
22373   l_comment_id                  number;
22374   l_payroll_id_updated          boolean;
22375   l_other_manager_warning       boolean;
22376   l_no_managers_warning         boolean;
22377   l_asg_ovn                     number;
22378   l_asg_eff_date                date;
22379   l_hourly_salaried_warning     boolean;
22380   l_manager_terminates varchar2(1); -- added for bug 7577823
22381   l_user_id varchar2(250); -- added for bug 7577823
22382 
22383   -- <<
22384   -- Local cursors
22385   --
22386   -- fix for bug 7577823 starts
22387 CURSOR csr_applicant_userid
22388     (p_assignment_id                IN
22389      per_all_assignments_f.assignment_id%TYPE
22390     ,p_effective_date               IN     DATE
22391     )
22392   IS
22393 select user_id
22394 from per_all_assignments_f paf, fnd_user usr, per_all_people_f ppf,
22395 per_all_people_f linkppf
22396 where p_effective_date between paf.effective_start_date and
22397 paf.effective_end_date
22398 and p_effective_date between usr.start_date and
22399 nvl(usr.end_date,p_effective_date)
22400 and p_effective_date between ppf.effective_start_date and
22401 ppf.effective_end_date
22402 and p_effective_date between linkppf.effective_start_date and
22403 linkppf.effective_end_date
22404 and usr.employee_id=linkppf.person_id
22405 and ppf.party_id = linkppf.party_id
22406 and ppf.person_id = paf.person_id
22407 and paf.assignment_id=p_assignment_id
22408 and usr.user_id = fnd_global.user_id;
22409 -- fix for bug 7577823 ends
22410 
22411   CURSOR csr_assignments
22412     (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
22413     ,p_effective_date               IN     DATE
22414     )
22415   IS
22416     SELECT asg.assignment_type
22417           ,asg.business_group_id
22418           ,bus.legislation_code
22419           ,person_id ,effective_end_date, application_id
22420 	  ,asg.assignment_status_type_id --7229710
22421 	  ,asg.effective_start_date -- Added for bug 9875744
22422       FROM per_all_assignments_f asg
22423           ,per_business_groups_perf bus
22424      WHERE asg.assignment_id = p_assignment_id
22425        AND bus.business_group_id = asg.business_group_id
22426        AND p_effective_date BETWEEN asg.effective_start_date
22427                                 AND asg.effective_end_date;
22428   -- 3652025 >>
22429   CURSOR csr_get_current_apl_asg(cp_asg_id number, cp_effective_date date) IS
22430     SELECT as2.assignment_id, as2.effective_start_date
22431           ,as2.effective_end_date
22432     FROM per_all_assignments_f as2
22433         ,per_all_assignments_f as1
22434     WHERE as2.person_id = as1.person_id
22435     AND as2.assignment_type = as1.assignment_type
22436     AND cp_effective_date BETWEEN as2.effective_start_date
22437                              AND as2.effective_end_date
22438     AND as2.assignment_id <> as1.assignment_id
22439     AND as1.assignment_id = cp_asg_id;
22440   --
22441   CURSOR csr_get_future_apl_asg(cp_asg_id number, cp_effective_date date) IS
22442     SELECT as2.assignment_id, as2.business_group_id
22443          , as2.effective_start_date, as2.effective_end_date
22444          , as2.application_id, as2.person_id, as2.object_version_number
22445     FROM per_all_assignments_f as2
22446         ,per_all_assignments_f as1
22447     WHERE as2.person_id = as1.person_id
22448     AND as2.assignment_type = as1.assignment_type
22449     AND as2.effective_start_date > cp_effective_date
22450     AND as2.assignment_id <> as1.assignment_id
22451     AND as1.assignment_id = cp_asg_id
22452     ORDER BY as2.effective_start_date, as2.assignment_id ASC;
22453   --
22454   CURSOR csr_appl_details(cp_application_id number) IS
22455      select *
22456        from per_applications
22457       where application_id = cp_application_id;
22458 
22459          -- Start changes for bug 9875744
22460   CURSOR chk_ae_assignment(lp_application_id number, lp_person_id number, lp_effective_start_date date) is
22461          select assignment_id
22462          from per_all_assignments_f paaf
22463          where  paaf.person_id = lp_person_id
22464           and  paaf.assignment_type = 'A'
22465           and  lp_effective_start_date between paaf.effective_start_date and paaf.effective_end_date
22466           and  paaf.assignment_id <> p_assignment_id
22467           and  paaf.application_id = lp_application_id
22468           and  exists
22469                ( select 1
22470                  from per_all_assignments_f paaf1
22471                  where paaf1.person_id = paaf.person_id
22472                  and paaf1.assignment_id = paaf.assignment_id
22473                  and paaf1.assignment_type = 'E' );
22474 
22475   cursor csr_other_asgs(cp_asg_id number, cp_appl_id number) is
22476      select 'Y' from per_assignments_f apl
22477        where apl.assignment_type = 'A'
22478          and apl.application_id = cp_appl_id
22479          and apl.assignment_id <> cp_asg_id
22480          and (apl.effective_end_date = hr_general.end_of_time
22481               or exists
22482               (select 'Y' from per_applications apa
22483                 where apa.application_id = cp_appl_id
22484                   and apa.date_end is not null
22485                   and apa.date_end >= apl.effective_end_date));
22486 
22487   l_emp_min_start_date     per_all_assignments_f.effective_start_date%type;
22488   l_apl_min_start_date     per_all_assignments_f.effective_start_date%type;
22489   l_ae_assignment_id       per_all_assignments_f.assignment_id%type;
22490   l_person_type_id         per_all_people_f.person_type_id%type;
22491   l_exists                 varchar2(10);
22492   -- Start changes for bug 9875744
22493 
22494   --  <<
22495   l_assignment            csr_assignments%ROWTYPE;
22496   l_fut_asg               csr_get_future_apl_asg%ROWTYPE;  -- 3652025 >>
22497   l_cur_asg               csr_get_current_apl_asg%ROWTYPE;
22498   l_appl_details          csr_appl_details%ROWTYPE;
22499   l_apl_object_version_number number;
22500   l_per_effective_start_date  date;
22501   l_per_effective_end_date    date; -- <<
22502   l_mx_end_dated              date;
22503   l_min_no_end_dated          date;
22504   --
22505   -- ----------------------------------------------------------------------- +
22506   -- ----------------------------------------------------------------------- +
22507   procedure end_assignment is
22508    --fix for bug 7229710 Start here.
22509    l_vacancy_id                   number;
22510    l_person_id number;
22511 
22512     Cursor csr_vacancy_id(l_assg_id number) is
22513 Select vacancy_id
22514 From per_all_assignments_f
22515 Where assignment_id = l_assg_id
22516 And p_effective_date between effective_start_date and effective_end_date;
22517 
22518 cursor csr_person_id(l_assg_id number) is
22519 select person_id
22520 from per_all_assignments_f
22521 where assignment_id=l_assg_id;
22522   --fix for bug 7229710 Ends here.
22523 
22524   begin
22525   per_asg_del.del
22526     (p_assignment_id                => p_assignment_id
22527     ,p_object_version_number        => p_object_version_number
22528     ,p_effective_date               => l_effective_date
22529     ,p_datetrack_mode               => hr_api.g_delete
22530     ,p_effective_start_date         => l_effective_start_date
22531     ,p_effective_end_date           => l_effective_end_date
22532     ,p_business_group_id            => l_business_group_id
22533     ,p_validation_start_date        => l_validation_start_date
22534     ,p_validation_end_date          => l_validation_end_date
22535     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
22536     );
22537     --
22538     if g_debug then
22539     hr_utility.set_location(l_proc,70);
22540     end if;
22541     --
22542     per_asg_bus1.chk_assignment_status_type
22543       (p_assignment_status_type_id => l_assignment_status_type_id
22544       ,p_business_group_id         => l_assignment.business_group_id
22545       ,p_legislation_code          => l_assignment.legislation_code
22546       ,p_expected_system_status    => 'TERM_APL'
22547       );
22548     --fix for bug 7229710 Start here.
22549     delete from per_letter_request_lines plrl
22550     where plrl.assignment_id = p_assignment_id
22551     and   plrl.assignment_status_type_id = l_assignment.assignment_status_type_id
22552     and   exists
22553          (select null
22554           from per_letter_requests plr
22555           where plr.letter_request_id = plrl.letter_request_id
22556           and   plr.request_status = 'PENDING'
22557           and   plr.auto_or_manual = 'AUTO');
22558 
22559   per_app_asg_pkg.cleanup_letters
22560     (p_assignment_id => p_assignment_id);
22561   --
22562   -- Check if a letter request is necessary for the assignment.
22563   --
22564 open csr_vacancy_id(p_assignment_id);
22565 fetch csr_vacancy_id into l_vacancy_id;
22566 if csr_vacancy_id%NOTFOUND then null;
22567 end if;
22568 close csr_vacancy_id;
22569 
22570 open csr_person_id(p_assignment_id);
22571 fetch csr_person_id into l_person_id;
22572 if csr_person_id%NOTFOUND then null;
22573 end if;
22574 close csr_person_id;
22575 
22576 
22577   per_applicant_pkg.check_for_letter_requests
22578     (p_business_group_id            => l_assignment.business_group_id
22579     ,p_per_system_status            => null
22580     ,p_assignment_status_type_id    => l_assignment_status_type_id
22581     ,p_person_id                    => l_person_id
22582     ,p_assignment_id                => p_assignment_id
22583     ,p_effective_start_date         => l_effective_start_date
22584     ,p_validation_start_date        => l_validation_start_date
22585     ,p_vacancy_id 		    => l_vacancy_id
22586     );
22587  --fix for bug 7229710 Ends here.
22588 
22589 if not per_otherbg_apl_api.g_otherbg_hire_in_process then -- 12537989
22590 
22591     IRC_ASG_STATUS_API.create_irc_asg_status
22592          (p_assignment_id               => p_assignment_id
22593          , p_assignment_status_type_id  => l_assignment_status_type_id
22594          , p_status_change_date         => p_effective_date
22595          , p_assignment_status_id       => l_assignment_status_id
22596          , p_status_change_reason       => p_change_reason -- 4066579
22597          , p_status_change_comments     => p_status_change_comments -- 8732296
22598          , p_object_version_number      => l_asg_status_ovn);
22599 end if;       --  12537989
22600 
22601     --fix for bug 7577823 starts
22602         OPEN csr_applicant_userid
22603     (p_assignment_id                => p_assignment_id
22604     ,p_effective_date               => p_effective_date
22605     );
22606     FETCH csr_applicant_userid INTO l_user_id;
22607     IF csr_applicant_userid%NOTFOUND
22608     THEN
22609      l_manager_terminates:='Y';
22610     END IF;
22611     CLOSE csr_applicant_userid;
22612     hr_utility.set_location('l_user_id: '||l_user_id,71);
22613     hr_utility.set_location('g_user_id: '||fnd_global.user_id,72);
22614     if l_user_id=fnd_global.user_id then
22615       l_manager_terminates:='N';
22616     else
22617       l_manager_terminates:='Y';
22618     end if;
22619     --fix for bug 7577823 ends
22620 
22621     --
22622     -- Close the offers (if any) for this applicant
22623     --
22624 /*   IRC_OFFERS_API.close_offer
22625        ( p_validate                   => p_validate
22626         ,p_effective_date             => p_effective_date
22627         ,p_applicant_assignment_id    => p_assignment_id
22628         ,p_change_reason              => 'WITHDRAWAL'
22629        );
22630 */ -- Commmented for bug 7577823
22631    --
22632    -- When an offer gets closed upon termination of application by manager
22633    -- incorrect offer close reason is displayed as 'Applicant Withdrew
22634    -- their Application'. It should be 'Manager Terminated Application'.
22635    -- Bug 7577823 handles this case.
22636    --
22637 --fix for bug 7577823 starts
22638      if l_manager_terminates = 'Y' then
22639        IRC_OFFERS_API.close_offer
22640        ( p_validate                   => p_validate
22641         ,p_effective_date             => p_effective_date
22642         ,p_applicant_assignment_id    => p_assignment_id
22643         ,p_change_reason              => 'MGR_TERMINATE_APPL'
22644        );
22645       else
22646         IRC_OFFERS_API.close_offer
22647        ( p_validate                   => p_validate
22648         ,p_effective_date             => p_effective_date
22649         ,p_applicant_assignment_id    => p_assignment_id
22650         ,p_change_reason              => 'WITHDRAWAL'
22651        );
22652       end if;
22653 --fix for bug 7577823 ends
22654 
22655   end end_assignment;
22656   --
22657 BEGIN
22658   --
22659  if g_debug then
22660   hr_utility.set_location('Entering:'||l_proc,10);
22661  end if;
22662   --
22663   -- Ensure mandatory arguments have been passed
22664   --
22665   hr_api.mandatory_arg_error
22666     (p_api_name                     => l_proc
22667     ,p_argument                     => 'assignment_id'
22668     ,p_argument_value               => p_assignment_id
22669     );
22670   --
22671   hr_api.mandatory_arg_error
22672     (p_api_name                     => l_proc
22673     ,p_argument                     => 'effective_date'
22674     ,p_argument_value               => p_effective_date
22675     );
22676   --
22677   -- Truncate all date parameters passed in
22678   --
22679   l_effective_date := TRUNC(p_effective_date);
22680   l_assignment_status_type_id  := p_assignment_status_type_id;
22681   lv_object_version_number     := p_object_version_number ;
22682   --
22683   -- Issue savepoint
22684   --
22685   SAVEPOINT terminate_apl_asg;
22686   --
22687  if g_debug then
22688   hr_utility.set_location(l_proc,20);
22689  end if;
22690   --
22691   -- Call Before Process User Hook
22692   --
22693   BEGIN
22694     hr_assignment_bkd.terminate_apl_asg_b
22695       (p_effective_date               => l_effective_date
22696       ,p_assignment_id                => p_assignment_id
22697       ,p_object_version_number        => p_object_version_number
22698       );
22699   EXCEPTION
22700     WHEN hr_api.cannot_find_prog_unit
22701     THEN
22702        hr_api.cannot_find_prog_unit_error
22703          (p_module_name       => 'TERMINATE_APL_ASG'
22704          ,p_hook_type         => 'B'
22705          );
22706   END;
22707   --
22708  if g_debug then
22709   hr_utility.set_location(l_proc,30);
22710  end if;
22711   --
22712   -- Retrieve derived assignment details
22713   --
22714   OPEN csr_assignments
22715     (p_assignment_id                => p_assignment_id
22716     ,p_effective_date               => l_effective_date
22717     );
22718   FETCH csr_assignments INTO l_assignment;
22719   IF csr_assignments%NOTFOUND
22720   THEN
22721     CLOSE csr_assignments;
22722     hr_utility.set_message(801,'HR_52360_ASG_DOES_NOT_EXIST');
22723     hr_utility.raise_error;
22724   END IF;
22725   CLOSE csr_assignments;
22726   --
22727  if g_debug then
22728   hr_utility.set_location(l_proc,40);
22729  end if;
22730   --
22731   -- Ensure this is an applicant assignment
22732   --
22733   IF l_assignment.assignment_type <> 'A'
22734   THEN
22735     hr_utility.set_message(801,'HR_51036_ASG_ASG_NOT_APL');
22736     hr_utility.raise_error;
22737   END IF;
22738   --
22739  if g_debug then
22740   hr_utility.set_location(l_proc,50);
22741  end if;
22742   --
22743   -- 3652025 >> Ensure this is not the last applicant assignment
22744   --
22745   --IF last_apl_asg
22746   --  (p_assignment_id                => p_assignment_id
22747   --  ,p_effective_date               => l_effective_date + 1
22748   --  )
22749   --THEN
22750     --
22751   --  hr_utility.set_message(800,'HR_7987_PER_INV_TYPE_CHANGE');
22752   --  hr_utility.raise_error;
22753   --
22754   --END IF; <<
22755   --
22756   open csr_get_current_apl_asg(p_assignment_id, l_effective_date+1);
22757   fetch csr_get_current_apl_asg into l_cur_asg;
22758   if csr_get_current_apl_asg%NOTFOUND then -- no current
22759     if g_debug then
22760         hr_utility.set_location(l_proc,60);
22761     end if;
22762     --
22763     close csr_get_current_apl_asg;
22764     open csr_get_future_apl_asg(p_assignment_id, l_effective_date);
22765     fetch csr_get_future_apl_asg into l_fut_asg;
22766     if csr_get_future_apl_asg%NOTFOUND then -- no current, no future
22767         close csr_get_future_apl_asg;
22768         hr_utility.set_message(800,'HR_7987_PER_INV_TYPE_CHANGE');
22769         hr_utility.raise_error;
22770     else                                    -- no current, yes future
22771         if g_debug then
22772             hr_utility.set_location(l_proc,62);
22773         end if;
22774         hr_utility.trace('  ex_apl date  = '||to_char(l_effective_date+1));
22775         hr_utility.trace('  apl date = '||to_char(l_fut_asg.effective_start_date));
22776         -- End assignment
22777         end_assignment;
22778         -- update the person and PTU records
22779         hr_applicant_internal.upd_person_ex_apl_and_apl(
22780               p_business_group_id           => l_fut_asg.business_group_id
22781              ,p_person_id                   => l_fut_asg.person_id
22782              ,p_ex_apl_effective_date       => l_effective_date+1
22783              ,p_apl_effective_date          => l_fut_asg.effective_start_date
22784              ,p_per_effective_start_date    => l_per_effective_start_date
22785              ,p_per_effective_end_date      => l_per_effective_end_date);
22786         --
22787         -- terminate current application
22788         --
22789         hr_utility.trace('   terminate current application on '||to_char(l_effective_date));
22790         --
22791         UPDATE per_applications
22792            SET date_end = l_effective_date
22793           where application_id = l_fut_asg.application_id;
22794         --
22795         open csr_appl_details(l_fut_asg.application_id);
22796         fetch csr_appl_details into l_appl_details;
22797         close csr_appl_details;
22798         -- create new application for future assignments
22799         per_apl_ins.ins
22800               (p_application_id            => l_new_application_id
22801               ,p_business_group_id         => l_fut_asg.business_group_id
22802               ,p_person_id                 => l_fut_asg.person_id
22803               ,p_date_received             => l_fut_asg.effective_start_date
22804               ,p_object_version_number     => l_apl_object_version_number
22805               ,p_effective_date            => l_fut_asg.effective_start_date
22806               ,p_comments                => l_appl_details.comments
22807               ,p_current_employer        => l_appl_details.current_employer
22808               ,p_projected_hire_date     => l_appl_details.projected_hire_date
22809               ,p_successful_flag         => l_appl_details.successful_flag
22810               ,p_termination_reason      => l_appl_details.termination_reason
22811               ,p_request_id              => l_appl_details.request_id
22812               ,p_program_application_id  => l_appl_details.program_application_id
22813               ,p_program_id              => l_appl_details.program_id
22814               ,p_program_update_date     => l_appl_details.program_update_date
22815               ,p_appl_attribute_category => l_appl_details.appl_attribute_category
22816               ,p_appl_attribute1         => l_appl_details.appl_attribute1
22817               ,p_appl_attribute2         => l_appl_details.appl_attribute2
22818               ,p_appl_attribute3         => l_appl_details.appl_attribute3
22819               ,p_appl_attribute4         => l_appl_details.appl_attribute4
22820               ,p_appl_attribute5         => l_appl_details.appl_attribute5
22821               ,p_appl_attribute6         => l_appl_details.appl_attribute6
22822               ,p_appl_attribute7         => l_appl_details.appl_attribute7
22823               ,p_appl_attribute8         => l_appl_details.appl_attribute8
22824               ,p_appl_attribute9         => l_appl_details.appl_attribute9
22825               ,p_appl_attribute10        => l_appl_details.appl_attribute10
22826               ,p_appl_attribute11        => l_appl_details.appl_attribute11
22827               ,p_appl_attribute12        => l_appl_details.appl_attribute12
22828               ,p_appl_attribute13        => l_appl_details.appl_attribute13
22829               ,p_appl_attribute14        => l_appl_details.appl_attribute14
22830               ,p_appl_attribute15        => l_appl_details.appl_attribute15
22831               ,p_appl_attribute16        => l_appl_details.appl_attribute16
22832               ,p_appl_attribute17        => l_appl_details.appl_attribute17
22833               ,p_appl_attribute18        => l_appl_details.appl_attribute18
22834               ,p_appl_attribute19        => l_appl_details.appl_attribute19
22835               ,p_appl_attribute20        => l_appl_details.appl_attribute20
22836               );
22837         hr_utility.trace('   new application ID = '||to_char(l_new_application_id));
22838 
22839         -- update future assignments with new application ID
22840         hr_utility.trace('   update all future assignments');
22841         -- update first assignment found
22842         l_asg_ovn := l_fut_asg.object_version_number;
22843         l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
22844         --
22845         hr_utility.trace('    => asg id = '||l_fut_asg.assignment_id);
22846         hr_utility.trace('    =>     SD = '||to_char(l_fut_asg.effective_start_date));
22847         hr_utility.trace('    =>     ED = '||to_char(l_fut_asg.effective_end_date));
22848         per_asg_upd.upd
22849             (p_assignment_id                => l_fut_asg.assignment_id
22850             ,p_effective_start_date         => l_fut_asg.effective_start_date
22851             ,p_effective_end_date           => l_fut_asg.effective_end_date
22852             ,p_business_group_id            => l_fut_asg.business_group_id
22853             ,p_comment_id                   => l_comment_id
22854             ,p_application_id               => l_new_application_id  -- override exsiting appl id
22855             ,p_payroll_id_updated           => l_payroll_id_updated
22856             ,p_other_manager_warning        => l_other_manager_warning
22857             ,p_no_managers_warning          => l_no_managers_warning
22858             ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
22859             ,p_validation_start_date        => l_validation_start_date
22860             ,p_validation_end_date          => l_validation_end_date
22861             ,p_object_version_number        => l_asg_ovn
22862             ,p_effective_date               => l_asg_eff_date
22863             ,p_datetrack_mode               => hr_api.g_correction
22864             ,p_validate                     => FALSE
22865             ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
22866         -- update all other future assignments
22867         hr_utility.trace('  update all other assignments');
22868         LOOP
22869           fetch csr_get_future_apl_asg into l_fut_asg;
22870           exit when csr_get_future_apl_asg%NOTFOUND;
22871              l_asg_ovn := l_fut_asg.object_version_number;
22872              l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
22873              per_asg_upd.upd
22874                 (p_assignment_id                => l_fut_asg.assignment_id
22875                 ,p_effective_start_date         => l_fut_asg.effective_start_date
22876                 ,p_effective_end_date           => l_fut_asg.effective_end_date
22877                 ,p_business_group_id            => l_fut_asg.business_group_id
22878                 ,p_comment_id                   => l_comment_id
22879                 ,p_application_id               => l_new_application_id
22880                 ,p_payroll_id_updated           => l_payroll_id_updated
22881                 ,p_other_manager_warning        => l_other_manager_warning
22882                 ,p_no_managers_warning          => l_no_managers_warning
22883                 ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
22884                 ,p_validation_start_date        => l_validation_start_date
22885                 ,p_validation_end_date          => l_validation_end_date
22886                 ,p_object_version_number        => l_asg_ovn
22887                 ,p_effective_date               => l_asg_eff_date
22888                 ,p_datetrack_mode               => hr_api.g_correction
22889                 ,p_validate                     => FALSE
22890                 ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
22891         END LOOP;
22892         --
22893         close csr_get_future_apl_asg;
22894         if g_debug then
22895             hr_utility.set_location(l_proc,68);
22896         end if;
22897   -- Start changes for bug#9875744
22898         l_ae_assignment_id := null;
22899         l_apl_min_start_date := null;
22900         l_emp_min_start_date := null;
22901         l_person_type_id := null;
22902 
22903         open chk_ae_assignment(
22904           lp_application_id => l_new_application_id,
22905           lp_person_id => l_assignment.person_id,
22906           lp_effective_start_date => l_fut_asg.effective_start_date);
22907         fetch chk_ae_assignment into l_ae_assignment_id;
22908         close chk_ae_assignment;
22909 
22910         if l_ae_assignment_id is not null then
22911             select min(effective_start_date) into l_apl_min_start_date
22912             from per_all_assignments_f
22913             where assignment_id = l_ae_assignment_id;
22914 
22915             select min(effective_start_date) into l_emp_min_start_date
22916             from per_all_assignments_f
22917             where assignment_id = l_ae_assignment_id
22918             and assignment_type = 'E';
22919 
22920             hr_utility.set_location('l_ae_assignment_id:'||l_ae_assignment_id,68);
22921             hr_utility.set_location('l_apl_min_start_date:'||l_apl_min_start_date,68);
22922             hr_utility.set_location('l_emp_min_start_date:'||l_emp_min_start_date,68);
22923             hr_utility.set_location('l_assignment.effective_start_date'||l_assignment.effective_start_date,68);
22924 
22925             If p_effective_date < l_apl_min_start_date then
22926               l_person_type_id :=
22927                 hr_person_type_usage_info.get_default_person_type_id(l_assignment.business_group_id,'EX_APL');
22928               hr_utility.set_location('l_person_type_id:'||l_person_type_id,69);
22929 
22930               --Transform person onto EX-APL on "min no end dated" - 1
22931               hr_applicant_internal.Update_PER_PTU_to_EX_APL(
22932                  p_business_group_id         => l_assignment.business_group_id
22933                  ,p_person_id                 => l_assignment.person_id
22934                  ,p_effective_date            => l_emp_min_start_date
22935                  ,p_person_type_id            => l_person_type_id
22936                  ,p_per_effective_start_date  => l_per_effective_start_date
22937                  ,p_per_effective_end_date    => l_per_effective_end_date);
22938               hr_utility.set_location('Converted Ex-Applicant',70);
22939               --
22940               UPDATE per_applications
22941               SET date_end = l_emp_min_start_date - 1
22942               where application_id = l_new_application_id;
22943 
22944               hr_utility.set_location('Terminated new application on '||l_emp_min_start_date - 1,71);
22945 
22946             End if;
22947         End if;
22948         -- End changes for bug#9875744
22949 
22950     end if;
22951   else -- yes current
22952     close csr_get_current_apl_asg;
22953     if l_cur_asg.effective_end_date < hr_general.end_of_time then
22954       --
22955       -- current assignment is end dated
22956       --
22957       if g_debug then
22958           hr_utility.set_location(l_proc,100);
22959       end if;
22960       select max(effective_end_date) into l_mx_end_dated
22961         from per_assignments_f
22962        where person_id = l_assignment.person_id
22963          and assignment_type = 'A'
22964          and effective_end_date < hr_general.end_of_time
22965          and assignment_id <> p_assignment_id;
22966       --
22967       select min(effective_start_date) into l_min_no_end_dated
22968         from per_assignments_f
22969        where person_id = l_assignment.person_id
22970          and assignment_type = 'A'
22971          and effective_end_date = hr_general.end_of_time
22972          and assignment_id <> p_assignment_id;
22973 
22974 	 	   hr_utility.set_location('l_mx_end_dated:'||l_mx_end_dated,72);
22975       hr_utility.set_location('l_min_no_end_dated:'||l_min_no_end_dated,73);
22976       --
22977       if l_mx_end_dated is not null then -- if A
22978         --
22979         if l_min_no_end_dated is not null then -- if B
22980           --
22981           if l_mx_end_dated + 1 = l_min_no_end_dated then -- if C
22982             --
22983             -- end assignment as normal
22984             if g_debug then
22985                 hr_utility.set_location(l_proc,110);
22986             end if;
22987             end_assignment;
22988             --
22989           else -- else C
22990             if l_min_no_end_dated <= l_mx_end_dated then -- if D
22991               --
22992               end_assignment; -- terminate assignment as normal.
22993             else -- else D
22994               -- this means person becomes ex-apl after "max end date"
22995               -- 1. End assignment as normal
22996               -- 2. Transform person onto EX-APL after "max end date" and before "min sd"
22997               -- 3. Create new application and update all future applicant assignments
22998               --    on "min sd"
22999               if g_debug then
23000                   hr_utility.set_location(l_proc,120);
23001               end if;
23002               -- End assignment
23003               end_assignment;
23004               -- update the person and PTU records
23005               hr_applicant_internal.upd_person_ex_apl_and_apl(
23006                     p_business_group_id           => l_assignment.business_group_id
23007                    ,p_person_id                   => l_assignment.person_id
23008                    ,p_ex_apl_effective_date       => l_mx_end_dated+1
23009                    ,p_apl_effective_date          => l_min_no_end_dated
23010                    ,p_per_effective_start_date    => l_per_effective_start_date
23011                    ,p_per_effective_end_date      => l_per_effective_end_date);
23012               --
23013               -- terminate current application
23014               --
23015               hr_utility.trace('   terminate current application on '||to_char(l_mx_end_dated));
23016               --
23017               UPDATE per_applications
23018                  SET date_end = l_mx_end_dated
23019                 where application_id = l_assignment.application_id;
23020               --
23021               open csr_appl_details(l_assignment.application_id);
23022               fetch csr_appl_details into l_appl_details;
23023               close csr_appl_details;
23024               -- create new application for future assignments
23025               per_apl_ins.ins
23026                     (p_application_id            => l_new_application_id
23027                     ,p_business_group_id         => l_assignment.business_group_id
23028                     ,p_person_id                 => l_assignment.person_id
23029                     ,p_date_received             => l_min_no_end_dated
23030                     ,p_object_version_number     => l_apl_object_version_number
23031                     ,p_effective_date            => l_min_no_end_dated
23032                     ,p_comments                => l_appl_details.comments
23033                     ,p_current_employer        => l_appl_details.current_employer
23034                     ,p_projected_hire_date     => l_appl_details.projected_hire_date
23035                     ,p_successful_flag         => l_appl_details.successful_flag
23036                     ,p_termination_reason      => l_appl_details.termination_reason
23037                     ,p_request_id              => l_appl_details.request_id
23038                     ,p_program_application_id  => l_appl_details.program_application_id
23039                     ,p_program_id              => l_appl_details.program_id
23040                     ,p_program_update_date     => l_appl_details.program_update_date
23041                     ,p_appl_attribute_category => l_appl_details.appl_attribute_category
23042                     ,p_appl_attribute1         => l_appl_details.appl_attribute1
23043                     ,p_appl_attribute2         => l_appl_details.appl_attribute2
23044                     ,p_appl_attribute3         => l_appl_details.appl_attribute3
23045                     ,p_appl_attribute4         => l_appl_details.appl_attribute4
23046                     ,p_appl_attribute5         => l_appl_details.appl_attribute5
23047                     ,p_appl_attribute6         => l_appl_details.appl_attribute6
23048                     ,p_appl_attribute7         => l_appl_details.appl_attribute7
23049                     ,p_appl_attribute8         => l_appl_details.appl_attribute8
23050                     ,p_appl_attribute9         => l_appl_details.appl_attribute9
23051                     ,p_appl_attribute10        => l_appl_details.appl_attribute10
23052                     ,p_appl_attribute11        => l_appl_details.appl_attribute11
23053                     ,p_appl_attribute12        => l_appl_details.appl_attribute12
23054                     ,p_appl_attribute13        => l_appl_details.appl_attribute13
23055                     ,p_appl_attribute14        => l_appl_details.appl_attribute14
23056                     ,p_appl_attribute15        => l_appl_details.appl_attribute15
23057                     ,p_appl_attribute16        => l_appl_details.appl_attribute16
23058                     ,p_appl_attribute17        => l_appl_details.appl_attribute17
23059                     ,p_appl_attribute18        => l_appl_details.appl_attribute18
23060                     ,p_appl_attribute19        => l_appl_details.appl_attribute19
23061                     ,p_appl_attribute20        => l_appl_details.appl_attribute20
23062                     );
23063               hr_utility.trace('   new application ID = '||to_char(l_new_application_id));
23064 
23065               -- update future assignments with new application ID
23066               hr_utility.trace('   update all future assignments');
23067               -- update first assignment found
23068               open csr_get_future_apl_asg(p_assignment_id, l_mx_end_dated+1);
23069               fetch csr_get_future_apl_asg into l_fut_asg;
23070               l_asg_ovn := l_fut_asg.object_version_number;
23071               l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
23072               --
23073               hr_utility.trace('    => asg id = '||l_fut_asg.assignment_id);
23074               hr_utility.trace('    =>     SD = '||to_char(l_fut_asg.effective_start_date));
23075               hr_utility.trace('    =>     ED = '||to_char(l_fut_asg.effective_end_date));
23076               per_asg_upd.upd
23077                   (p_assignment_id                => l_fut_asg.assignment_id
23078                   ,p_effective_start_date         => l_fut_asg.effective_start_date
23079                   ,p_effective_end_date           => l_fut_asg.effective_end_date
23080                   ,p_business_group_id            => l_fut_asg.business_group_id
23081                   ,p_comment_id                   => l_comment_id
23082                   ,p_application_id               => l_new_application_id  -- override exsiting appl id
23083                   ,p_payroll_id_updated           => l_payroll_id_updated
23084                   ,p_other_manager_warning        => l_other_manager_warning
23085                   ,p_no_managers_warning          => l_no_managers_warning
23086                   ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
23087                   ,p_validation_start_date        => l_validation_start_date
23088                   ,p_validation_end_date          => l_validation_end_date
23089                   ,p_object_version_number        => l_asg_ovn
23090                   ,p_effective_date               => l_asg_eff_date
23091                   ,p_datetrack_mode               => hr_api.g_correction
23092                   ,p_validate                     => FALSE
23093                   ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
23094               -- update all other future assignments
23095               hr_utility.trace('  update all other assignments');
23096               LOOP
23097                 fetch csr_get_future_apl_asg into l_fut_asg;
23098                 exit when csr_get_future_apl_asg%NOTFOUND;
23099                    l_asg_ovn := l_fut_asg.object_version_number;
23100                    l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
23101                    per_asg_upd.upd
23102                       (p_assignment_id                => l_fut_asg.assignment_id
23103                       ,p_effective_start_date         => l_fut_asg.effective_start_date
23104                       ,p_effective_end_date           => l_fut_asg.effective_end_date
23105                       ,p_business_group_id            => l_fut_asg.business_group_id
23106                       ,p_comment_id                   => l_comment_id
23107                       ,p_application_id               => l_new_application_id
23108                       ,p_payroll_id_updated           => l_payroll_id_updated
23109                       ,p_other_manager_warning        => l_other_manager_warning
23110                       ,p_no_managers_warning          => l_no_managers_warning
23111                       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
23112                       ,p_validation_start_date        => l_validation_start_date
23113                       ,p_validation_end_date          => l_validation_end_date
23114                       ,p_object_version_number        => l_asg_ovn
23115                       ,p_effective_date               => l_asg_eff_date
23116                       ,p_datetrack_mode               => hr_api.g_correction
23117                       ,p_validate                     => FALSE
23118                       ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
23119               END LOOP;
23120               --
23121               close csr_get_future_apl_asg;
23122               if g_debug then
23123                   hr_utility.set_location(l_proc,150);
23124               end if;
23125               --
23126             end if; -- end if D
23127           end if; -- end if C
23128           --
23129         else-- else B
23130           -- assignment being terminated is the only one available
23131           -- 1. End assignment as normal
23132           -- 2. Transform person onto EX-APL on "max end date" + 1
23133           if g_debug then
23134               hr_utility.set_location(l_proc,160);
23135           end if;
23136                        /*Start of code added for bug#9875744*/
23137             hr_utility.set_location(l_proc||' else -B',71);
23138 
23139             open csr_other_asgs(p_assignment_id, l_assignment.application_id);
23140             fetch csr_other_asgs into l_exists;
23141             if csr_other_asgs%NOTFOUND then
23142                 close csr_other_asgs;
23143                 hr_utility.set_message(800,'HR_6382_APP_TERM_FUTURE_PPT');
23144                 hr_utility.raise_error;
23145             else
23146                 close csr_other_asgs;
23147             end if;
23148 
23149             if g_debug then
23150                 hr_utility.set_location(l_proc,165);
23151             end if;
23152             -- null; -- not implemented.
23153 
23154 
23155         end if; -- end if B
23156         --
23157       else -- else A
23158         --
23159         if g_debug then
23160             hr_utility.set_location(l_proc,170);
23161         end if;
23162 
23163       end if; -- end if A
23164     else
23165        if g_debug then
23166            hr_utility.set_location(l_proc,180);
23167        end if;
23168        -- terminate assignment as normal
23169        end_assignment;
23170     end if;
23171 
23172   end if; -- end "yes current"
23173   --
23174   if g_debug then
23175     hr_utility.set_location(l_proc,200);
23176   end if;
23177   --
23178   -- Call After Process User Hook
23179   --
23180   BEGIN
23181     hr_assignment_bkd.terminate_apl_asg_a
23182       (p_effective_date               => l_effective_date
23183       ,p_assignment_id                => p_assignment_id
23184       ,p_object_version_number        => p_object_version_number
23185       ,p_effective_start_date         => l_effective_start_date
23186       ,p_effective_end_date           => l_effective_end_date
23187       );
23188   EXCEPTION
23189     WHEN hr_api.cannot_find_prog_unit
23190     THEN
23191        hr_api.cannot_find_prog_unit_error
23192          (p_module_name       => 'TERMINATE_APL_ASG'
23193          ,p_hook_type         => 'A'
23194          );
23195   END;
23196   --
23197  if g_debug then
23198   hr_utility.set_location(l_proc,300);
23199  end if;
23200   --
23201   -- When in validation only mode raise validate enabled exception
23202   --
23203   IF p_validate
23204   THEN
23205     RAISE hr_api.validate_enabled;
23206   END IF;
23207   --
23208   -- Set OUT parameters
23209   --
23210   p_effective_start_date         := l_effective_start_date;
23211   p_effective_end_date           := l_effective_end_date;
23212   --
23213  if g_debug then
23214   hr_utility.set_location(' Leaving:'||l_proc,1000);
23215  end if;
23216 --
23217 EXCEPTION
23218   WHEN hr_api.validate_enabled
23219   THEN
23220     --
23221     -- In validation only mode
23222     -- Rollback to savepoint
23223     -- Set relevant output warning arguments
23224     -- Reset any key or derived arguments
23225     --
23226     ROLLBACK TO terminate_apl_asg;
23227     p_object_version_number        := l_object_version_number;
23228     p_effective_start_date         := NULL;
23229     p_effective_end_date           := NULL;
23230   --
23231   WHEN OTHERS
23232   THEN
23233     --
23234     -- Validation or unexpected error occured
23235     -- Rollback to savepoint
23236     -- Re-raise exception
23237     p_object_version_number := lv_object_version_number;
23238     p_effective_start_date   := null;
23239     p_effective_end_date     := null;
23240     --
23241     ROLLBACK TO terminate_apl_asg;
23242     RAISE;
23243 --
23244 END terminate_apl_asg;
23245 --
23246 --
23247 PROCEDURE set_new_primary_asg
23248   (p_validate                    IN     BOOLEAN
23249   ,p_effective_date              IN     DATE
23250   ,p_person_id                   IN     per_all_people_f.person_id%TYPE
23251   ,p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
23252   ,p_object_version_number       IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
23253   ,p_effective_start_date           OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
23254   ,p_effective_end_date             OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
23255   )
23256 IS
23257   --
23258   -- Local Variables
23259   --
23260   l_proc                        VARCHAR2(72) := g_package||'set_new_primary_asg';
23261   --
23262   l_effective_date              DATE;
23263   l_object_version_number       CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
23264   l_effective_start_date        per_all_assignments_f.effective_start_date%TYPE;
23265   l_effective_end_date          per_all_assignments_f.effective_end_date%TYPE;
23266   --
23267   lv_object_version_number     number := p_object_version_number ;
23268   --
23269   -- Local cursors
23270   --
23271   CURSOR csr_new_assignment
23272     (p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
23273     ,p_effective_date              IN     DATE
23274     )
23275   IS
23276     SELECT asg.object_version_number
23277           ,asg.assignment_type
23278           ,asg.period_of_service_id
23279           ,asg.person_id
23280           ,asg.primary_flag
23281           ,asg.effective_start_date
23282           ,asg.effective_end_date
23283           ,MAX(mxa.effective_end_date) AS max_effective_end_date
23284           ,pds.actual_termination_date
23285       FROM per_all_assignments_f asg
23286           ,per_all_assignments_f mxa
23287           ,per_periods_of_service pds
23288      WHERE pds.period_of_service_id(+) = asg.period_of_service_id
23289        AND mxa.assignment_id = asg.assignment_id
23290        AND asg.assignment_id = csr_new_assignment.p_assignment_id
23291        AND csr_new_assignment.p_effective_date BETWEEN asg.effective_start_date
23292                                                    AND asg.effective_end_date
23293   GROUP BY asg.object_version_number
23294           ,asg.assignment_type
23295           ,asg.period_of_service_id
23296           ,asg.person_id
23297           ,asg.primary_flag
23298           ,asg.effective_start_date
23299           ,asg.effective_end_date
23300           ,pds.actual_termination_date;
23301   l_new_assignment               csr_new_assignment%ROWTYPE;
23302   --
23303   CURSOR csr_old_assignment
23304     (p_person_id                  IN     per_all_people_f.person_id%TYPE
23305     ,p_effective_date             IN     DATE
23306     )
23307   IS
23308     SELECT asg.assignment_id
23309           ,asg.period_of_service_id
23310           ,asg.assignment_type
23311           ,asg.primary_flag
23312           ,asg.person_id
23313           ,asg.effective_start_date
23314           ,asg.effective_end_date
23315       FROM per_all_assignments_f asg
23316      WHERE asg.person_id = csr_old_assignment.p_person_id
23317        AND csr_old_assignment.p_effective_date BETWEEN asg.effective_start_date
23318                                                    AND asg.effective_end_date
23319        AND asg.primary_flag = 'Y'
23320        AND asg.assignment_type = 'E';
23321  l_old_assignment               csr_old_assignment%ROWTYPE;
23322 --
23323 BEGIN
23324   --
23325  if g_debug then
23326   hr_utility.set_location('Entering:'||l_proc,10);
23327  end if;
23328   --
23329   -- Ensure mandatory parameters have been passed
23330   --
23331   hr_api.mandatory_arg_error
23332     (p_api_name                     => l_proc
23333     ,p_argument                     => 'effective_date'
23334     ,p_argument_value               => p_effective_date
23335     );
23336   --
23337   hr_api.mandatory_arg_error
23338     (p_api_name                     => l_proc
23339     ,p_argument                     => 'person_id'
23340     ,p_argument_value               => p_person_id
23341     );
23342   --
23343   hr_api.mandatory_arg_error
23344     (p_api_name                     => l_proc
23345     ,p_argument                     => 'assignment_id'
23346     ,p_argument_value               => p_assignment_id
23347     );
23348   --
23349   -- Truncate all date parameters
23350   --
23351   l_effective_date := TRUNC(p_effective_date);
23352   --
23353   -- Issue Savepoint
23354   --
23355   SAVEPOINT set_new_primary_asg;
23356   --
23357  if g_debug then
23358   hr_utility.set_location(l_proc,20);
23359  end if;
23360   --
23361   -- Call Before Process User Hook
23362   --
23363   BEGIN
23364     hr_assignment_bke.set_new_primary_asg_b
23365       (p_effective_date               => l_effective_date
23366       ,p_person_id                    => p_person_id
23367       ,p_assignment_id                => p_assignment_id
23368       ,p_object_version_number        => p_object_version_number
23369       );
23370   EXCEPTION
23371     WHEN hr_api.cannot_find_prog_unit
23372     THEN
23373       hr_api.cannot_find_prog_unit_error
23374         (p_module_name => 'SET_NEW_PRIMARY_ASG'
23375         ,p_hook_type   => 'BP'
23376         );
23377   END;
23378   --
23379  if g_debug then
23380   hr_utility.set_location(l_proc,30);
23381  end if;
23382   --
23383   -- Retrieve old primary assignment details
23384   --
23385   OPEN csr_old_assignment
23386     (p_person_id      => p_person_id
23387     ,p_effective_date => l_effective_date
23388     );
23389   FETCH csr_old_assignment INTO l_old_assignment;
23390   IF csr_old_assignment%NOTFOUND
23391   THEN
23392     CLOSE csr_old_assignment;
23393     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23394     hr_utility.raise_error;
23395   END IF;
23396   CLOSE csr_old_assignment;
23397   --
23398  if g_debug then
23399   hr_utility.set_location(l_proc,40);
23400  end if;
23401   --
23402   -- Retrieve new primary assignment details
23403   --
23404   OPEN csr_new_assignment
23405     (p_assignment_id  => p_assignment_id
23406     ,p_effective_date => l_effective_date
23407     );
23408   FETCH csr_new_assignment INTO l_new_assignment;
23409   IF csr_new_assignment%NOTFOUND
23410   THEN
23411     CLOSE csr_new_assignment;
23412     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23413     hr_utility.raise_error;
23414   END IF;
23415   CLOSE csr_new_assignment;
23416   --
23417  if g_debug then
23418   hr_utility.set_location(l_proc,50);
23419  end if;
23420   --
23421   -- Validate assignment selected to be new primary
23422   --
23423   IF l_new_assignment.person_id <> p_person_id
23424   THEN
23425     hr_utility.set_message(801,'HR_51253_PYP_ASS__NOT_VALID');
23426     hr_utility.raise_error;
23427   END IF;
23428   IF l_new_assignment.assignment_type <> 'E'
23429   THEN
23430     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
23431     hr_utility.raise_error;
23432   END IF;
23433   IF l_new_assignment.primary_flag = 'Y'
23434   THEN
23435     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
23436     hr_utility.raise_error;
23437   END IF;
23438   IF l_new_assignment.max_effective_end_date <> NVL(l_new_assignment.actual_termination_date,hr_api.g_eot)
23439   THEN
23440     hr_utility.set_message(800,'HR_6438_EMP_ASS_NOT_CONTIN');
23441     hr_utility.raise_error;
23442   END IF;
23443   --
23444  if g_debug then
23445   hr_utility.set_location(l_proc,60);
23446  end if;
23447   --
23448   -- End the previous primary assignment
23449   --
23450   -- # 2468916: This should be executed after creating NEW primary
23451   -- assignment. This call is replaced by do_primary_update proc.
23452   --
23453   -- hr_assignment.update_primary
23454   --  (p_assignment_id        => l_old_assignment.assignment_id
23455   --  ,p_period_of_service_id => l_old_assignment.period_of_service_id
23456   --  ,p_new_primary_ass_id   => p_assignment_id
23457   --  ,p_sdate                => l_effective_date
23458   --  ,p_new_primary_flag     => 'Y'
23459   --  ,p_mode                 => hr_api.g_update
23460   --  ,p_last_updated_by      => TO_NUMBER(NULL)
23461   --  ,p_last_update_login    => TO_NUMBER(NULL)
23462   --   );
23463   --
23464  if g_debug then
23465   hr_utility.set_location(l_proc,70);
23466  end if;
23467   --
23468   -- Start the new primary assignment
23469   --
23470   hr_assignment.update_primary
23471     (p_assignment_id        => l_old_assignment.assignment_id        -- #2468916:instead of p_assignment_id
23472     ,p_period_of_service_id => l_old_assignment.period_of_service_id -- #2468916:instead of new.
23473     ,p_new_primary_ass_id   => p_assignment_id
23474     ,p_sdate                => l_effective_date
23475     ,p_new_primary_flag     => 'Y'
23476     ,p_mode                 => hr_api.g_update
23477     ,p_last_updated_by      => TO_NUMBER(NULL)
23478     ,p_last_update_login    => TO_NUMBER(NULL)
23479     );
23480   --
23481  if g_debug then
23482   hr_utility.set_location(l_proc,75);
23483  end if;
23484   --
23485   -- #2468916: End previous assignment
23486   --
23487      hr_assignment.do_primary_update(l_old_assignment.assignment_id   --p_assignment_id
23488                        ,l_effective_date -- p_sdate
23489                        ,'N'              -- primary flag
23490                        ,'N'              -- current asg
23491                        ,TO_NUMBER(NULL)  --p_last_updated_by
23492                        ,TO_NUMBER(NULL)  --p_last_update_login
23493                        );
23494   -- end #2468916
23495   --
23496  if g_debug then
23497   hr_utility.set_location(l_proc,80);
23498  end if;
23499   --
23500   -- Retrieve new primary assignment details
23501   --
23502   OPEN csr_new_assignment
23503     (p_assignment_id  => p_assignment_id
23504     ,p_effective_date => l_effective_date
23505     );
23506   FETCH csr_new_assignment INTO l_new_assignment;
23507   IF csr_new_assignment%NOTFOUND
23508   THEN
23509     CLOSE csr_new_assignment;
23510     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23511     hr_utility.raise_error;
23512   END IF;
23513   CLOSE csr_new_assignment;
23514   --
23515  if g_debug then
23516   hr_utility.set_location(l_proc,90);
23517  end if;
23518   --
23519   -- Call After Process User Hook
23520   --
23521   BEGIN
23522     hr_assignment_bke.set_new_primary_asg_a
23523       (p_effective_date               => l_effective_date
23524       ,p_person_id                    => p_person_id
23525       ,p_assignment_id                => p_assignment_id
23526       ,p_object_version_number        => l_new_assignment.object_version_number
23527       ,p_effective_start_date         => l_new_assignment.effective_start_date
23528       ,p_effective_end_date           => l_new_assignment.effective_end_date
23529       );
23530   EXCEPTION
23531     WHEN hr_api.cannot_find_prog_unit
23532     THEN
23533       hr_api.cannot_find_prog_unit_error
23534         (p_module_name => 'SET_NEW_PRIMARY_ASG'
23535         ,p_hook_type   => 'AP'
23536         );
23537   END;
23538   --
23539  if g_debug then
23540   hr_utility.set_location(l_proc,100);
23541  end if;
23542   --
23543   -- When in validation only mode raise validate enabled exception
23544   --
23545   IF p_validate
23546   THEN
23547     RAISE hr_api.validate_enabled;
23548   END IF;
23549   --
23550   -- Set OUT parameters
23551   --
23552   p_object_version_number := l_new_assignment.object_version_number;
23553   p_effective_start_date  := l_new_assignment.effective_start_date;
23554   p_effective_end_date    := l_new_assignment.effective_end_date;
23555   --
23556  if g_debug then
23557   hr_utility.set_location(' Leaving:'||l_proc,1000);
23558  end if;
23559 --
23560 EXCEPTION
23561   WHEN hr_api.validate_enabled
23562   THEN
23563     --
23564     -- In validation only mode
23565     -- Rollback to savepoint
23566     -- Set relevant output warning parmeters
23567     -- Reset any key or derived values
23568     --
23569     ROLLBACK TO set_new_primary_asg;
23570     p_object_version_number := l_object_version_number;
23571     p_effective_start_date  := NULL;
23572     p_effective_end_date    := NULL;
23573   --
23574   WHEN OTHERS
23575   THEN
23576     --
23577     -- Validation or unexpected error
23578     -- Rollback to savepoint
23579     -- Re-raise exception
23580     --
23581     p_object_version_number := lv_object_version_number;
23582     p_effective_start_date   := null;
23583     p_effective_end_date     := null;
23584 
23585     ROLLBACK TO set_new_primary_asg;
23586     RAISE;
23587 --
23588 END set_new_primary_asg;
23589 --
23590 PROCEDURE set_new_primary_cwk_asg
23591   (p_validate                    IN     BOOLEAN
23592   ,p_effective_date              IN     DATE
23593   ,p_person_id                   IN     per_all_people_f.person_id%TYPE
23594   ,p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
23595   ,p_object_version_number       IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
23596   ,p_effective_start_date           OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
23597   ,p_effective_end_date             OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
23598   )
23599 IS
23600   --
23601   -- Local Variables
23602   --
23603   l_proc                        VARCHAR2(72) := g_package||'set_new_primary_cwk_asg';
23604   --
23605   l_effective_date              DATE;
23606   l_object_version_number       CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
23607   l_effective_start_date        per_all_assignments_f.effective_start_date%TYPE;
23608   l_effective_end_date          per_all_assignments_f.effective_end_date%TYPE;
23609   --
23610   lv_object_version_number     number := p_object_version_number ;
23611   --
23612   -- Local cursors
23613   --
23614   CURSOR csr_new_assignment
23615     (p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
23616     ,p_effective_date              IN     DATE) IS
23617     SELECT asg.object_version_number
23618           ,asg.assignment_type
23619           ,asg.period_of_placement_date_start
23620           ,asg.person_id
23621           ,asg.primary_flag
23622           ,asg.effective_start_date
23623           ,asg.effective_end_date
23624           ,MAX(mxa.effective_end_date) AS max_effective_end_date
23625           ,pop.actual_termination_date
23626       FROM per_all_assignments_f asg
23627           ,per_all_assignments_f mxa
23628           ,per_periods_of_placement pop
23629      WHERE pop.person_id  (+) = asg.person_id
23630 	   AND pop.date_start (+) = asg.period_of_placement_date_start
23631        AND mxa.assignment_id = asg.assignment_id
23632        AND asg.assignment_id = csr_new_assignment.p_assignment_id
23633        AND csr_new_assignment.p_effective_date BETWEEN asg.effective_start_date
23634                                                    AND asg.effective_end_date
23635   GROUP BY asg.object_version_number
23636           ,asg.assignment_type
23637           ,asg.period_of_placement_date_start
23638           ,asg.person_id
23639           ,asg.primary_flag
23640           ,asg.effective_start_date
23641           ,asg.effective_end_date
23642           ,pop.actual_termination_date;
23643   --
23644   CURSOR csr_old_assignment
23645     (p_person_id       IN     per_all_people_f.person_id%TYPE
23646     ,p_effective_date  IN     DATE) IS
23647     SELECT asg.assignment_id
23648           ,asg.assignment_type
23649           ,asg.period_of_placement_date_start
23650           ,asg.primary_flag
23651           ,asg.person_id
23652           ,asg.effective_start_date
23653           ,asg.effective_end_date
23654       FROM per_all_assignments_f asg
23655      WHERE asg.person_id = csr_old_assignment.p_person_id
23656        AND csr_old_assignment.p_effective_date BETWEEN asg.effective_start_date
23657                                                    AND asg.effective_end_date
23658        AND asg.primary_flag = 'Y'
23659        AND asg.assignment_type = 'C';
23660  --
23661  l_old_assignment csr_old_assignment%ROWTYPE;
23662  l_new_assignment csr_new_assignment%ROWTYPE;
23663   --
23664 BEGIN
23665   --
23666  if g_debug then
23667   hr_utility.set_location('Entering:'||l_proc,10);
23668  end if;
23669   --
23670   -- Ensure mandatory parameters have been passed
23671   --
23672   hr_api.mandatory_arg_error
23673     (p_api_name                     => l_proc
23674     ,p_argument                     => 'effective_date'
23675     ,p_argument_value               => p_effective_date
23676     );
23677   --
23678   hr_api.mandatory_arg_error
23679     (p_api_name                     => l_proc
23680     ,p_argument                     => 'person_id'
23681     ,p_argument_value               => p_person_id
23682     );
23683   --
23684   hr_api.mandatory_arg_error
23685     (p_api_name                     => l_proc
23686     ,p_argument                     => 'assignment_id'
23687     ,p_argument_value               => p_assignment_id
23688     );
23689   --
23690   -- Truncate all date parameters
23691   --
23692   l_effective_date := TRUNC(p_effective_date);
23693   --
23694   -- Issue Savepoint
23695   --
23696   SAVEPOINT set_new_primary_cwk_asg;
23697   --
23698  if g_debug then
23699   hr_utility.set_location(l_proc,20);
23700  end if;
23701   --
23702   -- Call Before Process User Hook
23703   --
23704   BEGIN
23705     --
23706     hr_assignment_bki.set_new_primary_cwk_asg_b
23707       (p_effective_date               => l_effective_date
23708       ,p_person_id                    => p_person_id
23709       ,p_assignment_id                => p_assignment_id
23710       ,p_object_version_number        => p_object_version_number);
23711     --
23712   EXCEPTION
23713     --
23714     WHEN hr_api.cannot_find_prog_unit THEN
23715       --
23716       hr_api.cannot_find_prog_unit_error
23717         (p_module_name => 'set_new_primary_cwk_asg'
23718         ,p_hook_type   => 'BP');
23719       --
23720   END;
23721   --
23722  if g_debug then
23723   hr_utility.set_location(l_proc,30);
23724  end if;
23725   --
23726   -- Retrieve old primary assignment details
23727   --
23728   OPEN csr_old_assignment
23729     (p_person_id      => p_person_id
23730     ,p_effective_date => l_effective_date);
23731   --
23732   FETCH csr_old_assignment INTO l_old_assignment;
23733   --
23734   IF csr_old_assignment%NOTFOUND THEN
23735     --
23736     CLOSE csr_old_assignment;
23737     --
23738     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23739     hr_utility.raise_error;
23740 	--
23741   END IF;
23742   --
23743   CLOSE csr_old_assignment;
23744   --
23745  if g_debug then
23746   hr_utility.set_location(l_proc,40);
23747  end if;
23748   --
23749   -- Retrieve new primary assignment details
23750   --
23751   OPEN csr_new_assignment
23752     (p_assignment_id  => p_assignment_id
23753     ,p_effective_date => l_effective_date);
23754   --
23755   FETCH csr_new_assignment INTO l_new_assignment;
23756   --
23757   IF csr_new_assignment%NOTFOUND THEN
23758     --
23759     CLOSE csr_new_assignment;
23760 	--
23761     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23762     hr_utility.raise_error;
23763 	--
23764   END IF;
23765   --
23766   CLOSE csr_new_assignment;
23767   --
23768  if g_debug then
23769   hr_utility.set_location(l_proc,50);
23770  end if;
23771   --
23772   -- Validate assignment selected to be new primary
23773   --
23774   IF l_new_assignment.person_id <> p_person_id THEN
23775     --
23776     hr_utility.set_message(801,'HR_51253_PYP_ASS__NOT_VALID');
23777     hr_utility.raise_error;
23778 	--
23779   END IF;
23780   --
23781   IF l_new_assignment.assignment_type <> 'C' THEN
23782     --
23783 	--hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
23784     hr_utility.set_message(801,'XXX');
23785     hr_utility.raise_error;
23786 	--
23787   END IF;
23788   --
23789   IF l_new_assignment.primary_flag = 'Y' THEN
23790     --
23791     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
23792     hr_utility.raise_error;
23793 	--
23794   END IF;
23795   --
23796   IF l_new_assignment.max_effective_end_date <>
23797      NVL(l_new_assignment.actual_termination_date,hr_api.g_eot) THEN
23798     --
23799     hr_utility.set_message(800,'HR_6438_EMP_ASS_NOT_CONTIN');
23800     hr_utility.raise_error;
23801 	--
23802   END IF;
23803   --
23804  if g_debug then
23805   hr_utility.set_location(l_proc,60);
23806  end if;
23807   --
23808   -- End the previous primary assignment
23809   --
23810   hr_assignment.update_primary_cwk
23811     (p_assignment_id        => l_old_assignment.assignment_id
23812     ,p_person_id            => p_person_id
23813     ,p_pop_date_start       => l_old_assignment.period_of_placement_date_start
23814     ,p_new_primary_ass_id   => p_assignment_id
23815     ,p_sdate                => l_effective_date
23816     ,p_new_primary_flag     => 'Y'
23817     ,p_mode                 => hr_api.g_update
23818     ,p_last_updated_by      => TO_NUMBER(NULL)
23819     ,p_last_update_login    => TO_NUMBER(NULL)
23820     );
23821   --
23822  if g_debug then
23823   hr_utility.set_location(l_proc,70);
23824  end if;
23825   --
23826   -- Start the new primary assignment
23827   --
23828   hr_assignment.update_primary_cwk
23829     (p_assignment_id        => p_assignment_id
23830     ,p_person_id            => p_person_id
23831     ,p_pop_date_start       => l_new_assignment.period_of_placement_date_start
23832     ,p_new_primary_ass_id   => p_assignment_id
23833     ,p_sdate                => l_effective_date
23834     ,p_new_primary_flag     => 'Y'
23835     ,p_mode                 => hr_api.g_update
23836     ,p_last_updated_by      => TO_NUMBER(NULL)
23837     ,p_last_update_login    => TO_NUMBER(NULL)
23838     );
23839   --
23840  if g_debug then
23841   hr_utility.set_location(l_proc,80);
23842  end if;
23843   --
23844   -- Retrieve new primary assignment details
23845   --
23846   OPEN csr_new_assignment
23847     (p_assignment_id  => p_assignment_id
23848     ,p_effective_date => l_effective_date);
23849   --
23850   FETCH csr_new_assignment INTO l_new_assignment;
23851   --
23852   IF csr_new_assignment%NOTFOUND THEN
23853     --
23854     CLOSE csr_new_assignment;
23855     --
23856     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
23857     hr_utility.raise_error;
23858 	--
23859   END IF;
23860   --
23861   CLOSE csr_new_assignment;
23862   --
23863  if g_debug then
23864   hr_utility.set_location(l_proc,90);
23865  end if;
23866   --
23867   -- Call After Process User Hook
23868   --
23869   BEGIN
23870     --
23871     hr_assignment_bki.set_new_primary_cwk_asg_a
23872       (p_effective_date               => l_effective_date
23873       ,p_person_id                    => p_person_id
23874       ,p_assignment_id                => p_assignment_id
23875       ,p_object_version_number        => l_new_assignment.object_version_number
23876       ,p_effective_start_date         => l_new_assignment.effective_start_date
23877       ,p_effective_end_date           => l_new_assignment.effective_end_date);
23878     --
23879   EXCEPTION
23880     --
23881     WHEN hr_api.cannot_find_prog_unit THEN
23882       --
23883       hr_api.cannot_find_prog_unit_error
23884         (p_module_name => 'set_new_primary_cwk_asg'
23885         ,p_hook_type   => 'AP');
23886       --
23887   END;
23888   --
23889  if g_debug then
23890   hr_utility.set_location(l_proc,100);
23891  end if;
23892   --
23893   -- When in validation only mode raise validate enabled exception
23894   --
23895   IF p_validate THEN
23896     --
23897     RAISE hr_api.validate_enabled;
23898 	--
23899   END IF;
23900   --
23901   -- Set OUT parameters
23902   --
23903   p_object_version_number := l_new_assignment.object_version_number;
23904   p_effective_start_date  := l_new_assignment.effective_start_date;
23905   p_effective_end_date    := l_new_assignment.effective_end_date;
23906   --
23907  if g_debug then
23908   hr_utility.set_location(' Leaving:'||l_proc,999);
23909  end if;
23910   --
23911 EXCEPTION
23912   --
23913   WHEN hr_api.validate_enabled THEN
23914     --
23915     -- In validation only mode
23916     -- Rollback to savepoint
23917     -- Set relevant output warning parmeters
23918     -- Reset any key or derived values
23919     --
23920     ROLLBACK TO set_new_primary_cwk_asg;
23921     --
23922     p_object_version_number := l_object_version_number;
23923     p_effective_start_date  := NULL;
23924     p_effective_end_date    := NULL;
23925     --
23926   WHEN OTHERS THEN
23927     --
23928     -- Validation or unexpected error
23929     -- Rollback to savepoint
23930     -- Re-raise exception
23931     --
23932     p_object_version_number := lv_object_version_number;
23933     p_effective_start_date   := null;
23934     p_effective_end_date     := null;
23935 
23936     ROLLBACK TO set_new_primary_cwk_asg;
23937     RAISE;
23938     --
23939 END set_new_primary_cwk_asg;
23940 --
23941 --
23942 -- -----------------------------------------------------------------------------
23943 -- |--------------------------< interview1_apl_asg >---------------------------|
23944 -- -----------------------------------------------------------------------------
23945 --
23946 PROCEDURE interview1_apl_asg
23947   (p_validate                     IN     BOOLEAN
23948   ,p_effective_date               IN     DATE
23949   ,p_datetrack_update_mode        IN     VARCHAR2
23950   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
23951   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
23952   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
23953   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
23954   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
23955   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
23956   )
23957 IS
23958   --
23959   -- Local variables
23960   --
23961   l_proc                       VARCHAR2(72);
23962   --
23963   l_effective_date             DATE;
23964   --
23965   l_object_version_number      CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
23966   --
23967   l_expected_system_status     per_assignment_status_types.per_system_status%TYPE := 'INTERVIEW1';
23968   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
23969   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
23970 --
23971   lv_object_version_number     number := p_object_version_number ;
23972 --
23973 BEGIN
23974   --
23975  if g_debug then
23976   l_proc := g_package||'interview1_apl_asg';
23977   hr_utility.set_location('Entering:'||l_proc,10);
23978  end if;
23979   --
23980   -- Truncate all date parameters passed in
23981   --
23982   l_effective_date := TRUNC(p_effective_date);
23983   --
23984   -- Issue savepoint
23985   --
23986   SAVEPOINT interview1_apl_asg;
23987   --
23988  if g_debug then
23989   hr_utility.set_location(l_proc,20);
23990  end if;
23991   --
23992   -- Call Before Process User Hook
23993   --
23994   BEGIN
23995      hr_assignment_bkf.interview1_apl_asg_b
23996        (p_effective_date               => l_effective_date
23997        ,p_datetrack_update_mode        => p_datetrack_update_mode
23998        ,p_assignment_id                => p_assignment_id
23999        ,p_object_version_number        => p_object_version_number
24000        ,p_assignment_status_type_id    => p_assignment_status_type_id
24001        ,p_change_reason                => p_change_reason
24002        );
24003   EXCEPTION
24004      WHEN hr_api.cannot_find_prog_unit
24005      THEN
24006        hr_api.cannot_find_prog_unit_error
24007          (p_module_name       => 'INTERVIEW1_APL_ASG',
24008           p_hook_type         => 'BP'
24009          );
24010   END;
24011   --
24012  if g_debug then
24013   hr_utility.set_location(l_proc,30);
24014  end if;
24015   --
24016   -- Call business support process to update status type
24017   --
24018   hr_assignment_internal.update_status_type_apl_asg
24019     (p_effective_date               => l_effective_date
24020     ,p_datetrack_update_mode        => p_datetrack_update_mode
24021     ,p_assignment_id                => p_assignment_id
24022     ,p_object_version_number        => p_object_version_number
24023     ,p_expected_system_status       => l_expected_system_status
24024     ,p_assignment_status_type_id    => p_assignment_status_type_id
24025     ,p_change_reason                => p_change_reason
24026     ,p_effective_start_date         => l_effective_start_date
24027     ,p_effective_end_date           => l_effective_end_date
24028     );
24029   --
24030  if g_debug then
24031   hr_utility.set_location(l_proc,40);
24032  end if;
24033   --
24034   -- Call After Process User Hook
24035   --
24036   BEGIN
24037      hr_assignment_bkf.interview1_apl_asg_a
24038        (p_effective_date               => l_effective_date
24039        ,p_datetrack_update_mode        => p_datetrack_update_mode
24040        ,p_assignment_id                => p_assignment_id
24041        ,p_object_version_number        => p_object_version_number
24042        ,p_assignment_status_type_id    => p_assignment_status_type_id
24043        ,p_change_reason                => p_change_reason
24044        ,p_effective_start_date         => l_effective_start_date
24045        ,p_effective_end_date           => l_effective_end_date
24046        );
24047   EXCEPTION
24048      WHEN hr_api.cannot_find_prog_unit
24049      THEN
24050        hr_api.cannot_find_prog_unit_error
24051          (p_module_name => 'INTERVIEW1_APL_ASG',
24052           p_hook_type   => 'AP'
24053          );
24054   END;
24055   --
24056  if g_debug then
24057   hr_utility.set_location(l_proc,50);
24058  end if;
24059   --
24060   -- When in validation only mode raise validate_enabled exception
24061   --
24062   IF p_validate
24063   THEN
24064     RAISE hr_api.validate_enabled;
24065   END IF;
24066   --
24067   -- Set OUT parameters
24068   --
24069   p_effective_start_date         := l_effective_start_date;
24070   p_effective_end_date           := l_effective_end_date;
24071   --
24072  if g_debug then
24073   hr_utility.set_location(' Leaving:'||l_proc,100);
24074  end if;
24075 --
24076 EXCEPTION
24077   WHEN hr_api.validate_enabled
24078   THEN
24079     --
24080     -- In validation only mode
24081     -- Rollback to savepoint
24082     -- Set relevant output warning arguments
24083     -- Reset any key or derived arguments
24084     --
24085     ROLLBACK TO interview1_apl_asg;
24086     p_object_version_number        := l_object_version_number;
24087     p_effective_start_date         := NULL;
24088     p_effective_end_date           := NULL;
24089   --
24090   WHEN OTHERS
24091   THEN
24092     --
24093     -- Validation or unexpected error occured
24094     -- Rollback to savepoint
24095     -- Re-raise exception
24096     --
24097     p_object_version_number := lv_object_version_number;
24098     p_effective_start_date   := null;
24099     p_effective_end_date     := null;
24100 
24101     ROLLBACK TO interview1_apl_asg;
24102     RAISE;
24103 --
24104 END interview1_apl_asg;
24105 --
24106 -- -----------------------------------------------------------------------------
24107 -- |--------------------------< interview2_apl_asg >---------------------------|
24108 -- -----------------------------------------------------------------------------
24109 --
24110 PROCEDURE interview2_apl_asg
24111   (p_validate                     IN     BOOLEAN
24112   ,p_effective_date               IN     DATE
24113   ,p_datetrack_update_mode        IN     VARCHAR2
24114   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
24115   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
24116   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
24117   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
24118   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
24119   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
24120   )
24121 IS
24122   --
24123   -- Local variables
24124   --
24125   l_proc                       VARCHAR2(72);
24126   --
24127   l_effective_date             DATE;
24128   --
24129   l_object_version_number      CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
24130   --
24131   l_expected_system_status     per_assignment_status_types.per_system_status%TYPE := 'INTERVIEW2';
24132   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
24133   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
24134 --
24135   lv_object_version_number     number := p_object_version_number ;
24136 --
24137 BEGIN
24138   --
24139  if g_debug then
24140   l_proc := g_package||'interview2_apl_asg';
24141   hr_utility.set_location('Entering:'||l_proc,10);
24142  end if;
24143   --
24144   -- Truncate all date parameters passed in
24145   --
24146   l_effective_date := TRUNC(p_effective_date);
24147   --
24148   -- Issue savepoint
24149   --
24150   SAVEPOINT interview2_apl_asg;
24151   --
24152  if g_debug then
24153   hr_utility.set_location(l_proc,20);
24154  end if;
24155   --
24156   -- Call Before Process User Hook
24157   --
24158   BEGIN
24159      hr_assignment_bkg.interview2_apl_asg_b
24160        (p_effective_date               => l_effective_date
24161        ,p_datetrack_update_mode        => p_datetrack_update_mode
24162        ,p_assignment_id                => p_assignment_id
24163        ,p_object_version_number        => p_object_version_number
24164        ,p_assignment_status_type_id    => p_assignment_status_type_id
24165        ,p_change_reason                => p_change_reason
24166        );
24167   EXCEPTION
24168      WHEN hr_api.cannot_find_prog_unit
24169      THEN
24170        hr_api.cannot_find_prog_unit_error
24171          (p_module_name       => 'INTERVIEW2_APL_ASG',
24172           p_hook_type         => 'BP'
24173          );
24174   END;
24175   --
24176  if g_debug then
24177   hr_utility.set_location(l_proc,30);
24178  end if;
24179   --
24180   -- Call business support process to update status type
24181   --
24182   hr_assignment_internal.update_status_type_apl_asg
24183     (p_effective_date               => l_effective_date
24184     ,p_datetrack_update_mode        => p_datetrack_update_mode
24185     ,p_assignment_id                => p_assignment_id
24186     ,p_object_version_number        => p_object_version_number
24187     ,p_expected_system_status       => l_expected_system_status
24188     ,p_assignment_status_type_id    => p_assignment_status_type_id
24189     ,p_change_reason                => p_change_reason
24190     ,p_effective_start_date         => l_effective_start_date
24191     ,p_effective_end_date           => l_effective_end_date
24192     );
24193   --
24194  if g_debug then
24195   hr_utility.set_location(l_proc,40);
24196  end if;
24197   --
24198   -- Call After Process User Hook
24199   --
24200   BEGIN
24201      hr_assignment_bkg.interview2_apl_asg_a
24202        (p_effective_date               => l_effective_date
24203        ,p_datetrack_update_mode        => p_datetrack_update_mode
24204        ,p_assignment_id                => p_assignment_id
24205        ,p_object_version_number        => p_object_version_number
24206        ,p_assignment_status_type_id    => p_assignment_status_type_id
24207        ,p_change_reason                => p_change_reason
24208        ,p_effective_start_date         => l_effective_start_date
24209        ,p_effective_end_date           => l_effective_end_date
24210        );
24211   EXCEPTION
24212      WHEN hr_api.cannot_find_prog_unit
24213      THEN
24214        hr_api.cannot_find_prog_unit_error
24215          (p_module_name => 'INTERVIEW2_APL_ASG',
24216           p_hook_type   => 'AP'
24217          );
24218   END;
24219   --
24220  if g_debug then
24221   hr_utility.set_location(l_proc,50);
24222  end if;
24223   --
24224   -- When in validation only mode raise validate_enabled exception
24225   --
24226   IF p_validate
24227   THEN
24228     RAISE hr_api.validate_enabled;
24229   END IF;
24230   --
24231   -- Set OUT parameters
24232   --
24233   p_effective_start_date         := l_effective_start_date;
24234   p_effective_end_date           := l_effective_end_date;
24235   --
24236  if g_debug then
24237   hr_utility.set_location(' Leaving:'||l_proc,100);
24238  end if;
24239 --
24240 EXCEPTION
24241   WHEN hr_api.validate_enabled
24242   THEN
24243     --
24244     -- In validation only mode
24245     -- Rollback to savepoint
24246     -- Set relevant output warning arguments
24247     -- Reset any key or derived arguments
24248     --
24249     ROLLBACK TO interview2_apl_asg;
24250     p_object_version_number        := l_object_version_number;
24251     p_effective_start_date         := NULL;
24252     p_effective_end_date           := NULL;
24253   --
24254   WHEN OTHERS
24255   THEN
24256     --
24257     -- Validation or unexpected error occured
24258     -- Rollback to savepoint
24259     -- Re-raise exception
24260     --
24261     p_object_version_number := lv_object_version_number;
24262     p_effective_start_date   := null;
24263     p_effective_end_date     := null;
24264 
24265     ROLLBACK TO interview2_apl_asg;
24266     RAISE;
24267 --
24268 END interview2_apl_asg;
24269 --
24270 --
24271 -- -----------------------------------------------------------------------------
24272 -- |--------------------------< delete_assignment >-----------------------------|
24273 -- -----------------------------------------------------------------------------
24274 --
24275 PROCEDURE delete_assignment
24276   (p_validate                     IN     boolean default false
24277   ,p_effective_date               IN     DATE
24278   ,p_datetrack_mode               IN     VARCHAR2
24279   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
24280   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
24281   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
24282   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
24283   ,p_loc_change_tax_issues           OUT NOCOPY boolean
24284   ,p_delete_asg_budgets              OUT NOCOPY boolean
24285   ,p_org_now_no_manager_warning      OUT NOCOPY boolean
24286   ,p_element_salary_warning          OUT NOCOPY boolean
24287   ,p_element_entries_warning         OUT NOCOPY boolean
24288   ,p_spp_warning                     OUT NOCOPY boolean
24289   ,P_cost_warning                    OUT NOCOPY Boolean
24290   ,p_life_events_exists   	     OUT NOCOPY Boolean
24291   ,p_cobra_coverage_elements         OUT NOCOPY Boolean
24292   ,p_assgt_term_elements             OUT NOCOPY Boolean)
24293 IS
24294   l_effective_date date;
24295   l_validate boolean;
24296   --
24297   l_proc    varchar2(72) := g_package||'delete_assignment';
24298   asg_type  varchar2(10);
24299   --
24300   cursor get_asgt_type is
24301      select assignment_type
24302        from per_all_assignments_f
24303       where assignment_id = p_assignment_id
24304         and p_effective_date between effective_start_date and effective_end_date;
24305   --
24306 BEGIN
24307   --
24308   if g_debug then
24309     hr_utility.set_location('Entering:'|| l_proc, 5);
24310     hr_utility.set_location('p_effective_date:'|| to_char(p_effective_date,'DD/MM/YYYY'), 5);
24311     hr_utility.set_location('p_assignment_id :'|| p_assignment_id, 5);
24312   end if;
24313   --
24314   l_effective_date  := trunc(p_effective_date);
24315   l_validate        := p_validate ;
24316   --
24317   -- Issue a savepoint.
24318   --
24319   savepoint hr_delete_assignment;
24320   --
24321   if g_debug then
24322     hr_utility.set_location(l_proc, 6);
24323   end if;
24324   --
24325   open get_asgt_type;
24326   fetch get_asgt_type into asg_type;
24327   if get_asgt_type%notfound then
24328      close get_asgt_type;
24329   else
24330       --
24331       close get_asgt_type;
24332       if asg_type = 'B' then
24333          if g_debug then
24334             hr_utility.set_location('Selected assignment is of type Benifit', 10);
24335          end if;
24336          --
24337          fnd_message.set_name('PER', 'HR_449746_DEL_BEN_ASG');
24338          fnd_message.raise_error;
24339       end if;
24340       --
24341   end if;
24342   --
24343   begin
24344     --
24345     -- Start of API User Hook for the before hook of delete_assignment
24346     --
24347     hr_assignment_bkp.delete_assignment_b
24348       (p_effective_date               => l_effective_date
24349       ,p_assignment_id                => p_assignment_id
24350       ,p_datetrack_mode               => p_datetrack_mode
24351       );
24352     --
24353   exception
24354     when hr_api.cannot_find_prog_unit then
24355       hr_api.cannot_find_prog_unit_error
24356         (p_module_name => 'DELETE_ASSIGNMENT'
24357         ,p_hook_type   => 'BP'
24358         );
24359     --
24360     -- End of API User Hook for the before hook of delete_assignment
24361     --
24362   end;
24363   --
24364   per_asg_del.del(
24365      p_validate                     =>  p_validate
24366     ,p_assignment_id                =>  p_assignment_id
24367     ,p_effective_date               =>  p_effective_date
24368     ,p_datetrack_mode               =>  p_datetrack_mode
24369     ,p_object_version_number        =>  p_object_version_number
24370     ,p_effective_start_date         =>  p_effective_start_date
24371     ,p_effective_end_date           =>  p_effective_end_date
24372     ,p_loc_change_tax_issues        =>  p_loc_change_tax_issues
24373     ,p_delete_asg_budgets           =>  p_delete_asg_budgets
24374     ,p_org_now_no_manager_warning   =>  p_org_now_no_manager_warning
24375     ,p_element_salary_warning       =>  p_element_salary_warning
24376     ,p_element_entries_warning      =>  p_element_entries_warning
24377     ,p_spp_warning                  =>  p_spp_warning
24378     ,P_cost_warning                 =>  P_cost_warning
24379     ,p_life_events_exists           =>  p_life_events_exists
24380     ,p_cobra_coverage_elements      =>  p_cobra_coverage_elements
24381     ,p_assgt_term_elements          =>  p_assgt_term_elements );
24382   --
24383   begin
24384     --
24385     -- Start of API User Hook for the after hook of delete_assignment
24386     --
24387     hr_assignment_bkp.delete_assignment_a
24388       (p_effective_date               => l_effective_date
24389       ,p_assignment_id                => p_assignment_id
24390       ,p_datetrack_mode               => p_datetrack_mode
24391       ,p_loc_change_tax_issues        => p_loc_change_tax_issues
24392       ,p_delete_asg_budgets           => p_delete_asg_budgets
24393       ,p_org_now_no_manager_warning   => p_org_now_no_manager_warning
24394       ,p_element_salary_warning       => p_element_salary_warning
24395       ,p_element_entries_warning      => p_element_entries_warning
24396       ,p_spp_warning                  => p_spp_warning
24397       ,P_cost_warning                 => P_cost_warning
24398       ,p_life_events_exists           => p_life_events_exists
24399       ,p_cobra_coverage_elements      => p_cobra_coverage_elements
24400       ,p_assgt_term_elements          => p_assgt_term_elements );
24401   exception
24402     when hr_api.cannot_find_prog_unit then
24403       hr_api.cannot_find_prog_unit_error
24404         (p_module_name => 'DELETE_ASSIGNMENT'
24405         ,p_hook_type   => 'AP'
24406         );
24407     --
24408     -- End of API User Hook for the after hook of delete_person
24409     --
24410   end;
24411   --
24412 
24413   if p_validate then
24414     raise hr_api.validate_enabled;
24415   end if;
24416   --
24417   if g_debug then
24418     hr_utility.set_location(' Leaving:'||l_proc, 100);
24419   end if;
24420   --
24421   exception
24422    when hr_api.validate_enabled then
24423     --
24424     -- As the Validate_Enabled exception has been raised
24425     -- we must rollback to the savepoint
24426     --
24427     p_loc_change_tax_issues          := null;
24428     p_delete_asg_budgets             := null;
24429     p_org_now_no_manager_warning     := null;
24430     p_element_salary_warning         := null;
24431     p_element_entries_warning        := null;
24432     p_spp_warning                    := null;
24433     P_cost_warning                   := null;
24434     p_life_events_exists   	     := null;
24435     p_cobra_coverage_elements        := null;
24436     p_assgt_term_elements            := null;
24437     --
24438     ROLLBACK TO hr_delete_assignment;
24439     --
24440   when others then
24441     --
24442     -- A validation or unexpected error has occurred
24443     --
24444     p_loc_change_tax_issues          := null;
24445     p_delete_asg_budgets             := null;
24446     p_org_now_no_manager_warning     := null;
24447     p_element_salary_warning         := null;
24448     p_element_entries_warning        := null;
24449     p_spp_warning                    := null;
24450     P_cost_warning                   := null;
24451     p_life_events_exists   	     := null;
24452     p_cobra_coverage_elements        := null;
24453     p_assgt_term_elements            := null;
24454     --
24455     ROLLBACK TO hr_delete_assignment;
24456     raise;
24457   --
24458 END; -- End of delete_assignment Procedure
24459 --
24460 END hr_assignment_api;