DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_PERASGADD_RIW

Source


1 PACKAGE BODY PQP_PERASGADD_RIW  as
2 /* $Header: pqpaariw.pkb 120.30 2012/01/19 07:28:57 rpahune ship $ */
3 
4 -- =============================================================================
5 -- ~ Package Body Global variables:
6 -- =============================================================================
7   g_pkg                constant varchar2(150) := 'PQP_PerAsgAdd_RIW.';
8   g_debug                       boolean;
9   g_leg_code                    varchar2(5);
10   g_emp_num_gen                 varchar2(5);
11   g_apl_num_gen                 varchar2(5);
12   g_cwk_num_gen                 varchar2(5);
13   g_business_group_id           number(15);
14 
15   g_per_rec                     per_all_people_f%rowtype;
16   g_scl_rec                     hr_soft_coding_keyflex%rowtype;
17   g_add_rec                     per_addresses%rowtype;
18   g_grp_rec                     pay_people_groups%rowtype;
19   g_asg_rec                     per_all_assignments_f%rowtype;
20   g_phn_rec                     per_phones%rowtype;
21   g_cnt_rec                     per_contact_relationships%rowtype;
22   g_interface_code              varchar2(150);
23   g_migration_flag              varchar2(5);
24 
25   --$ Added by Dbansal to upload comments
26   g_per_comments                varchar2(150);
27   g_asg_comments                varchar2(150);
28   g_sec_asg_flag                number :=0;
29     --$ To upload supervisor id
30   g_supervisor_user_key     varchar2(240);
31     --$ To Upload Benefit Group Name in HR Pump Batch Lines
32   g_benefit_grp_name        varchar2(100);
33     --$ Get upload mode - "Create and Update" (C) or "Update Only" (U)
34     -- or "View/Download Only" (D)
35   g_crt_upd                 varchar2 (1):= 'D'; -- By default 'Download only'
36                                                 -- i.e. uploading data not allowed
37     --$ Exceptions
38   e_upl_not_allowed exception; -- when mode is 'View Only'
39   e_crt_per_not_allowed exception;
40   e_crt_asg_not_allowed exception;
41   e_crt_add_not_allowed exception;
42 
43   g_upl_err_msg varchar2(100) := 'Upload NOT allowed.';
44   g_crt_per_err_msg varchar2(100) := 'Creating new person is NOT allowed.'; -- this includes converting a person
45                                            -- to an employee also
46   g_crt_asg_err_msg varchar2(100) := 'Creating new assignment is NOT allowed.';
47   g_crt_add_err_msg varchar2(100) := 'Creating new address is NOT allowed.';
48 
49   type ref_cur_typ is ref cursor;
50 
51   type t_hrempapi is record
52   (person_id                    per_all_people_f.person_id%type
53   ,assignment_id                per_all_assignments_f.assignment_id%type
54   ,per_object_version_number    per_all_people_f.object_version_number%type
55   ,asg_object_version_number    per_all_assignments_f.object_version_number%type
56   ,per_effective_start_date     date
57   ,per_effective_end_date       date
58   ,full_name                    per_all_people_f.full_name%type
59   ,per_comment_id               per_all_people_f.comment_id%type
60   ,assignment_sequence          per_all_assignments_f.assignment_sequence%type
61   ,assignment_number            per_all_assignments_f.assignment_number%type
62   ,pdp_object_version_number    per_all_people_f.object_version_number%type
63   ,name_combination_warning     boolean
64   ,assign_payroll_warning       boolean
65   ,orig_hire_warning            boolean
66   );
67 
68   type t_asgupdcrit_api is record
69   (asg_object_version_number    per_all_assignments_f.object_version_number%type
70   ,special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%type
71   ,people_group_id              per_all_assignments_f.people_group_id%type
72   ,soft_coding_keyflex_id       per_all_assignments_f.soft_coding_keyflex_id%type
73   ,group_name                   pay_people_groups.group_name%type
74   ,asg_effective_start_date     per_all_assignments_f.effective_start_date%type
75   ,asg_effective_end_date       per_all_assignments_f.effective_end_date%type
76   ,org_now_no_manager_warning   boolean
77   ,other_manager_warning        boolean
78   ,spp_delete_warning           boolean
79   ,entries_changed_warning      varchar2(50)
80   ,tax_district_changed_warning boolean
81   ,concatenated_segments        hr_soft_coding_keyflex.concatenated_segments%type
82   ,gsp_post_process_warning     varchar2(2000)
83   ,comment_id                   per_all_assignments_f.comment_id%type
84   );
85 
86   type t_upd_emp_asg_api is record
87   (cagr_grade_def_id            per_all_assignments_f.cagr_grade_def_id%type
88   ,cagr_concatenated_segments   varchar2(2000)
89   ,concatenated_segments        varchar2(2000)
90   ,soft_coding_keyflex_id       per_all_assignments_f.soft_coding_keyflex_id%type
91   ,comment_id                   per_all_assignments_f.comment_id%type
92   ,effective_start_date         per_all_assignments_f.effective_start_date%type
93   ,effective_end_date           per_all_assignments_f.effective_end_date%type
94   ,no_managers_warning          boolean
95   ,other_manager_warning        boolean
96   ,hourly_salaried_warning      boolean
97   ,gsp_post_process_warning     varchar2(2000)
98   );
99 
100   type t_rehireemp_api is record
101   (assignment_id                per_all_assignments_f.assignment_id%type
102   ,asg_object_version_number    per_all_assignments_f.object_version_number%type
103   ,per_effective_start_date     per_all_people_f.effective_start_date%type
104   ,per_effective_end_date       per_all_people_f.effective_end_date%type
105   ,assignment_sequence          per_all_assignments_f.assignment_sequence%type
106   ,assignment_number            per_all_assignments_f.assignment_number%type
107   ,assign_payroll_warning       boolean
108   );
109 
110   type t_updemp_api is record
111   (effective_start_date        per_all_people_f.effective_start_date%type
112   ,effective_end_date          per_all_people_f.effective_end_date%type
113   ,full_name                   per_all_people_f.full_name%type
114   ,comment_id                  number
115   ,name_combination_warning    boolean
116   ,assign_payroll_warning      boolean
117   ,orig_hire_warning           boolean
118   );
119 
120   type t_hrtojob_api is record
121   (effective_start_date        per_all_people_f.effective_start_date%type
122   ,effective_end_date          per_all_people_f.effective_end_date%type
123   ,assignment_id               per_all_assignments_f.assignment_id%type
124   ,assign_payroll_warning      boolean
125   ,orig_hire_warning           boolean
126   );
127 
128   type t_hrapp_api is record
129   (effective_start_date        per_all_people_f.effective_start_date%type
130   ,effective_end_date          per_all_people_f.effective_end_date%type
131   ,assign_payroll_warning      boolean
132   ,oversubscribed_vacancy_id   number
133   );
134 
135   type t_createcontact_api is record
136   (contact_relationship_id     per_contact_relationships.contact_relationship_id%type
137   ,ctr_object_version_number   per_contact_relationships.object_version_number%type
138   ,per_person_id               per_contact_relationships.contact_person_id%type
139   ,per_object_version_number   per_contact_relationships.object_version_number%type
140   ,per_effective_start_date    per_contact_relationships.date_start%type
141   ,per_effective_end_date      per_contact_relationships.date_start%type
142   ,full_name                   per_all_people_f.full_name%type
143   ,per_comment_id              per_all_people_f.comment_id%type
144   ,name_combination_warning    boolean
145   ,orig_hire_warning           boolean
146   );
147 
148   type t_asg_wrk_strs is record
149   (grade_name        per_grades.name%type
150   ,position_name     hr_all_positions_f.name%type
151   ,job_name          per_jobs.name%type
152   ,payroll_name      pay_all_payrolls_f.payroll_name%type
153   ,organization_name hr_all_organization_units.name%type
154   ,location_code     hr_locations_all.location_code%type
155   ,pay_basis_name    per_pay_bases.name%type
156   );
157 
158   g_wstr_names       t_asg_wrk_strs;
159 
160 -- =============================================================================
161 -- ~ Package Body Cursor variables:
162 -- =============================================================================
163 
164   --$ Cursor to fetch Benefit Group Name from Benefit Group ID to
165   -- insert into batch lines
166 
167   Cursor csr_get_benefit_name (c_benefit_group_id in number,
168                                c_business_group_id in number) is
169    select bbg.name
170    from   ben_benfts_grp bbg
171    where  bbg.benfts_grp_id = c_benefit_group_id
172    and    bbg.business_group_id + 0 = c_business_group_id;
173 
174 
175    -- Cursor to get the leg. code
176    cursor csr_bg_code (c_business_group_id in number) is
177    select pbg.legislation_code
178          ,pbg.method_of_generation_emp_num
179          ,pbg.method_of_generation_apl_num
180          ,pbg.method_of_generation_cwk_num
181          ,pbg.business_group_id
182      from per_business_groups pbg
183     where pbg.business_group_id = c_business_group_id;
184 
185    -- Cursor to get the meaning and code for a lookup type
186    cursor csr_chk_code (c_lookup_type    in varchar2
187                        ,c_lookup_code    in varchar2
188                        ,c_effective_date in date) is
189    select hrl.meaning
190          ,hrl.lookup_code
191      from hr_lookups hrl
192     where hrl.lookup_type = c_lookup_type
193       and hrl.lookup_code = c_lookup_code
194       and hrl.enabled_flag = 'Y'
195       and trunc(c_effective_date)
196           between nvl(hrl.start_date_active, trunc(c_effective_date))
197               and nvl(hrl.end_date_active,   trunc(c_effective_date));
198 
199    -- Cursor to check the valid df context
200    cursor csr_style (c_context_code in varchar2) is
201    select dfc.descriptive_flex_context_code
202      from fnd_descr_flex_contexts dfc
203     where dfc.application_id = 800
204       and dfc.descriptive_flexfield_name = 'Person Developer DF'
205       and dfc.enabled_flag = 'Y';
206 
207   -- Cursor to get details of a particular person
208   cursor csr_per (c_person_id         in number
209                  ,c_business_group_id in number
210                  ,c_effective_date    in date ) is
211   select *
212     from per_all_people_f ppf
213    where ppf.person_id = c_person_id
214      and ppf.business_group_id = c_business_group_id
215      and c_effective_date between ppf.effective_start_date
216                               and ppf.effective_end_date;
217 
218   -- Check the person or party if exists in hrms
219   cursor chk_party (c_party_id       in number
220                    ,c_bg_grp_id      in number
221                    ,c_person_id      in number
222                    ,c_effective_date in date) is
223   select ppt.system_person_type
224         ,ppf.effective_start_date
225         ,ppf.effective_end_date
226         ,ppf.employee_number
227         ,ppt.person_type_id
228         ,ppf.person_id
229     from per_all_people_f ppf
230         ,per_person_types ppt
231    where ppt.person_type_id    = ppf.person_type_id
232      and ppf.business_group_id = c_bg_grp_id
233      and ppt.business_group_id = ppf.business_group_id
234      and ppt.active_flag       = 'Y'
235      and ((c_person_id is not null and ppf.person_id = c_person_id) or
236           (c_party_id  is not null and ppf.party_id = c_party_id))
237      and c_effective_date between ppf.effective_start_date
238                               and ppf.effective_end_date;
239 
240   -- cursor to get the person types used as of a date
241   cursor csr_per_ptu (c_person_id         in number
242                      ,c_business_group_id in number
243                      ,c_effective_date    in date) is
244   select ptu.person_id
245         ,ptu.person_type_id
246         ,ppt.active_flag
247         ,ppt.system_person_type
248         ,ppt.user_person_type
249     from per_person_type_usages_f ptu
250         ,per_person_types         ppt
251    where ptu.person_id         = c_person_id
252      and ppt.business_group_id = c_business_group_id
253      and ppt.person_type_id    = ptu.person_type_id
254      and c_effective_date between ptu.effective_start_date
255                               and ptu.effective_end_date
256      and ppt.system_person_type
257          in ('EMP','EMP_APL','EX_EMP',
258              'APL','APL_EX_APL','EX_APL','EX_EMP_APL',
259              'CWK','EX_CWK')
260   order by ptu.effective_start_date desc;
261 
262   -- Cursor to check if the person has any future person type
263   -- changes of EMP, APL, CWK or OTHER i.e. Contact type
264   cursor chk_pertype_usage (c_person_id         in number
265                            ,c_effective_date    in date
266                            ,c_business_group_id in number) is
267   select ptu.person_type_id
268         ,ppt.system_person_type
269         ,ppt.user_person_type
270     from per_person_type_usages_f ptu
271         ,per_person_types         ppt
272    where ptu.person_id         = c_person_id
273      and ppt.person_type_id    = ptu.person_type_id
274      and ppt.business_group_id = c_business_group_id
275      and ptu.effective_start_date > c_effective_date
276      and ppt.system_person_type in
277          ('EMP'   ,'CWK'       ,'APL'       ,'EMP_APL',
278           'EX_APL','EX_CWK'    ,'EX_EMP_APL',
279           'OTHER' ,'APL_EX_APL','EX_EMP'
280           );
281   --
282   -- Cursor to check if the applicant assignment is accepted
283   --
284   cursor csr_accepted_asgs(c_person_id         in number
285                           ,c_business_group_id in number
286                           ,c_effective_date    in date
287                           ,c_assignment_id     in number
288                           ) is
289   select asg.assignment_id
290         ,asg.object_version_number
291         ,asg.vacancy_id
292     from per_all_assignments_f       asg
293         ,per_assignment_status_types ast
294    where asg.assignment_status_type_id = ast.assignment_status_type_id
295      and asg.person_id                 = c_person_id
296      and asg.business_group_id         = c_business_group_id
297      and (c_assignment_id is null or
298           asg.assignment_id = c_assignment_id)
299      and c_effective_date between asg.effective_start_date
300                               and asg.effective_end_date
301      and asg.assignment_type   = 'A'
302      and ast.per_system_status = 'ACCEPTED';
303   --
304   -- Cursor to check if the applicant assignment is accepted
305   --
306   cursor csr_not_accepted_asgs(c_person_id         in number
307                               ,c_business_group_id in number
308                               ,c_effective_date    in date
309                               ,c_assignment_id     in number
310                               ) is
311   select asg.assignment_id
312         ,asg.object_version_number
313         ,asg.vacancy_id
314     from per_all_assignments_f asg
315         ,per_assignment_status_types ast
316    where asg.assignment_status_type_id = ast.assignment_status_type_id
317      and asg.person_id = c_person_id
318      and asg.business_group_id = c_business_group_id
319      and (c_assignment_id is null or
320           asg.assignment_id = c_assignment_id)
321      and c_effective_date between asg.effective_start_date
322                               and asg.effective_end_date
323      and asg.assignment_type = 'A'
324      and ast.per_system_status <> 'ACCEPTED';
325   --
326   -- Cursor to get the Assignment Status Id of accepted Applicant Assig.
327   --
328   cursor csr_asg_status (c_leg_code          in varchar2
329                         ,c_business_group_id in number
330                         ) is
331   select assignment_status_type_id
332         ,active_flag
333         ,per_system_status
334    from per_assignment_status_types
335   where per_system_status    = 'ACCEPTED'
336     and (business_group_id   = c_business_group_id
337          or legislation_code = c_leg_code
338          or (legislation_code is null
339              and business_group_id is null)
340          )
341     and default_flag = 'Y'
342     and active_flag  = 'Y';
343   --
344   -- Cursor to get the User Person Type
345   --
346   cursor csr_per_type(c_person_type_id number
347                      ,c_business_group_id in number) is
348   select ppt.user_person_type
349     from per_person_types ppt
350    where ppt.person_type_id    = c_person_type_id
351      and ppt.business_group_id = c_business_group_id;
352   --
353   -- Cursor to get the Grade Name
354   --
355   cursor csr_grade(c_grade_id in number
356                   ,c_business_group_id in number
357                   ,c_effective_date in date) is
358   select gtl.name
359     from per_grades    pgr
360         ,per_grades_tl gtl
361    where pgr.grade_id          = c_grade_id
362      and gtl.grade_id          = pgr.grade_id
363      and gtl.language          = userenv('LANG')
364      and pgr.business_group_id = c_business_group_id
365      and c_effective_date between pgr.date_from
366                               and nvl(pgr.date_to,c_effective_date);
367   --
368   -- Cursor to get the Position Name
369   --
370   cursor csr_position(c_position_id       in number
371                      ,c_business_group_id in number
372                      ,c_effective_date    in date) is
373   select ptl.name
374     from hr_all_positions_f    pos
375         ,hr_all_positions_f_tl ptl
376    where pos.position_id       = c_position_id
377      and ptl.position_id       = pos.position_id
378      and ptl.language          = userenv('LANG')
379      and pos.business_group_id = c_business_group_id
380      and c_effective_date between pos.effective_start_date
381                               and pos.effective_end_date;
382   --
383   -- Cursor to get the Job Name
384   --
385   cursor csr_job(c_job_id            in number
386                 ,c_business_group_id in number
387                 ,c_effective_date    in date) is
388   select jtl.name
389     from per_jobs    pjb
390         ,per_jobs_tl jtl
391    where pjb.job_id            = c_job_id
392      and jtl.job_id            = pjb.job_id
393      and jtl.language          = Userenv('LANG')
394      and pjb.business_group_id = c_business_group_id
395      and c_effective_date between pjb.date_from
396                               and NVL(pjb.date_to,c_effective_date);
397   --
398   -- Cursor to get the Payroll Name
399   --
400   cursor csr_payroll(c_payroll_id in number
401                     ,c_business_group_id in number
402                     ,c_effective_date in date) is
403   select payroll_name
404     from pay_payrolls_f ppf
405    where ppf.payroll_id        = c_payroll_id
406      and ppf.business_group_id = c_business_group_id
407      and c_effective_date between ppf.effective_start_date
408                               and ppf.effective_end_date;
409   --
410   -- Cursor to get the Location Code
411   --
412   cursor csr_location(c_location_id in number
413                      ,c_business_group_id in number
414                      ) is
415   select htl.location_code
416     from hr_locations          hrl
417         ,hr_locations_all_tl   htl
418    where hrl.location_id        = c_location_id
419      and htl.location_id        = hrl.location_id
420      and htl.language           = Userenv('LANG')
421      and (hrl.business_group_id is null or
422           hrl.business_group_id = c_business_group_id);
423   --
424   -- Cursor to get the Organization Name
425   --
426   cursor csr_organization(c_organization_id in number
427                          ,c_business_group_id in number
428                          ,c_effective_date in date
429                           ) is
430   select htl.name
431     from hr_all_organization_units_tl htl
432         ,hr_all_organization_units    hao
433    where hao.organization_id   = c_organization_id
434      and hao.business_group_id = c_business_group_id
435      and htl.organization_id   = hao.organization_id
436      and htl.language          = Userenv('LANG')
437      and c_effective_date between hao.date_from
438                               and NVL(hao.date_to,c_effective_date);
439   --
440   -- Cursor to get the Pay Basis Name
441   --
442   cursor csr_paybasis(c_pay_basis_id in number
443                      ,c_business_group_id in number
444                      ) is
445   select ppb.name
446     from per_pay_bases ppb
447    where ppb.pay_basis_id = c_pay_basis_id
448      and ppb.business_group_id = c_business_group_id;
449   --
450   -- Cursor to check if address already exists
451   --
452   cursor csr_ck_add_xsts (c_person_id         in number
453                          ,c_business_group_id in number
454                          ,c_effective_date    in date
455                          ,c_primary_flag      in varchar2) is
456   select *
457     from per_addresses
458    where person_id = c_person_id
459      and business_group_id = c_business_group_id
460      and primary_flag = c_primary_flag
461      and c_effective_date between date_from
462                               and NVL(date_to, c_effective_date);
463   --
464   -- Cursor to check if Contact for a person already exists
465   --
466   cursor csr_ck_cont_xsts(c_person_id         in number
467                          ,c_business_group_id in number
468                          ,c_effective_date    in date) is
469   select object_version_number
470     from per_contact_relationships
471    where person_id = c_person_id
472      and business_group_id = c_business_group_id
473      and c_effective_date between date_start
474                               and NVL(date_end, c_effective_date);
475   --
476   -- Cursor to get the Employee Number
477   --
478   cursor csr_get_employee_num(c_person_id   in number) is
479   select employee_number
480     from per_all_people_f
481    where person_id = c_person_id;
482 
483 -- =============================================================================
484 -- Default_Record_Values:
485 -- =============================================================================
486 function Default_Person_Rec
487          return per_all_people_f%rowtype is
488   l_proc_name    constant varchar2(150) := g_pkg||'Default_Person_Rec';
489   l_per_rec     per_all_people_f%rowtype;
490 begin
491 
492   Hr_Utility.set_location(' Entering: '||l_proc_name, 5);
493   /*
494    ==========================================================================
495    g_varchar2  constant varchar2(9) := '$Sys_Def$';
496    g_number  constant number        := -987123654;
497    g_date  constant date            := to_date('01-01-4712', 'DD-MM-SYYYY');
498    ==========================================================================
499   */
500   l_per_rec.person_type_id                := hr_api.g_number;
501   l_per_rec.vendor_id                     := hr_api.g_number;
502   --l_per_rec.benefit_group_id              := hr_api.g_number;
503   l_per_rec.party_id                      := hr_api.g_number;
504   l_per_rec.comment_id                    := hr_api.g_number;
505 
506   Hr_Utility.set_location(l_proc_name, 6);
507 
508   --l_per_rec.date_employee_data_verified   := hr_api.g_date;
509   --l_per_rec.date_of_birth                 := hr_api.g_date;
510   --l_per_rec.original_date_of_hire         := hr_api.g_date;
511   --l_per_rec.dpdnt_adoption_date           := hr_api.g_date;
512   --l_per_rec.coord_ben_med_cvg_strt_dt     := hr_api.g_date;
513   --l_per_rec.coord_ben_med_cvg_end_dt      := hr_api.g_date;
514   --l_per_rec.receipt_of_death_cert_date    := hr_api.g_date;
515   --l_per_rec.resume_last_updated           := hr_api.g_date;
516   --l_per_rec.last_medical_test_date        := hr_api.g_date;
517   --l_per_rec.hold_applicant_date_until     := hr_api.g_date;
518   --l_per_rec.background_date_check         := hr_api.g_date;
519   --l_per_rec.date_of_death                 := hr_api.g_date;
520   --l_per_rec.projected_start_date          := hr_api.g_date;
521 
522   l_per_rec.last_name                     := hr_api.g_varchar2;
523   l_per_rec.applicant_number              := hr_api.g_varchar2;
524   l_per_rec.email_address                 := hr_api.g_varchar2;
525   l_per_rec.expense_check_send_to_address := hr_api.g_varchar2;
526   l_per_rec.first_name                    := hr_api.g_varchar2;
527   l_per_rec.known_as                      := hr_api.g_varchar2;
528   l_per_rec.marital_status                := hr_api.g_varchar2;
529   l_per_rec.middle_names                  := hr_api.g_varchar2;
530   l_per_rec.nationality                   := hr_api.g_varchar2;
531   l_per_rec.national_identifier           := hr_api.g_varchar2;
532   l_per_rec.previous_last_name            := hr_api.g_varchar2;
533   l_per_rec.registered_disabled_flag      := hr_api.g_varchar2;
534   l_per_rec.sex                           := hr_api.g_varchar2;
535   l_per_rec.title                         := hr_api.g_varchar2;
536   l_per_rec.work_telephone                := hr_api.g_varchar2;
537 
538   Hr_Utility.set_location(l_proc_name, 7);
539 
540   l_per_rec.attribute_category            := hr_api.g_varchar2;
541   l_per_rec.attribute1                    := hr_api.g_varchar2;
542   l_per_rec.attribute2                    := hr_api.g_varchar2;
543   l_per_rec.attribute3                    := hr_api.g_varchar2;
544   l_per_rec.attribute4                    := hr_api.g_varchar2;
545   l_per_rec.attribute5                    := hr_api.g_varchar2;
546   l_per_rec.attribute6                    := hr_api.g_varchar2;
547   l_per_rec.attribute7                    := hr_api.g_varchar2;
548   l_per_rec.attribute8                    := hr_api.g_varchar2;
549   l_per_rec.attribute9                    := hr_api.g_varchar2;
550   l_per_rec.attribute10                   := hr_api.g_varchar2;
551   l_per_rec.attribute11                   := hr_api.g_varchar2;
552   l_per_rec.attribute12                   := hr_api.g_varchar2;
553   l_per_rec.attribute13                   := hr_api.g_varchar2;
554   l_per_rec.attribute14                   := hr_api.g_varchar2;
555   l_per_rec.attribute15                   := hr_api.g_varchar2;
556   l_per_rec.attribute16                   := hr_api.g_varchar2;
557   l_per_rec.attribute17                   := hr_api.g_varchar2;
558   l_per_rec.attribute18                   := hr_api.g_varchar2;
559   l_per_rec.attribute19                   := hr_api.g_varchar2;
560   l_per_rec.attribute20                   := hr_api.g_varchar2;
561   l_per_rec.attribute21                   := hr_api.g_varchar2;
562   l_per_rec.attribute22                   := hr_api.g_varchar2;
563   l_per_rec.attribute23                   := hr_api.g_varchar2;
564   l_per_rec.attribute24                   := hr_api.g_varchar2;
565   l_per_rec.attribute25                   := hr_api.g_varchar2;
566   l_per_rec.attribute26                   := hr_api.g_varchar2;
567   l_per_rec.attribute27                   := hr_api.g_varchar2;
568   l_per_rec.attribute28                   := hr_api.g_varchar2;
569   l_per_rec.attribute29                   := hr_api.g_varchar2;
570   l_per_rec.attribute30                   := hr_api.g_varchar2;
571 
572   Hr_Utility.set_location(l_proc_name, 8);
573 
574   l_per_rec.per_information_category      := hr_api.g_varchar2;
575   l_per_rec.per_information1              := hr_api.g_varchar2;
576   l_per_rec.per_information2              := hr_api.g_varchar2;
577   l_per_rec.per_information3              := hr_api.g_varchar2;
578   l_per_rec.per_information4              := hr_api.g_varchar2;
579   l_per_rec.per_information5              := hr_api.g_varchar2;
580   l_per_rec.per_information6              := hr_api.g_varchar2;
581   l_per_rec.per_information7              := hr_api.g_varchar2;
582   l_per_rec.per_information8              := hr_api.g_varchar2;
583   l_per_rec.per_information9              := hr_api.g_varchar2;
584   l_per_rec.per_information10             := hr_api.g_varchar2;
585   l_per_rec.per_information11             := hr_api.g_varchar2;
586   l_per_rec.per_information12             := hr_api.g_varchar2;
587   l_per_rec.per_information13             := hr_api.g_varchar2;
588   l_per_rec.per_information14             := hr_api.g_varchar2;
589   l_per_rec.per_information15             := hr_api.g_varchar2;
590   l_per_rec.per_information16             := hr_api.g_varchar2;
591   l_per_rec.per_information17             := hr_api.g_varchar2;
592   l_per_rec.per_information18             := hr_api.g_varchar2;
593   l_per_rec.per_information19             := hr_api.g_varchar2;
594   l_per_rec.per_information20             := hr_api.g_varchar2;
595   l_per_rec.per_information21             := hr_api.g_varchar2;
596   l_per_rec.per_information22             := hr_api.g_varchar2;
597   l_per_rec.per_information23             := hr_api.g_varchar2;
598   l_per_rec.per_information24             := hr_api.g_varchar2;
599   l_per_rec.per_information25             := hr_api.g_varchar2;
600   l_per_rec.per_information26             := hr_api.g_varchar2;
601   l_per_rec.per_information27             := hr_api.g_varchar2;
602   l_per_rec.per_information28             := hr_api.g_varchar2;
603   l_per_rec.per_information29             := hr_api.g_varchar2;
604   l_per_rec.per_information30             := hr_api.g_varchar2;
605 
606   Hr_Utility.set_location(l_proc_name, 9);
607 
608   l_per_rec.background_check_status       := hr_api.g_varchar2;
609   l_per_rec.blood_type                    := hr_api.g_varchar2;
610   l_per_rec.correspondence_language       := hr_api.g_varchar2;
611   l_per_rec.fast_path_employee            := hr_api.g_varchar2;
612   l_per_rec.honors                        := hr_api.g_varchar2;
613   l_per_rec.internal_location             := hr_api.g_varchar2;
614   l_per_rec.last_medical_test_by          := hr_api.g_varchar2;
615   l_per_rec.mailstop                      := hr_api.g_varchar2;
616   l_per_rec.office_number                 := hr_api.g_varchar2;
617   l_per_rec.on_military_service           := hr_api.g_varchar2;
618   l_per_rec.pre_name_adjunct              := hr_api.g_varchar2;
619   l_per_rec.rehire_authorizor             := hr_api.g_varchar2;
620   l_per_rec.rehire_recommendation         := hr_api.g_varchar2;
621   l_per_rec.resume_exists                 := hr_api.g_varchar2;
622   l_per_rec.second_passport_exists        := hr_api.g_varchar2;
623   l_per_rec.student_status                := hr_api.g_varchar2;
624   l_per_rec.work_schedule                 := hr_api.g_varchar2;
625   l_per_rec.rehire_reason                 := hr_api.g_varchar2;
626   l_per_rec.suffix                        := hr_api.g_varchar2;
627   l_per_rec.coord_ben_med_pln_no          := hr_api.g_varchar2;
628   l_per_rec.coord_ben_no_cvg_flag         := hr_api.g_varchar2;
629   l_per_rec.coord_ben_med_ext_er          := hr_api.g_varchar2;
630   l_per_rec.coord_ben_med_pl_name         := hr_api.g_varchar2;
631   l_per_rec.coord_ben_med_insr_crr_name   := hr_api.g_varchar2;
632   l_per_rec.coord_ben_med_insr_crr_ident  := hr_api.g_varchar2;
633   l_per_rec.uses_tobacco_flag             := hr_api.g_varchar2;
634   l_per_rec.dpdnt_vlntry_svce_flag        := hr_api.g_varchar2;
635   l_per_rec.town_of_birth                 := hr_api.g_varchar2;
636   l_per_rec.region_of_birth               := hr_api.g_varchar2;
637   l_per_rec.country_of_birth              := hr_api.g_varchar2;
638   l_per_rec.global_person_id              := hr_api.g_varchar2;
639   l_per_rec.npw_number                    := hr_api.g_varchar2;
640 
641   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
642   return l_per_rec;
643 exception
644   when others then
645   Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
646   raise;
647 
648 end Default_Person_Rec;
649 -- =============================================================================
650 -- Get_PerRecord_Values:
651 -- =============================================================================
652 function Get_PerRecord_Values
653         (p_interface_code in varchar2 default null)
654          return per_all_people_f%rowtype is
655 
656   cursor bne_cols(c_interface_code in varchar2) is
657   select lower(bic.interface_col_name) interface_col_name
658     from bne_interface_cols_b  bic
659    where bic.interface_code = c_interface_code
660      and bic.display_flag ='Y';
661      --and bic.interface_col_type <> 2;
662 
663   -- Added by pkagrawa to query cols which are not displayed (DFF segments)
664    cursor bne_cols_no_disp(c_interface_code in varchar2) is
665   select lower(bic.interface_col_name) interface_col_name
666     from bne_interface_cols_b  bic
667    where bic.interface_code = c_interface_code
668      and bic.display_flag ='N';
669 
670   l_per_rec            per_all_people_f%rowtype;
671   col_name             varchar2(150);
672   l_proc_name constant varchar2(150) := g_pkg||'Default_Person_Rec';
673 begin
674 
675   Hr_Utility.set_location(' Entering: '||l_proc_name, 5);
676 
677   l_per_rec := Default_Person_Rec;
678 
679   for col_rec in bne_cols (g_interface_code)
680   loop
681    case col_rec.interface_col_name
682 
683     when 'p_internal_location' then       -- Added by pkagrawa
684           l_per_rec.internal_location := g_per_rec.internal_location; -- Added by pkagrawa
685     when 'p_party_id' then
686           l_per_rec.party_id := g_per_rec.party_id;
687     when 'p_business_group_id' then
688           l_per_rec.business_group_id := g_per_rec.business_group_id;
689     when 'p_national_identifier' then
690           l_per_rec.national_identifier := g_per_rec.national_identifier;
691     when 'p_last_name' then
692           l_per_rec.last_name := g_per_rec.last_name;
693     when 'p_middle_name' then
694           l_per_rec.middle_names := g_per_rec.middle_names;
695     when 'p_first_name' then
696           l_per_rec.first_name := g_per_rec.first_name;
697     when 'p_suffix' then
698           l_per_rec.suffix := g_per_rec.suffix;
699     when 'p_prefix' then
700           l_per_rec.pre_name_adjunct := g_per_rec.pre_name_adjunct;
701     when 'p_title' then
702           l_per_rec.title := g_per_rec.title;
703     when 'p_email_address' then
704           l_per_rec.email_address := g_per_rec.email_address;
705     when 'p_preferred_name' then
706           l_per_rec.known_as := g_per_rec.known_as;
707     when 'p_marital_status' then
708           l_per_rec.marital_status := g_per_rec.marital_status;
709     when 'p_sex' then
710           l_per_rec.sex := g_per_rec.sex;
711     when 'p_nationality' then
712           l_per_rec.nationality := g_per_rec.nationality;
713     when 'p_date_of_birth' then
714           l_per_rec.date_of_birth := g_per_rec.date_of_birth;
715     when 'p_date_of_hire' then
716           l_per_rec.start_date := g_per_rec.start_date;
717     when 'p_user_person_type' then
718           l_per_rec.person_type_id := g_per_rec.person_type_id;
719     when 'p_date_employee_data_verified' then
720           l_per_rec.date_employee_data_verified := g_per_rec.date_employee_data_verified;
721     when 'p_expense_check_send_to_addres' then
722           l_per_rec.expense_check_send_to_address := g_per_rec.expense_check_send_to_address;
723     when 'p_previous_last_name' then
724           l_per_rec.previous_last_name := g_per_rec.previous_last_name;
725     when 'p_registered_disabled_flag' then
726           l_per_rec.registered_disabled_flag := g_per_rec.registered_disabled_flag;
727     when 'p_vendor_id' then
728           l_per_rec.vendor_id := g_per_rec.vendor_id;
729     when 'p_date_of_death' then
730           l_per_rec.date_of_death := g_per_rec.date_of_death;
731     when 'p_background_check_status' then
732           l_per_rec.background_check_status := g_per_rec.background_check_status;
733     when 'p_background_date_check' then
734           l_per_rec.background_date_check := g_per_rec.background_date_check;
735     when 'p_blood_type' then
736           l_per_rec.blood_type := g_per_rec.blood_type;
737     when 'p_correspondence_language' then
738           l_per_rec.correspondence_language := g_per_rec.correspondence_language;
739     when 'p_fast_path_employee' then
740           l_per_rec.fast_path_employee := g_per_rec.fast_path_employee;
741     when 'p_fte_capacity' then
742           l_per_rec.fte_capacity := g_per_rec.fte_capacity;
743     when 'p_honors' then
744           l_per_rec.honors := g_per_rec.honors;
745     when 'p_last_medical_test_by' then
746           l_per_rec.last_medical_test_by := g_per_rec.last_medical_test_by;
747     when 'p_last_medical_test_date' then
748           l_per_rec.last_medical_test_date := g_per_rec.last_medical_test_date;
749     when 'p_mailstop' then
750           l_per_rec.mailstop := g_per_rec.mailstop;
751     when 'p_office_number' then
752           l_per_rec.office_number := g_per_rec.office_number;
753     when 'p_projected_start_date' then
754           l_per_rec.projected_start_date := g_per_rec.projected_start_date;
755     when 'p_resume_last_updated' then
756           l_per_rec.resume_last_updated := g_per_rec.resume_last_updated;
757     when 'p_student_status' then
758           l_per_rec.student_status := g_per_rec.student_status;
759     when 'p_work_schedule' then
760           l_per_rec.work_schedule := g_per_rec.work_schedule;
761     when 'p_benefit_group_id' then
762           l_per_rec.benefit_group_id := g_per_rec.benefit_group_id;
763     when 'p_receipt_of_death_cert_date' then
764           l_per_rec.receipt_of_death_cert_date := g_per_rec.receipt_of_death_cert_date;
765     when 'p_coord_ben_med_pln_no' then
766           l_per_rec.coord_ben_med_pln_no := g_per_rec.coord_ben_med_pln_no;
767     when 'p_coord_ben_med_ext_er' then
768           l_per_rec.coord_ben_med_ext_er := g_per_rec.coord_ben_med_ext_er;
769     when 'p_coord_ben_med_pl_name' then
770           l_per_rec.coord_ben_med_pl_name := g_per_rec.coord_ben_med_pl_name;
771     when 'p_coord_ben_med_insr_crr_name' then
772           l_per_rec.coord_ben_med_insr_crr_name := g_per_rec.coord_ben_med_insr_crr_name;
773     when 'p_coord_ben_med_insr_crr_ident' then
774           l_per_rec.coord_ben_med_insr_crr_ident := g_per_rec.coord_ben_med_insr_crr_ident;
775     when 'p_coord_ben_med_cvg_strt_dt' then
776           l_per_rec.coord_ben_med_cvg_strt_dt := g_per_rec.coord_ben_med_cvg_strt_dt;
777     when 'p_coord_ben_med_cvg_end_dt' then
778           l_per_rec.coord_ben_med_cvg_end_dt := g_per_rec.coord_ben_med_cvg_end_dt;
779     when 'p_uses_tobacco_flag' then
780           l_per_rec.uses_tobacco_flag := g_per_rec.uses_tobacco_flag;
781     when 'p_dpdnt_adoption_date' then
782           l_per_rec.dpdnt_adoption_date := g_per_rec.dpdnt_adoption_date;
783     when 'p_original_date_of_hire' then
784           l_per_rec.original_date_of_hire := g_per_rec.original_date_of_hire;
785     when 'p_town_of_birth' then
786           l_per_rec.town_of_birth := g_per_rec.town_of_birth;
787     when 'p_region_of_birth' then
788           l_per_rec.region_of_birth := g_per_rec.region_of_birth;
789     when 'p_country_of_birth' then
790           l_per_rec.country_of_birth := g_per_rec.country_of_birth;
791     when 'p_global_person_id' then
792           l_per_rec.global_person_id := g_per_rec.global_person_id;
793     when 'p_dpdnt_vlntry_svce_flag' then
794           l_per_rec.dpdnt_vlntry_svce_flag := g_per_rec.dpdnt_vlntry_svce_flag;
795     when 'p_coord_ben_no_cvg_flag' then
796           l_per_rec.coord_ben_no_cvg_flag := g_per_rec.coord_ben_no_cvg_flag;
797     when 'p_second_passport_exists' then
798           l_per_rec.second_passport_exists := g_per_rec.second_passport_exists;
799     when 'p_resume_exists' then
800           l_per_rec.resume_exists := g_per_rec.resume_exists;
801     when 'p_on_military_service' then
802           l_per_rec.on_military_service := g_per_rec.on_military_service;
803     -- Person User Defined DF
804     when 'attribute_category' then
805           l_per_rec.attribute_category := g_per_rec.attribute_category;
806           if l_per_rec.attribute_category is not null then
807           for col_rec1 in bne_cols_no_disp(g_interface_code) loop
808     --hr_utility.trace('$$UPD: attribute_category columns: '|| col_rec1.interface_col_name);
809              case col_rec1.interface_col_name
810              when 'attribute1' then
811                    l_per_rec.attribute1 := g_per_rec.attribute1;
812              when 'attribute2' then
813                    l_per_rec.attribute2 := g_per_rec.attribute2;
814              when 'attribute3' then
815                    l_per_rec.attribute3 := g_per_rec.attribute3;
816              when 'attribute4' then
817                    l_per_rec.attribute4 := g_per_rec.attribute4;
818              when 'attribute5' then
819                    l_per_rec.attribute5 := g_per_rec.attribute5;
820              when 'attribute6' then
821                    l_per_rec.attribute6 := g_per_rec.attribute6;
822              when 'attribute7' then
823                    l_per_rec.attribute7 := g_per_rec.attribute7;
824              when 'attribute8' then
825                    l_per_rec.attribute8 := g_per_rec.attribute8;
826              when 'attribute9' then
827                    l_per_rec.attribute9 := g_per_rec.attribute9;
828              when 'attribute10' then
829                    l_per_rec.attribute10 := g_per_rec.attribute10;
830              when 'attribute11' then
831                    l_per_rec.attribute11 := g_per_rec.attribute11;
832              when 'attribute12' then
833                    l_per_rec.attribute12 := g_per_rec.attribute12;
834              when 'attribute13' then
835                    l_per_rec.attribute13 := g_per_rec.attribute13;
836              when 'attribute14' then
837                    l_per_rec.attribute14 := g_per_rec.attribute14;
838              when 'attribute15' then
839                    l_per_rec.attribute15 := g_per_rec.attribute15;
840              when 'attribute16' then
841                    l_per_rec.attribute16 := g_per_rec.attribute16;
842              when 'attribute17' then
843                    l_per_rec.attribute17 := g_per_rec.attribute17;
844              when 'attribute18' then
845                    l_per_rec.attribute18 := g_per_rec.attribute18;
846              when 'attribute19' then
847                    l_per_rec.attribute19 := g_per_rec.attribute19;
848              when 'attribute20' then
849                    l_per_rec.attribute20 := g_per_rec.attribute20;
850              when 'attribute21' then
851                    l_per_rec.attribute21 := g_per_rec.attribute21;
852              when 'attribute22' then
853                    l_per_rec.attribute22 := g_per_rec.attribute22;
854              when 'attribute23' then
855                    l_per_rec.attribute23 := g_per_rec.attribute23;
856              when 'attribute24' then
857                    l_per_rec.attribute24 := g_per_rec.attribute24;
858              when 'attribute25' then
859                    l_per_rec.attribute25 := g_per_rec.attribute25;
860              when 'attribute26' then
861                    l_per_rec.attribute26 := g_per_rec.attribute26;
862              when 'attribute27' then
863                    l_per_rec.attribute27 := g_per_rec.attribute27;
864              when 'attribute28' then
865                    l_per_rec.attribute28 := g_per_rec.attribute28;
866              when 'attribute29' then
867                    l_per_rec.attribute29 := g_per_rec.attribute29;
868              when 'attribute30' then
869                    l_per_rec.attribute30 := g_per_rec.attribute30;
870              else
871                   null;
872              end case;
873             end loop;
874            end if;
875 
876     -- Person Legislative DDF
877     when 'per_information_category' then
878           l_per_rec.per_information_category := g_per_rec.per_information_category;
879           if l_per_rec.per_information_category is not null then
880     --hr_utility.trace('$$UPD: Inside per_information_category: '||l_per_rec.per_information_category);
881             for col_rec1 in bne_cols_no_disp(g_interface_code) loop
882     --hr_utility.trace('$$UPD: per_information_category Columns: '||col_rec1.interface_col_name);
883              case col_rec1.interface_col_name
884              when 'per_information1' then
885                    l_per_rec.per_information1 := g_per_rec.per_information1;
886              when 'per_information2' then
887                    l_per_rec.per_information2 := g_per_rec.per_information2;
888              when 'per_information3' then
889                    l_per_rec.per_information3 := g_per_rec.per_information3;
890              when 'per_information4' then
891                    l_per_rec.per_information4 := g_per_rec.per_information4;
892              when 'per_information5' then
893                    l_per_rec.per_information5 := g_per_rec.per_information5;
894              when 'per_information6' then
895                    l_per_rec.per_information6 := g_per_rec.per_information6;
896              when 'per_information7' then
897                    l_per_rec.per_information7 := g_per_rec.per_information7;
898              when 'per_information8' then
899                    l_per_rec.per_information8 := g_per_rec.per_information8;
900              when 'per_information9' then
901                    l_per_rec.per_information9 := g_per_rec.per_information9;
902              when 'per_information10' then
903                    l_per_rec.per_information10 := g_per_rec.per_information10;
904              when 'per_information11' then
905                    l_per_rec.per_information11 := g_per_rec.per_information11;
906              when 'per_information12' then
907                    l_per_rec.per_information12 := g_per_rec.per_information12;
908              when 'per_information13' then
909                    l_per_rec.per_information13 := g_per_rec.per_information13;
910              when 'per_information14' then
911                    l_per_rec.per_information14 := g_per_rec.per_information14;
912              when 'per_information15' then
913                    l_per_rec.per_information15 := g_per_rec.per_information15;
914              when 'per_information16' then
915                    l_per_rec.per_information16 := g_per_rec.per_information16;
916              when 'per_information17' then
917                    l_per_rec.per_information17 := g_per_rec.per_information17;
918              when 'per_information18' then
919                    l_per_rec.per_information18 := g_per_rec.per_information18;
920              when 'per_information19' then
921                    l_per_rec.per_information19 := g_per_rec.per_information19;
922              when 'per_information20' then
923                    l_per_rec.per_information20 := g_per_rec.per_information20;
924              when 'per_information21' then
925                    l_per_rec.per_information21 := g_per_rec.per_information21;
926              when 'per_information22' then
927                    l_per_rec.per_information22 := g_per_rec.per_information22;
928              when 'per_information23' then
929                    l_per_rec.per_information23 := g_per_rec.per_information23;
930              when 'per_information24' then
931                    l_per_rec.per_information24 := g_per_rec.per_information24;
932              when 'per_information25' then
933                    l_per_rec.per_information25 := g_per_rec.per_information25;
934              when 'per_information26' then
935                    l_per_rec.per_information26 := g_per_rec.per_information26;
936              when 'per_information27' then
937                    l_per_rec.per_information27 := g_per_rec.per_information27;
938              when 'per_information28' then
939                    l_per_rec.per_information28 := g_per_rec.per_information28;
940              when 'per_information29' then
941                    l_per_rec.per_information29 := g_per_rec.per_information29;
942              when 'per_information30' then
943                    l_per_rec.per_information30 := g_per_rec.per_information30;
944              else
945                   null;
946              end case;
947             end loop;
948            end if;
949    else
950       null;
951    end case;
952   end loop;
953   Hr_Utility.set_location(' Leaving: '||l_proc_name, 80);
954   return l_per_rec;
955 
956 end Get_PerRecord_Values;
957 -- =============================================================================
958 -- Default_Asg_Rec:
959 -- =============================================================================
960 function Default_Assignment_Rec
961          return per_all_assignments_f%rowtype is
962   l_proc_name    constant varchar2(150) := g_pkg||'Default_Assignment_Rec';
963   l_asg_rec     per_all_assignments_f%rowtype;
964 begin
965   Hr_Utility.set_location(' Entering: '||l_proc_name, 5);
966   /*
967    ======================================================================
968    g_varchar2 constant varchar2(9):= '$Sys_Def$';
969    g_number constant number       := -987123654;
970    g_date constant date           := to_date('01-01-4712','DD-MM-SYYYY');
971    ======================================================================
972   */
973   l_asg_rec.grade_id                 := hr_api.g_number;
974   l_asg_rec.position_id              := hr_api.g_number;
975   l_asg_rec.job_id                   := hr_api.g_number;
976   l_asg_rec.payroll_id               := hr_api.g_number;
977   l_asg_rec.location_id              := hr_api.g_number;
978   l_asg_rec.organization_id          := hr_api.g_number;
979   l_asg_rec.pay_basis_id             := hr_api.g_number;
980   l_asg_rec.employment_category      := hr_api.g_varchar2;
981   l_asg_rec.contract_id              := hr_api.g_number;
982   l_asg_rec.establishment_id         := hr_api.g_number;
983   l_asg_rec.grade_ladder_pgm_id      := hr_api.g_number;
984   l_asg_rec.supervisor_assignment_id := hr_api.g_number;
985   l_asg_rec.special_ceiling_step_id  := hr_api.g_number;
986   l_asg_rec.people_group_id          := hr_api.g_number;
987   l_asg_rec.soft_coding_keyflex_id   := hr_api.g_number;
988 
989   Hr_Utility.set_location(l_proc_name, 10);
990 
991   l_asg_rec.supervisor_id                := hr_api.g_number;
992   l_asg_rec.assignment_number            := hr_api.g_varchar2;
993   l_asg_rec.change_reason                := hr_api.g_varchar2;
994   l_asg_rec.assignment_status_type_id    := hr_api.g_number;
995   l_asg_rec.date_probation_end           := hr_api.g_date;
996   l_asg_rec.default_code_comb_id         := hr_api.g_number;
997   l_asg_rec.frequency                    := hr_api.g_varchar2;
998   l_asg_rec.internal_address_line        := hr_api.g_varchar2;
999   l_asg_rec.manager_flag                 := hr_api.g_varchar2;
1000   l_asg_rec.normal_hours                 := hr_api.g_number;
1001   l_asg_rec.perf_review_period           := hr_api.g_number;
1002   l_asg_rec.perf_review_period_frequency := hr_api.g_varchar2;
1003   l_asg_rec.probation_period             := hr_api.g_number;
1004   l_asg_rec.probation_unit               := hr_api.g_varchar2;
1005   l_asg_rec.sal_review_period            := hr_api.g_number;
1006   l_asg_rec.sal_review_period_frequency  := hr_api.g_varchar2;
1007   l_asg_rec.set_of_books_id              := hr_api.g_number;
1008   l_asg_rec.source_type                  := hr_api.g_varchar2;
1009 --  l_asg_rec.time_normal_finish           := hr_api.g_varchar2;
1010 --  l_asg_rec.time_normal_start            := hr_api.g_varchar2;
1011   l_asg_rec.bargaining_unit_code         := hr_api.g_varchar2;
1012   l_asg_rec.labour_union_member_flag     := hr_api.g_varchar2;
1013   l_asg_rec.hourly_salaried_code         := hr_api.g_varchar2;
1014 
1015   Hr_Utility.set_location(l_proc_name, 15);
1016 
1017   l_asg_rec.ass_attribute_category       := hr_api.g_varchar2;
1018   l_asg_rec.ass_attribute1               := hr_api.g_varchar2;
1019   l_asg_rec.ass_attribute2               := hr_api.g_varchar2;
1020   l_asg_rec.ass_attribute3               := hr_api.g_varchar2;
1021   l_asg_rec.ass_attribute4               := hr_api.g_varchar2;
1022   l_asg_rec.ass_attribute5               := hr_api.g_varchar2;
1023   l_asg_rec.ass_attribute6               := hr_api.g_varchar2;
1024   l_asg_rec.ass_attribute7               := hr_api.g_varchar2;
1025   l_asg_rec.ass_attribute8               := hr_api.g_varchar2;
1026   l_asg_rec.ass_attribute9               := hr_api.g_varchar2;
1027   l_asg_rec.ass_attribute10              := hr_api.g_varchar2;
1028   l_asg_rec.ass_attribute11              := hr_api.g_varchar2;
1029   l_asg_rec.ass_attribute12              := hr_api.g_varchar2;
1030   l_asg_rec.ass_attribute13              := hr_api.g_varchar2;
1031   l_asg_rec.ass_attribute14              := hr_api.g_varchar2;
1032   l_asg_rec.ass_attribute15              := hr_api.g_varchar2;
1033   l_asg_rec.ass_attribute16              := hr_api.g_varchar2;
1034   l_asg_rec.ass_attribute17              := hr_api.g_varchar2;
1035   l_asg_rec.ass_attribute18              := hr_api.g_varchar2;
1036   l_asg_rec.ass_attribute19              := hr_api.g_varchar2;
1037   l_asg_rec.ass_attribute20              := hr_api.g_varchar2;
1038   l_asg_rec.ass_attribute21              := hr_api.g_varchar2;
1039   l_asg_rec.ass_attribute22              := hr_api.g_varchar2;
1040   l_asg_rec.ass_attribute23              := hr_api.g_varchar2;
1041   l_asg_rec.ass_attribute24              := hr_api.g_varchar2;
1042   l_asg_rec.ass_attribute25              := hr_api.g_varchar2;
1043   l_asg_rec.ass_attribute26              := hr_api.g_varchar2;
1044   l_asg_rec.ass_attribute27              := hr_api.g_varchar2;
1045   l_asg_rec.ass_attribute28              := hr_api.g_varchar2;
1046   l_asg_rec.ass_attribute29              := hr_api.g_varchar2;
1047   l_asg_rec.ass_attribute30              := hr_api.g_varchar2;
1048 
1049   Hr_Utility.set_location(l_proc_name, 20);
1050 
1051   l_asg_rec.title                        := hr_api.g_varchar2;
1052   l_asg_rec.contract_id                  := hr_api.g_number;
1053   l_asg_rec.establishment_id             := hr_api.g_number;
1054   l_asg_rec.collective_agreement_id      := hr_api.g_number;
1055   l_asg_rec.notice_period                := hr_api.g_number;
1056   l_asg_rec.notice_period_uom            := hr_api.g_varchar2;
1057   l_asg_rec.employee_category            := hr_api.g_varchar2;
1058   l_asg_rec.supervisor_assignment_id     := hr_api.g_number;
1059 
1060   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1061   return l_asg_rec;
1062 exception
1063   when others then
1064   Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1065   raise;
1066 
1067 end Default_Assignment_Rec;
1068 -- =============================================================================
1069 -- Get_AsgRecord_Values:
1070 -- =============================================================================
1071 function Get_AsgRecord_Values
1072         (p_interface_code in varchar2 default null)
1073          return per_all_assignments_f%rowtype is
1074 
1075   cursor bne_cols(c_interface_code in varchar2) is
1076   select lower(bic.interface_col_name) interface_col_name
1077     from bne_interface_cols_b  bic
1078    where bic.interface_code = c_interface_code
1079      and bic.display_flag ='Y';
1080 
1081   -- Added by Dbansal to query cols which are not displayed (DFF segments)
1082    cursor bne_cols_no_disp(c_interface_code in varchar2) is
1083   select lower(bic.interface_col_name) interface_col_name
1084     from bne_interface_cols_b  bic
1085    where bic.interface_code = c_interface_code
1086      and bic.display_flag ='N';
1087 
1088   l_proc_name    constant varchar2(150) := g_pkg||'Get_AsgRecord_Values';
1089   l_asg_rec per_all_assignments_f%rowtype;
1090   col_name  varchar2(150);
1091 
1092 begin
1093   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1094   --$ check if secondary assignment is to be created
1095   -- If yes (i.e. flag is set to 1 ) then initialize to null else to hr_api variable
1096    -- type
1097   if   g_sec_asg_flag <> 1 then
1098   l_asg_rec := Default_Assignment_Rec;
1099   elsif g_sec_asg_flag = 1 then
1100   l_asg_rec := null;
1101   end if;
1102 
1103   for col_rec in bne_cols (g_interface_code)
1104   loop
1105    case col_rec.interface_col_name
1106     when 'p_business_group_id' then
1107      l_asg_rec.business_group_id := g_asg_rec.business_group_id;
1108     when 'p_assign_organization' then
1109      l_asg_rec.organization_id := g_asg_rec.organization_id;
1110     when 'p_job' then
1111      l_asg_rec.job_id := g_asg_rec.job_id;
1112     when 'p_grade' then
1113      l_asg_rec.grade_id := g_asg_rec.grade_id;
1114     when 'p_assign_group' then
1115      l_asg_rec.people_group_id := g_asg_rec.people_group_id;
1116     when 'p_position' then
1117      l_asg_rec.position_id := g_asg_rec.position_id;
1118     when 'p_payroll' then
1119      l_asg_rec.payroll_id := g_asg_rec.payroll_id;
1120     when 'p_salary_basis' then
1121      l_asg_rec.pay_basis_id := g_asg_rec.pay_basis_id;
1122     when 'p_status' then
1123      l_asg_rec.assignment_status_type_id := g_asg_rec.assignment_status_type_id;
1124     when 'p_assignment_no' then
1125      l_asg_rec.assignment_number := g_asg_rec.assignment_number;
1126     when 'p_assign_eff_dt_from' then
1127      l_asg_rec.effective_start_date := g_asg_rec.effective_start_date;
1128     when 'p_assign_eff_dt_to' then
1129      l_asg_rec.effective_end_date := g_asg_rec.effective_end_date;
1130     when 'p_assignment_category' then
1131      l_asg_rec.assignment_category := g_asg_rec.assignment_category;
1132     --Added by dbansal
1133      l_asg_rec.employment_category := g_asg_rec.assignment_category;
1134     when 'p_collective_agreement' then
1135      l_asg_rec.collective_agreement_id :=  g_asg_rec.collective_agreement_id;
1136     when 'p_employee_category' then
1137      l_asg_rec.employee_category := g_asg_rec.employee_category;
1138     when 'p_supervisor_id' then
1139      l_asg_rec.supervisor_id := g_asg_rec.supervisor_id;
1140     when 'p_assignment_number' then
1141      l_asg_rec.assignment_number := g_asg_rec.assignment_number;
1142     when 'p_change_reason' then
1143      l_asg_rec.change_reason := g_asg_rec.change_reason;
1144     when 'p_date_probation_end' then
1145      l_asg_rec.date_probation_end := g_asg_rec.date_probation_end;
1146     when 'p_default_code_comb_id' then
1147      l_asg_rec.default_code_comb_id := g_asg_rec.default_code_comb_id;
1148     when 'p_frequency' then
1149      l_asg_rec.frequency := g_asg_rec.frequency;
1150     when 'p_internal_address_line' then
1151      l_asg_rec.internal_address_line := g_asg_rec.internal_address_line;
1152     when 'p_manager_flag' then
1153      l_asg_rec.manager_flag := g_asg_rec.manager_flag;
1154     when 'p_normal_hours' then
1155      l_asg_rec.normal_hours := g_asg_rec.normal_hours;
1156     when 'p_perf_review_period' then
1157      l_asg_rec.perf_review_period := g_asg_rec.perf_review_period;
1158     when 'p_perf_review_period_frequency' then
1159      l_asg_rec.perf_review_period_frequency := g_asg_rec.perf_review_period_frequency;
1160     when 'p_probation_period' then
1161      l_asg_rec.probation_period := g_asg_rec.probation_period;
1162     when 'p_probation_unit' then
1163      l_asg_rec.probation_unit := g_asg_rec.probation_unit;
1164     when 'p_sal_review_period' then
1165      l_asg_rec.sal_review_period := g_asg_rec.sal_review_period;
1166     when 'p_sal_review_period_frequency' then
1167      l_asg_rec.sal_review_period_frequency := g_asg_rec.sal_review_period_frequency;
1168     when 'p_set_of_books_id' then
1169      l_asg_rec.set_of_books_id := g_asg_rec.set_of_books_id;
1170     when 'p_source_type' then
1171      l_asg_rec.source_type := g_asg_rec.source_type;
1172     when 'p_time_normal_finish' then
1173      l_asg_rec.time_normal_finish := g_asg_rec.time_normal_finish;
1174     when 'p_time_normal_start' then
1175      l_asg_rec.time_normal_start := g_asg_rec.time_normal_start;
1176     when 'p_bargaining_unit_code' then
1177      l_asg_rec.bargaining_unit_code := g_asg_rec.bargaining_unit_code;
1178     when 'p_labour_union_member_flag' then
1179      l_asg_rec.labour_union_member_flag := g_asg_rec.labour_union_member_flag;
1180     when 'p_hourly_salaried_code' then
1181      l_asg_rec.hourly_salaried_code := g_asg_rec.hourly_salaried_code;
1182     when 'p_location_id' then
1183      l_asg_rec.location_id := g_asg_rec.location_id;
1184     -- Assignment User Defined DF
1185     when 'ass_attribute_category' then
1186  --    hr_utility.trace('IN GET_ASGRECORD_VALUES, when ass_att_cat');
1187       l_asg_rec.ass_attribute_category := g_asg_rec.ass_attribute_category;
1188 --hr_utility.trace('IN GET_ASGRECORD_VALUES ass_attribute_cat='||l_asg_rec.ass_attribute_category);
1189       if l_asg_rec.ass_attribute_category is not null then
1190 --hr_utility.trace('IN GET_ASGRECORD_VALUES intfcolname'|| col_rec.interface_col_name);
1191 
1192          -- Added by Dbansal -> Another nested loop to set the values of DFF segments
1193          for col_rec1 in bne_cols_no_disp(g_interface_code) loop
1194        --   hr_utility.trace('IN GET_ASGRECORD_VALUES Nested:'|| col_rec1.interface_col_name);
1195            case col_rec1.interface_col_name
1196             when 'ass_attribute1' then
1197             l_asg_rec.ass_attribute1 := g_asg_rec.ass_attribute1;
1198 --hr_utility.trace('IN GET_ASGRECORD_VALUES ass_attribute1='||l_asg_rec.ass_attribute1);
1199             when 'ass_attribute2' then
1200             l_asg_rec.ass_attribute2 := g_asg_rec.ass_attribute2;
1201 --hr_utility.trace('IN GET_ASGRECORD_VALUES ass_attribute2='||l_asg_rec.ass_attribute2);
1202             when 'ass_attribute3' then
1203             l_asg_rec.ass_attribute3 := g_asg_rec.ass_attribute3;
1204             when 'ass_attribute4' then
1205             l_asg_rec.ass_attribute4 := g_asg_rec.ass_attribute4;
1206             when 'ass_attribute5' then
1207             l_asg_rec.ass_attribute5 := g_asg_rec.ass_attribute5;
1208             when 'ass_attribute6' then
1209             l_asg_rec.ass_attribute6 := g_asg_rec.ass_attribute6;
1210             when 'ass_attribute7' then
1211             l_asg_rec.ass_attribute7 := g_asg_rec.ass_attribute7;
1212             when 'ass_attribute8' then
1213             l_asg_rec.ass_attribute8 := g_asg_rec.ass_attribute8;
1214             when 'ass_attribute9' then
1215             l_asg_rec.ass_attribute9 := g_asg_rec.ass_attribute9;
1216             when 'ass_attribute10' then
1217             l_asg_rec.ass_attribute10 := g_asg_rec.ass_attribute10;
1218 --hr_utility.trace('IN GET_ASGRECORD_VALUES ass_attribute10='||l_asg_rec.ass_attribute10);
1219             when 'ass_attribute11' then
1220             l_asg_rec.ass_attribute11 := g_asg_rec.ass_attribute11;
1221             when 'ass_attribute12' then
1222             l_asg_rec.ass_attribute12 := g_asg_rec.ass_attribute12;
1223 --hr_utility.trace('IN GET_ASGRECORD_VALUES ass_attribute12='||l_asg_rec.ass_attribute12);
1224             when 'ass_attribute13' then
1225             l_asg_rec.ass_attribute13 := g_asg_rec.ass_attribute13;
1226             when 'ass_attribute14' then
1227             l_asg_rec.ass_attribute14 := g_asg_rec.ass_attribute14;
1228             when 'ass_attribute15' then
1229             l_asg_rec.ass_attribute15 := g_asg_rec.ass_attribute15;
1230             when 'ass_attribute16' then
1231             l_asg_rec.ass_attribute16 := g_asg_rec.ass_attribute16;
1232             when 'ass_attribute17' then
1233             l_asg_rec.ass_attribute17 := g_asg_rec.ass_attribute17;
1234             when 'ass_attribute18' then
1235             l_asg_rec.ass_attribute18 := g_asg_rec.ass_attribute18;
1236             when 'ass_attribute19' then
1237             l_asg_rec.ass_attribute19 := g_asg_rec.ass_attribute19;
1238             when 'ass_attribute20' then
1239             l_asg_rec.ass_attribute20 := g_asg_rec.ass_attribute20;
1240             when 'ass_attribute21' then
1241             l_asg_rec.ass_attribute21 := g_asg_rec.ass_attribute21;
1242             when 'ass_attribute22' then
1243             l_asg_rec.ass_attribute22 := g_asg_rec.ass_attribute22;
1244             when 'ass_attribute23' then
1245             l_asg_rec.ass_attribute23 := g_asg_rec.ass_attribute23;
1246             when 'ass_attribute24' then
1247             l_asg_rec.ass_attribute24 := g_asg_rec.ass_attribute24;
1248             when 'ass_attribute25' then
1249             l_asg_rec.ass_attribute25 := g_asg_rec.ass_attribute25;
1250             when 'ass_attribute26' then
1251             l_asg_rec.ass_attribute26 := g_asg_rec.ass_attribute26;
1252             when 'ass_attribute27' then
1253             l_asg_rec.ass_attribute27 := g_asg_rec.ass_attribute27;
1254             when 'ass_attribute28' then
1255             l_asg_rec.ass_attribute28 := g_asg_rec.ass_attribute28;
1256             when 'ass_attribute29' then
1257             l_asg_rec.ass_attribute29 := g_asg_rec.ass_attribute29;
1258             when 'ass_attribute30' then
1259             l_asg_rec.ass_attribute30 := g_asg_rec.ass_attribute30;
1260             else
1261             null;
1262           end case;
1263         end loop;
1264       end if;
1265    else
1266       null;
1267    end case;
1268   end loop;
1269 
1270   return l_Asg_rec;
1271  Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1272 exception
1273   when others then
1274   Hr_Utility.set_location('Error Leaving: '||l_proc_name, 90);
1275   raise;
1276 
1277 end Get_AsgRecord_Values;
1278 
1279 -- =============================================================================
1280 -- Default_PpgFlx_Rec:
1281 -- =============================================================================
1282 function Default_PpgFlx_Rec
1283          return pay_people_groups%rowtype is
1284   l_proc_name    constant varchar2(150) := g_pkg||'Default_PpgFlx_Rec';
1285   l_grp_rec     pay_people_groups%rowtype;
1286 begin
1287   Hr_Utility.set_location(' Entering: '||l_proc_name, 5);
1288   /*
1289    ======================================================================
1290    hr_api defaults:
1291    g_varchar2 constant varchar2(9):= '$Sys_Def$';
1292    g_number constant number       := -987123654;
1293    g_date constant date           := to_date('01-01-4712','DD-MM-SYYYY');
1294    ======================================================================
1295   */
1296   l_grp_rec.group_name   := hr_api.g_varchar2;
1297 
1298   Hr_Utility.set_location(' First : Default_PpgFlx_Rec'||l_grp_rec.group_name, 5);
1299 
1300   l_grp_rec.segment1     := hr_api.g_varchar2;
1301   l_grp_rec.segment2     := hr_api.g_varchar2;
1302   l_grp_rec.segment3     := hr_api.g_varchar2;
1303   l_grp_rec.segment4     := hr_api.g_varchar2;
1304   l_grp_rec.segment5     := hr_api.g_varchar2;
1305   l_grp_rec.segment6     := hr_api.g_varchar2;
1306   l_grp_rec.segment7     := hr_api.g_varchar2;
1307   l_grp_rec.segment8     := hr_api.g_varchar2;
1308   l_grp_rec.segment9     := hr_api.g_varchar2;
1309   Hr_Utility.set_location('Default_PpgFlx_Rec', 15);
1310   l_grp_rec.segment10    := hr_api.g_varchar2;
1311   l_grp_rec.segment11    := hr_api.g_varchar2;
1312   l_grp_rec.segment12    := hr_api.g_varchar2;
1313   l_grp_rec.segment13    := hr_api.g_varchar2;
1314   l_grp_rec.segment14    := hr_api.g_varchar2;
1315   l_grp_rec.segment15    := hr_api.g_varchar2;
1316   l_grp_rec.segment16    := hr_api.g_varchar2;
1317   l_grp_rec.segment17    := hr_api.g_varchar2;
1318   l_grp_rec.segment18    := hr_api.g_varchar2;
1319   l_grp_rec.segment19    := hr_api.g_varchar2;
1320   Hr_Utility.set_location('Default_PpgFlx_Rec', 20);
1321   l_grp_rec.segment20    := hr_api.g_varchar2;
1322   l_grp_rec.segment21    := hr_api.g_varchar2;
1323   l_grp_rec.segment22    := hr_api.g_varchar2;
1324   l_grp_rec.segment23    := hr_api.g_varchar2;
1325   l_grp_rec.segment24    := hr_api.g_varchar2;
1326   l_grp_rec.segment25    := hr_api.g_varchar2;
1327   l_grp_rec.segment26    := hr_api.g_varchar2;
1328   l_grp_rec.segment27    := hr_api.g_varchar2;
1329   l_grp_rec.segment28    := hr_api.g_varchar2;
1330   l_grp_rec.segment29    := hr_api.g_varchar2;
1331   l_grp_rec.segment30    := hr_api.g_varchar2;
1332 
1333   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1334   return l_grp_rec;
1335 
1336 exception
1337   when others then
1338   if g_debug then
1339      Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1340   end if;
1341   raise;
1342 
1343 end Default_PpgFlx_Rec;
1344 -- =============================================================================
1345 -- Get_GrpRecord_Values:
1346 -- =============================================================================
1347 function Get_GrpRecord_Values
1348         (p_interface_code in varchar2 default null)
1349          return pay_people_groups%rowtype is
1350 
1351   cursor bne_cols(c_interface_code in varchar2) is
1352   select lower(bic.interface_col_name) interface_col_name
1353     from bne_interface_cols_b  bic
1354    where bic.interface_code = c_interface_code
1355      and bic.group_name = 'PEOPLE_KEYFLEX_GROUP'
1356      and bic.display_flag ='Y';
1357      --If the concat segments column is included then each segment value is assigned to the passed value.
1358      --The segments will always have display flag as 'N'
1359 
1360   l_proc_name    constant varchar2(150) := g_pkg||'Get_GrpRecord_Values';
1361   l_grp_rec      pay_people_groups%rowtype;
1362   col_name        varchar2(150);
1363 
1364 begin
1365   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1366   if g_sec_asg_flag <> 1 then
1367       l_grp_rec := Default_PpgFlx_Rec;
1368   else
1369       l_grp_rec := null;
1370   end if;
1371   for col_rec in bne_cols (g_interface_code)
1372   loop
1373    --$ Assign global values to the People Group segments
1374    case col_rec.interface_col_name
1375     when 'p_concat_segments' then
1376      l_grp_rec.group_name := g_grp_rec.group_name; --l_grp_rec.group_name;
1377     --when 'segment1' then
1378      l_grp_rec.segment1 := g_grp_rec.segment1;
1379     --when 'segment2' then
1380      l_grp_rec.segment2 := g_grp_rec.segment2;
1381     --when 'segment3' then
1382      l_grp_rec.segment3 := g_grp_rec.segment3;
1383     --when 'segment4' then
1384      l_grp_rec.segment4 := g_grp_rec.segment4;
1385     --when 'segment5' then
1386      l_grp_rec.segment5 := g_grp_rec.segment5;
1387     --when 'segment6' then
1388      l_grp_rec.segment6 := g_grp_rec.segment6;
1389     --when 'segment7' then
1390      l_grp_rec.segment7 := g_grp_rec.segment7;
1391     --when 'segment8' then
1392      l_grp_rec.segment8 := g_grp_rec.segment8;
1393     --when 'segment9' then
1394      l_grp_rec.segment9 := g_grp_rec.segment9;
1395     --when 'segment10' then
1396      l_grp_rec.segment10 := g_grp_rec.segment10;
1397     --when 'segment11' then
1398      l_grp_rec.segment11 := g_grp_rec.segment11;
1399     --when 'segment12' then
1400      l_grp_rec.segment12 := g_grp_rec.segment12;
1401     --when 'segment13' then
1402      l_grp_rec.segment13 := g_grp_rec.segment13;
1403     --when 'segment14' then
1404      l_grp_rec.segment14 := g_grp_rec.segment14;
1405     --when 'segment15' then
1406      l_grp_rec.segment15 := g_grp_rec.segment15;
1407     --when 'segment16' then
1408      l_grp_rec.segment16 := g_grp_rec.segment16;
1409     --when 'segment17' then
1410      l_grp_rec.segment17 := g_grp_rec.segment17;
1411     --when 'segment18' then
1412      l_grp_rec.segment18 := g_grp_rec.segment18;
1413     --when 'segment19' then
1414      l_grp_rec.segment19 := g_grp_rec.segment19;
1415     --when 'segment20' then
1416      l_grp_rec.segment20 := g_grp_rec.segment20;
1417     --when 'segment21' then
1418      l_grp_rec.segment21 := g_grp_rec.segment21;
1419     --when 'segment22' then
1420      l_grp_rec.segment22 := g_grp_rec.segment22;
1421     --when 'segment23' then
1422      l_grp_rec.segment23 := g_grp_rec.segment23;
1423     --when 'segment24' then
1424      l_grp_rec.segment24 := g_grp_rec.segment24;
1425     --when 'segment25' then
1426      l_grp_rec.segment25 := g_grp_rec.segment25;
1427     --when 'segment26' then
1428      l_grp_rec.segment26 := g_grp_rec.segment26;
1429     --when 'segment27' then
1430      l_grp_rec.segment27 := g_grp_rec.segment27;
1431     --when 'segment28' then
1432      l_grp_rec.segment28 := g_grp_rec.segment28;
1433     --when 'segment29' then
1434      l_grp_rec.segment29 := g_grp_rec.segment29;
1435     --when 'segment30' then
1436      l_grp_rec.segment30 := g_grp_rec.segment30;
1437    else
1438       null;
1439    end case;
1440   end loop;
1441   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1442   return l_grp_rec;
1443 
1444 exception
1445   when others then
1446   Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1447   raise;
1448 
1449 end Get_GrpRecord_Values;
1450 
1451 -- =============================================================================
1452 -- Default_Scflx_Rec:
1453 -- =============================================================================
1454 function Default_Scflx_Rec
1455          return hr_soft_coding_keyflex%rowtype is
1456   l_proc_name    constant varchar2(150) := g_pkg||'Default_Scflx_Rec';
1457   l_scl_rec     hr_soft_coding_keyflex%rowtype;
1458 begin
1459   Hr_Utility.set_location(' Entering: '||l_proc_name, 5);
1460   /*
1461    ======================================================================
1462    g_varchar2 constant varchar2(9):= '$Sys_Def$';
1463    g_number constant number       := -987123654;
1464    g_date constant date           := to_date('01-01-4712','DD-MM-SYYYY');
1465    ======================================================================
1466   */
1467   l_scl_rec.concatenated_segments := hr_api.g_varchar2;
1468   l_scl_rec.segment1              := hr_api.g_varchar2;
1469   l_scl_rec.segment2              := hr_api.g_varchar2;
1470   l_scl_rec.segment3              := hr_api.g_varchar2;
1471   l_scl_rec.segment4              := hr_api.g_varchar2;
1472   l_scl_rec.segment5              := hr_api.g_varchar2;
1473   l_scl_rec.segment6              := hr_api.g_varchar2;
1474   l_scl_rec.segment7              := hr_api.g_varchar2;
1475   l_scl_rec.segment8              := hr_api.g_varchar2;
1476   l_scl_rec.segment9              := hr_api.g_varchar2;
1477   Hr_Utility.set_location(l_proc_name, 15);
1478   l_scl_rec.segment10             := hr_api.g_varchar2;
1479   l_scl_rec.segment11             := hr_api.g_varchar2;
1480   l_scl_rec.segment12             := hr_api.g_varchar2;
1481   l_scl_rec.segment13             := hr_api.g_varchar2;
1482   l_scl_rec.segment14             := hr_api.g_varchar2;
1483   l_scl_rec.segment15             := hr_api.g_varchar2;
1484   l_scl_rec.segment16             := hr_api.g_varchar2;
1485   l_scl_rec.segment17             := hr_api.g_varchar2;
1486   l_scl_rec.segment18             := hr_api.g_varchar2;
1487   l_scl_rec.segment19             := hr_api.g_varchar2;
1488   Hr_Utility.set_location(l_proc_name, 20);
1489   l_scl_rec.segment20             := hr_api.g_varchar2;
1490   l_scl_rec.segment21             := hr_api.g_varchar2;
1491   l_scl_rec.segment22             := hr_api.g_varchar2;
1492   l_scl_rec.segment23             := hr_api.g_varchar2;
1493   l_scl_rec.segment24             := hr_api.g_varchar2;
1494   l_scl_rec.segment25             := hr_api.g_varchar2;
1495   l_scl_rec.segment26             := hr_api.g_varchar2;
1496   l_scl_rec.segment27             := hr_api.g_varchar2;
1497   l_scl_rec.segment28             := hr_api.g_varchar2;
1498   l_scl_rec.segment29             := hr_api.g_varchar2;
1499   l_scl_rec.segment30             := hr_api.g_varchar2;
1500 
1501   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1502   return l_scl_rec;
1503 exception
1504   when others then
1505   Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1506   raise;
1507 
1508 end Default_Scflx_Rec;
1509 
1510 -- =============================================================================
1511 -- Get_ScflxRecord_Values:
1512 -- =============================================================================
1513 function Get_ScflxRecord_Values
1514         (p_interface_code in varchar2 default null)
1515          return hr_soft_coding_keyflex%rowtype is
1516 
1517   cursor bne_cols(c_interface_code in varchar2) is
1518   select lower(bic.interface_col_name) interface_col_name
1519     from bne_interface_cols_b  bic
1520    where bic.interface_code = c_interface_code
1521          and bic.SEQUENCE_NUM between 222 and 252 --$ All soft coded KFF segments
1522    --  and (bic.group_name = 'SOFT_KEYFLEX_GROUP' or
1523     --      lower(bic.interface_col_name) ='p_gre');
1524 
1525       -- $ Commented this as segments value is not passed due to this flag
1526      and bic.display_flag ='Y'; --Select only those segments that the user has selected while function creation
1527 
1528   l_proc_name    constant varchar2(150) := g_pkg||'Get_ScflxRecord_Values';
1529   l_scl_rec      hr_soft_coding_keyflex%rowtype;
1530   col_name       varchar2(150);
1531 
1532 begin
1533   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1534   if g_sec_asg_flag <> 1 then
1535       l_scl_rec := Default_Scflx_Rec;
1536   else
1537       l_scl_rec := null;
1538   end if;
1539 
1540   for col_rec in bne_cols (g_interface_code)
1541   loop
1542    case col_rec.interface_col_name
1543     when 'p_soft_segments' then
1544      l_scl_rec.concatenated_segments := g_scl_rec.concatenated_segments;
1545     when 's_segment1' then
1546      l_scl_rec.segment1 := g_scl_rec.segment1;
1547     when 'p_gre' then
1548      l_scl_rec.segment1 := g_scl_rec.segment1;
1549     when 's_segment2' then
1550      l_scl_rec.segment2 := g_scl_rec.segment2;
1551     when 's_segment3' then
1552      l_scl_rec.segment3 := g_scl_rec.segment3;
1553     when 's_segment4' then
1554      l_scl_rec.segment4 := g_scl_rec.segment4;
1555     when 's_segment5' then
1556      l_scl_rec.segment5 := g_scl_rec.segment5;
1557 
1558     when 's_segment6' then
1559      l_scl_rec.segment6 := g_scl_rec.segment6;
1560 
1561     when 's_segment7' then
1562      l_scl_rec.segment7 := g_scl_rec.segment7;
1563 
1564     when 's_segment8' then
1565      l_scl_rec.segment8 := g_scl_rec.segment8;
1566 
1567     when 's_segment9' then
1568      l_scl_rec.segment9 := g_scl_rec.segment9;
1569 
1570     when 's_segment10' then
1571      l_scl_rec.segment10 := g_scl_rec.segment10;
1572 
1573     when 's_segment11' then
1574      l_scl_rec.segment11 := g_scl_rec.segment11;
1575 
1576     when 's_segment12' then
1577      l_scl_rec.segment12 := g_scl_rec.segment12;
1578 
1579     when 's_segment13' then
1580      l_scl_rec.segment13 := g_scl_rec.segment13;
1581 
1582     when 's_segment14' then
1583      l_scl_rec.segment14 := g_scl_rec.segment14;
1584 
1585     when 's_segment15' then
1586      l_scl_rec.segment15 := g_scl_rec.segment15;
1587 
1588     when 's_segment16' then
1589      l_scl_rec.segment16 := g_scl_rec.segment16;
1590 
1591     when 's_segment17' then
1592      l_scl_rec.segment17 := g_scl_rec.segment17;
1593 
1594     when 's_segment18' then
1595      l_scl_rec.segment18 := g_scl_rec.segment18;
1596 
1597     when 's_segment19' then
1598      l_scl_rec.segment19 := g_scl_rec.segment19;
1599 
1600     when 's_segment20' then
1601      l_scl_rec.segment20 := g_scl_rec.segment20;
1602 
1603     when 's_segment21' then
1604      l_scl_rec.segment21 := g_scl_rec.segment21;
1605 
1606     when 's_segment22' then
1607      l_scl_rec.segment22 := g_scl_rec.segment22;
1608 
1609     when 's_segment23' then
1610      l_scl_rec.segment23 := g_scl_rec.segment23;
1611 
1612     when 's_segment24' then
1613      l_scl_rec.segment24 := g_scl_rec.segment24;
1614 
1615     when 's_segment25' then
1616      l_scl_rec.segment25 := g_scl_rec.segment25;
1617 
1618     when 's_segment26' then
1619      l_scl_rec.segment26 := g_scl_rec.segment26;
1620 
1621     when 's_segment27' then
1622      l_scl_rec.segment27 := g_scl_rec.segment27;
1623 
1624     when 's_segment28' then
1625      l_scl_rec.segment28 := g_scl_rec.segment28;
1626 
1627     when 's_segment29' then
1628      l_scl_rec.segment29 := g_scl_rec.segment29;
1629 
1630     when 's_segment30' then
1631      l_scl_rec.segment30 := g_scl_rec.segment30;
1632    else
1633       null;
1634    end case;
1635 
1636   end loop;
1637   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1638   return l_scl_rec;
1639 
1640 exception
1641   when others then
1642   Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
1643   raise;
1644 
1645 end Get_ScflxRecord_Values;
1646 -- =============================================================================
1647 -- Get_UnMasked_NI:
1648 -- =============================================================================
1649 function Get_UnMasked_NI
1650          (p_national_identifier     in varchar2
1651          ,p_batch_id                in number
1652          ,p_data_pump_batch_line_id in number
1653          ,p_web_adi_identifier      in varchar2
1654          )
1655          return varchar2 is
1656 
1657 
1658   csr_get_unmasked_ni          ref_cur_typ;
1659 
1660   l_proc_name    constant varchar2(150) :='Get_UnMasked_NI';
1661   l_dyn_sql_qry           varchar2(1000);
1662   l_national_identifier   per_all_people_f.national_identifier%type;
1663 
1664 begin
1665   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1666 
1667   if p_web_adi_identifier = 'DP ERROR' and
1668     (substrb(p_national_identifier, 1,
1669              lengthb(p_national_identifier) - 4) =  'XXX-XX-' or
1670      substrb(p_national_identifier, 3, 2) = 'XX'  or
1671      substrb(p_national_identifier, 1,
1672              lengthb(p_national_identifier) - 4) = 'XXXXX') then
1673      l_dyn_sql_qry :=
1674         ' select p_national_identifier
1675             from hrdpv_create_employee
1676            where batch_id = '   || p_batch_id  ||
1677           '  and link_value = ' || p_data_pump_batch_line_id ||
1678         ' union
1679           select p_national_identifier
1680             from hrdpv_update_person
1681            where batch_id = '   || p_batch_id     ||
1682           '  and link_value = ' || p_data_pump_batch_line_id;
1683 
1684       open  csr_get_unmasked_ni for l_dyn_sql_qry;
1685       fetch csr_get_unmasked_ni into l_national_identifier;
1686       close csr_get_unmasked_ni;
1687   else
1688       l_national_identifier := p_national_identifier;
1689   end if;
1690   if g_debug then
1691    Hr_Utility.set_location(' p_batch_id: '||p_batch_id, 50);
1692    Hr_Utility.set_location(' p_data_pump_batch_line_id: '||p_data_pump_batch_line_id, 50);
1693    Hr_Utility.set_location(' p_web_adi_identifier: '||p_web_adi_identifier, 50);
1694    Hr_Utility.set_location(' l_national_identifier: '||l_national_identifier, 50);
1695    Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1696   end if;
1697   return l_national_identifier;
1698 
1699 end Get_UnMasked_NI;
1700 
1701 function Chk_Dup_Person
1702          (p_national_identifier in varchar2
1703          ,p_business_group_id   in number
1704          ,p_effective_date      in date
1705          ,p_dup_person_id       in number
1706          ) return number is
1707 
1708   cursor csr_chk_per_exists (c_business_group_id   in number
1709                             ,c_effective_date      in date) is
1710   select ppf.person_id
1711         ,ppf.business_group_id
1712         ,ppf.employee_number
1713         ,ppf.applicant_number
1714         ,ppf.npw_number
1715         ,ppf.party_id
1716     from per_all_people_f ppf
1717    where (ppf.date_of_birth = g_per_rec.date_of_birth
1718           or ppf.date_of_birth is null
1719           or g_per_rec.date_of_birth is null)
1720      and upper(ppf.last_name) = upper(g_per_rec.last_name)
1721      and (ppf.sex = g_per_rec.sex
1722           or ppf.sex is null
1723           or g_per_rec.sex is null)
1724      and ppf.business_group_id   = c_business_group_id
1725      and c_effective_date between ppf.effective_start_date
1726                               and ppf.effective_end_date;
1727 
1728   cursor csr_chk_per_exists_mig (c_business_group_id   in number
1729                             ,c_effective_date      in date) is
1730   select ppf.person_id
1731         ,ppf.business_group_id
1732         ,ppf.employee_number
1733         ,ppf.applicant_number
1734         ,ppf.npw_number
1735         ,ppf.party_id
1736     from per_all_people_f ppf
1737    where ppf.date_of_birth = g_per_rec.date_of_birth
1738      and upper(ppf.last_name) = upper(g_per_rec.last_name)
1739      and ppf.sex = g_per_rec.sex
1740      and ppf.business_group_id   = c_business_group_id
1741      and c_effective_date between ppf.effective_start_date
1742                               and ppf.effective_end_date;
1743 
1744  --l_per_rec      csr_chk_ni_exists%rowtype;
1745   --$
1746   l_per_exists   csr_chk_per_exists%rowtype;
1747   l_person_id    per_all_people_f.person_id%type := null;
1748 
1749   l_proc_name    constant varchar2(150) := g_pkg||'Chk_NI_Exists';
1750 
1751   begin
1752 
1753         if g_migration_flag = 'Y' then
1754         hr_utility.set_location('The migration flag is y', 78);
1755         open csr_chk_per_exists_mig (c_business_group_id   => p_business_group_id
1756                                 ,c_effective_date      => p_effective_date);
1757         fetch csr_chk_per_exists_mig into l_per_exists;
1758         if csr_chk_per_exists_mig%found then
1759             hr_utility.trace('PERSON EXISTS');
1760             g_per_rec.person_id         := l_per_exists.person_id;
1761             g_per_rec.business_group_id := l_per_exists.business_group_id;
1762              --g_per_rec.employee_number   := l_per_rec.employee_number;
1763              --g_per_rec.applicant_number  := l_per_rec.applicant_number;
1764              --g_per_rec.npw_number        := l_per_rec.npw_number;
1765             g_per_rec.party_id          := l_per_exists.party_id;
1766 
1767             g_add_rec.person_id         := l_per_exists.person_id;
1768             g_add_rec.business_group_id := l_per_exists.business_group_id;
1769             g_add_rec.party_id          := l_per_exists.party_id;
1770 
1771             l_person_id := g_per_rec.person_id;
1772         end if;
1773         hr_utility.trace('PERSON DOES NOT EXIST');
1774         close csr_chk_per_exists_mig;
1775         else
1776                 hr_utility.set_location('The migration flag is n', 78);
1777         open csr_chk_per_exists (c_business_group_id   => p_business_group_id
1778                                 ,c_effective_date      => p_effective_date);
1779         fetch csr_chk_per_exists into l_per_exists;
1780         if csr_chk_per_exists%found then
1781            hr_utility.set_location('Records are found', 89);
1782            if csr_chk_per_exists%rowcount = 1 then
1783 --hr_utility.trace('PERSON EXISTS');
1784             hr_utility.set_location('One record is found', 90);
1785             g_per_rec.person_id         := l_per_exists.person_id;
1786             g_per_rec.business_group_id := l_per_exists.business_group_id;
1787              --g_per_rec.employee_number   := l_per_rec.employee_number;
1788              --g_per_rec.applicant_number  := l_per_rec.applicant_number;
1789              --g_per_rec.npw_number        := l_per_rec.npw_number;
1790             g_per_rec.party_id          := l_per_exists.party_id;
1791 
1792             g_add_rec.person_id         := l_per_exists.person_id;
1793             g_add_rec.business_group_id := l_per_exists.business_group_id;
1794             g_add_rec.party_id          := l_per_exists.party_id;
1795 
1796             l_person_id := g_per_rec.person_id;
1797            else
1798             hr_utility.set_location('More than one record is found', 91);
1799             l_person_id := p_dup_person_id;
1800            end if;
1801        end if;
1802        hr_utility.trace('Code has come here');
1803        close csr_chk_per_exists;
1804       end if;
1805 
1806       hr_utility.set_location('The person id found is '||l_person_id, 92);
1807   return l_person_id;
1808 end Chk_Dup_Person;
1809 -- =============================================================================
1810 -- Chk_NI_Exists: Check if NI entered already exists in the system, that implies
1811 -- that user is accidently trying to enter a duplicate.
1812 -- =============================================================================
1813 function Chk_NI_Exists
1814          (p_national_identifier in varchar2
1815          ,p_business_group_id   in number
1816          ,p_effective_date      in date
1817          ,p_dup_person_id       in number
1818          ) return number is
1819   --
1820   -- Check for Ex-Emp, as we should allow a person to be rehired,
1821   -- that implies that NI for Ex-Emp may already exist.
1822   --
1823   cursor csr_chk_ni_exists (c_national_identifier in varchar2
1824                            ,c_business_group_id   in number
1825                            ,c_effective_date      in date) is
1826   select ppf.person_id
1827         ,ppf.business_group_id
1828         ,ppf.employee_number
1829         ,ppf.applicant_number
1830         ,ppf.npw_number
1831         ,ppf.party_id
1832     from per_all_people_f ppf
1833    where ppf.national_identifier = c_national_identifier
1834      and ppf.business_group_id   = c_business_group_id
1835      and c_effective_date between ppf.effective_start_date
1836                               and ppf.effective_end_date;
1837 
1838   l_per_rec      csr_chk_ni_exists%rowtype;
1839   --$
1840   --l_per_exists   csr_chk_per_exists%rowtype;
1841   l_person_id    per_all_people_f.person_id%type := null;
1842 
1843   l_proc_name    constant varchar2(150) := g_pkg||'Chk_NI_Exists';
1844 begin
1845    Hr_Utility.set_location('Entering: '||l_proc_name, 5);
1846 
1847  --$ If national identifier is available (for US legislation for e.g.)
1848  -- then use it to check if the person record exists or not
1849  -- else use Combination of person details to check the same
1850   if p_national_identifier is not null then
1851 
1852   --hr_utility.trace('NATIONAL IDENTIFIER AVAILABLE');
1853    hr_utility.set_location('The national identifier is found '||p_national_identifier, 78);
1854    hr_utility.set_location('The bg id found is '||p_business_group_id, 79);
1855    hr_utility.set_location('The date found is '||p_effective_date, 80);
1856 
1857   open  csr_chk_ni_exists(c_national_identifier => p_national_identifier
1858                          ,c_business_group_id   => p_business_group_id
1859                          ,c_effective_date      => p_effective_date);
1860 
1861   fetch csr_chk_ni_exists into l_per_rec;
1862   if csr_chk_ni_exists%found then
1863      hr_utility.set_location('Records are found ', 89);
1864 
1865         hr_utility.trace('PERSON EXISTS by NI');
1866          g_per_rec.person_id         := l_per_rec.person_id;
1867          g_per_rec.business_group_id := l_per_rec.business_group_id;
1868      --g_per_rec.employee_number   := l_per_rec.employee_number;
1869      --g_per_rec.applicant_number  := l_per_rec.applicant_number;
1870      --g_per_rec.npw_number        := l_per_rec.npw_number;
1871          g_per_rec.party_id          := l_per_rec.party_id;
1872 
1873          g_add_rec.person_id         := l_per_rec.person_id;
1874          g_add_rec.business_group_id := l_per_rec.business_group_id;
1875          g_add_rec.party_id          := l_per_rec.party_id;
1876 
1877          l_person_id := g_per_rec.person_id;
1878          hr_utility.set_location('The person id found is ' || l_person_id, 78);
1879      else
1880          hr_utility.set_location('No Match found', 22);
1881          l_person_id := Chk_Dup_Person
1882                                       (p_national_identifier => p_national_identifier
1883                                       ,p_business_group_id   => p_business_group_id
1884                                       ,p_effective_date      => p_effective_date
1885                                       ,p_dup_person_id       => p_dup_person_id
1886                                       );
1887   end if;
1888   close csr_chk_ni_exists;
1889   else
1890          l_person_id := Chk_Dup_Person
1891                              (p_national_identifier => p_national_identifier
1892                              ,p_business_group_id   => p_business_group_id
1893                              ,p_effective_date      => p_effective_date
1894                              ,p_dup_person_id       => p_dup_person_id
1895                              );
1896 
1897   end if;
1898 
1899   hr_utility.set_location('The person id found is '|| l_person_id, 66);
1900   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
1901 
1902   return l_person_id ; --$ l_per_rec.person_id;
1903 
1904 end Chk_NI_Exists;
1905 -- =============================================================================
1906 -- Get_WrkStrs_Names: The assignment DataPump api accepts name instead of ids
1907 -- for work structures like grade, job, organization etc.
1908 -- =============================================================================
1909 procedure Get_WrkStrs_Names is
1910   l_proc_name  constant    varchar2(150):= g_pkg ||'Get_WrkStrs_Names';
1911   l_pay_basis_name         per_pay_bases.name%type;
1912   l_organization_name      hr_all_organization_units.name%type;
1913   l_location_code          hr_locations_all.location_code%type;
1914   l_payroll_name           pay_all_payrolls_f.payroll_name%type;
1915   l_job_name               per_jobs.name%type;
1916   l_position_name          hr_all_positions_f.name%type;
1917   l_grade_name             per_grades.name%type;
1918 begin
1919   hr_utility.set_location('Entering: ' || l_proc_name, 5);
1920   g_wstr_names := null;
1921   -- Get grade name
1922   open  csr_grade(g_asg_rec.grade_id
1923                  ,g_asg_rec.business_group_id
1924                  ,g_per_rec.start_date);
1925   fetch csr_grade into l_grade_name;
1926   if csr_grade%notfound then
1927      hr_utility.set_location('..Grade Name not found Id: ' ||
1928                               g_asg_rec.grade_id, 6);
1929   else
1930      g_wstr_names.grade_name :=  l_grade_name;
1931   end if;
1932   close csr_grade;
1933   -- Get position name
1934   open  csr_position (g_asg_rec.position_id
1935                      ,g_asg_rec.business_group_id
1936                      ,g_per_rec.start_date);
1937   fetch csr_position into l_position_name;
1938   if csr_position%notfound then
1939      hr_utility.set_location('..Position Name not found Id: ' ||
1940                               g_asg_rec.position_id, 7);
1941   else
1942      g_wstr_names.position_name :=  l_position_name;
1943   end if;
1944   close csr_position;
1945   -- Get job name
1946   open  csr_job(g_asg_rec.job_id
1947                ,g_asg_rec.business_group_id
1948                ,g_per_rec.start_date);
1949   fetch csr_job into l_job_name;
1950   if csr_job%notfound then
1951      hr_utility.set_location('..Job Name not found Id: ' ||
1952                               g_asg_rec.job_id, 8);
1953   else
1954      g_wstr_names.job_name :=  l_job_name;
1955   end if;
1956   close csr_job;
1957   -- Get payroll name
1958   open  csr_payroll(g_asg_rec.payroll_id
1959                    ,g_asg_rec.business_group_id
1960                    ,g_per_rec.start_date);
1961   fetch csr_payroll into l_payroll_name;
1962   if csr_payroll%notfound then
1963      hr_utility.set_location('..Payroll Name not found Id: ' ||
1964                               g_asg_rec.payroll_id, 9);
1965   else
1966      g_wstr_names.payroll_name :=  l_payroll_name;
1967   end if;
1968   close csr_payroll;
1969   -- Get location code
1970   open  csr_location(g_asg_rec.location_id
1971                     ,g_asg_rec.business_group_id);
1972   fetch csr_location into l_location_code;
1973   if csr_location%notfound then
1974      hr_utility.set_location('..Location Code not found, Id: ' ||
1975                               g_asg_rec.location_id, 10);
1976   else
1977      g_wstr_names.location_code :=  l_location_code;
1978   end if;
1979   close csr_location;
1980   -- Get organization name
1981   open  csr_organization(g_asg_rec.organization_id
1982                         ,g_asg_rec.business_group_id
1983                         ,g_per_rec.start_date);
1984   fetch csr_organization into l_organization_name;
1985   if csr_organization%notfound then
1986      hr_utility.set_location('..Org Name not found, Id: ' ||
1987                               g_asg_rec.organization_id, 11);
1988   else
1989      g_wstr_names.organization_name :=  l_organization_name;
1990   end if;
1991   close csr_organization;
1992   -- Get pay basis name
1993   open  csr_paybasis(g_asg_rec.pay_basis_id
1994                     ,g_asg_rec.business_group_id);
1995   fetch csr_paybasis into l_pay_basis_name;
1996   if csr_paybasis%notfound then
1997      hr_utility.set_location('..Org Name not found, Id: ' ||
1998                               g_asg_rec.pay_basis_id, 12);
1999   else
2000      g_wstr_names.pay_basis_name :=  l_pay_basis_name;
2001   end if;
2002   close csr_paybasis;
2003 
2004   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
2005 
2006 end Get_WrkStrs_Names;
2007 -- =============================================================================
2008 -- ~ EmpAplCwk_NumGen:
2009 -- =============================================================================
2010 procedure EmpAplCwk_NumGen
2011          (p_employee_number  in varchar2
2012          ,p_applicant_number in varchar2
2013          ,p_cwk_number       in varchar2
2014          ) is
2015   l_proc_name  constant    varchar2(150):= g_pkg ||'EmpAplCwk_NumGen';
2016 begin
2017   hr_utility.set_location('Entering: ' || l_proc_name, 5);
2018   if g_emp_num_gen <> 'A' then
2019     g_per_rec.employee_number := p_employee_number;
2020   else
2021     g_per_rec.employee_number := null;
2022   end if;
2023 
2024   if g_apl_num_gen <> 'A' then
2025     g_per_rec.applicant_number := p_applicant_number;
2026   else
2027     g_per_rec.applicant_number := null;
2028   end if;
2029 
2030   if g_cwk_num_gen <> 'A' then
2031     g_per_rec.npw_number := p_cwk_number;
2032   else
2033     g_per_rec.npw_number := null;
2034   end if;
2035   if g_debug then
2036      hr_utility.set_location(' p_employee_number : ' || p_employee_number, 6);
2037      hr_utility.set_location(' p_applicant_number: ' || p_applicant_number, 6);
2038      hr_utility.set_location(' p_cwk_number      : ' || p_cwk_number, 6);
2039      hr_utility.set_location(' g_emp_num_gen: ' || g_emp_num_gen, 6);
2040      hr_utility.set_location(' g_apl_num_gen: ' || g_apl_num_gen, 6);
2041      hr_utility.set_location(' g_cwk_num_gen: ' || p_cwk_number, 6);
2042   end if;
2043 
2044   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
2045 end EmpAplCwk_NumGen;
2046 -- =============================================================================
2047 -- ~ Get_DataTrack_Mode:
2048 -- =============================================================================
2049 procedure Get_DataTrack_Mode
2050           (p_datetrack_update_mode out nocopy varchar2
2051           ) is
2052   l_cur_per_rec            csr_per%rowtype;
2053   l_ptu_rec                chk_perType_usage%rowtype;
2054   l_datetrack_update_mode  varchar2(50);
2055   l_dt_correction          boolean;
2056   l_dt_update              boolean;
2057   l_dt_upd_override        boolean;
2058   l_upd_chg_ins            boolean;
2059   l_error_msg              varchar2(2000);
2060   l_proc_name  constant    varchar2(150):= g_pkg ||'Get_DataTrack_Mode';
2061   e_future_chgs_exists     exception;
2062 begin
2063   hr_utility.set_location('Entering: ' || l_proc_name, 5);
2064   if g_per_rec.person_id is not null then
2065     open  csr_per(c_person_id         => g_per_rec.person_id
2066                  ,c_business_group_id => g_per_rec.business_group_id
2067                  ,c_effective_date    => g_per_rec.start_date);
2068     fetch csr_per into l_cur_per_rec;
2069     close csr_per;
2070     hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
2071 
2072     Dt_Api.Find_DT_Upd_Modes
2073     (p_effective_date        => g_per_rec.start_date
2074     ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
2075     ,p_base_key_column       => 'PERSON_ID'
2076     ,p_base_key_value        => l_cur_per_rec.person_id
2077     ,p_correction            => l_dt_correction
2078     ,p_update                => l_dt_update
2079     ,p_update_override       => l_dt_upd_override
2080     ,p_update_change_insert  => l_upd_chg_ins
2081      );
2082 
2083     if l_dt_update then
2084        l_datetrack_update_mode := 'UPDATE';
2085     elsif l_dt_upd_override or
2086           l_upd_chg_ins then
2087           -- Need to check if person type in future is EMP, APL or CWK , if yes
2088           -- then raise error
2089           open chk_perType_usage
2090              (c_person_id         => l_cur_per_rec.person_id
2091              ,c_effective_date    => g_per_rec.start_date
2092              ,c_business_group_id => g_per_rec.business_group_id);
2093 
2094           fetch chk_perType_usage into l_ptu_rec;
2095           if chk_perType_usage%found then
2096              close chk_perType_usage;
2097              raise e_future_chgs_exists;
2098           end if;
2099           close chk_perType_usage;
2100          --Else USE Correction Mode
2101         l_datetrack_update_mode := 'CORRECTION';
2102     else
2103        l_datetrack_update_mode := 'CORRECTION';
2104     end if;
2105 
2106     hr_utility.set_location('l_datetrack_update_mode: ' ||
2107                              l_datetrack_update_mode, 30);
2108     g_per_rec.object_version_number := l_cur_per_rec.object_version_number;
2109     EmpAplCwk_NumGen
2110     (p_employee_number  => nvl(l_cur_per_rec.employee_number,
2111                                g_per_rec.employee_number)
2112     ,p_applicant_number => nvl(l_cur_per_rec.applicant_number,
2113                                g_per_rec.applicant_number)
2114     ,p_cwk_number       => nvl(l_cur_per_rec.npw_number,
2115                                g_per_rec.npw_number)
2116      );
2117   end if;
2118   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
2119 exception
2120   when e_future_chgs_exists then
2121     l_error_msg :=
2122        'This person cannot be created/updated in HRMS as the '||
2123        'Person has future changes beyond the date: '||g_per_rec.start_date;
2124 
2125     hr_utility.set_location('..Future Update exists for the Student Employee', 90);
2126     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
2127     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2128     hr_utility.raise_error;
2129 
2130 end Get_DataTrack_Mode;
2131 -- =============================================================================
2132 -- Chk_Person_InHR:
2133 -- =============================================================================
2134 procedure Chk_Person_InHR
2135          (p_dup_person_id        in number
2136          ,p_dup_party_id         in number
2137          ,p_effective_date       in date
2138          ,p_business_group_id    in number
2139          ,p_Input_PerType        out nocopy varchar2
2140          ,p_hire_Into_Employee   out nocopy boolean
2141          ,p_Hire_Applicant       out nocopy boolean
2142          ,p_Convert_To_Applicant out nocopy boolean
2143          ,p_Apply_For_Job        out nocopy boolean
2144          ,p_Convert_To_CWK       out nocopy boolean
2145          ,p_Per_Exists_InHR      out nocopy boolean
2146          ) is
2147 
2148   cursor csr_type (c_person_type_id in number) is
2149   select *
2150     from per_person_types
2151    where person_type_id = c_person_type_id
2152      and business_group_id = p_business_group_id;
2153 
2154   l_pty_rec     csr_type%rowtype;
2155 
2156   cursor chk_party (c_party_id       in number
2157                    ,c_bg_grp_id      in number
2158                    ,c_person_id      in number
2159                    ,c_effective_date in date) is
2160   select ppt.system_person_type
2161         ,ppt.user_person_type
2162         ,ppf.effective_start_date
2163         ,ppf.effective_end_date
2164         ,ppf.employee_number
2165         ,ppf.applicant_number
2166         ,ppf.npw_number
2167         ,ptu.person_type_id
2168         ,ppf.person_id
2169         ,ppf.object_version_number
2170     from per_all_people_f         ppf
2171         ,per_person_type_usages_f ptu
2172         ,per_person_types         ppt
2173    where ptu.person_type_id = ppf.person_type_id
2174      and ppt.person_type_id = ptu.person_type_id
2175      and ppt.business_group_id = ppf.business_group_id
2176      and ppf.business_group_id = c_bg_grp_id
2177      and ((c_person_id is not null and ppf.person_id = c_person_id) or
2178           (c_party_id  is not null and ppf.party_id = c_party_id))
2179      and c_effective_date between ppf.effective_start_date
2180                               and ppf.effective_end_date
2181      and c_effective_date between ptu.effective_start_date
2182                               and ptu.effective_end_date;
2183 
2184   l_chk_per              chk_party%rowtype;
2185   l_error_msg            varchar2(2000);
2186   --
2187   -- Exceptions
2188   --
2189   e_InValid_PerType_Id   exception;
2190   e_active_empcwk        exception;
2191   e_active_apl           exception;
2192   l_person_id            per_all_people_f.person_id%type;
2193   l_party_id             per_all_people_f.person_id%type;
2194   l_user_person_type     per_person_types.user_person_type%TYPE;
2195   l_effective_date       date;
2196   l_proc_name  constant  varchar2(150):= g_pkg ||'Chk_Person_InHR';
2197 begin
2198   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
2199     --hr_utility.trace('Inside Chk_Person_InHR');
2200 
2201    open csr_type(g_per_rec.person_type_id);
2202   fetch csr_type into l_pty_rec;
2203   close csr_type;
2204 
2205   p_hire_Into_Employee   := false;
2206   p_Convert_To_Applicant := false;
2207   p_Convert_To_CWK       := false;
2208   p_Per_Exists_InHR      := false;
2209   p_Hire_Applicant       := false;
2210   p_Apply_For_Job        := false;
2211 
2212   if l_pty_rec.system_person_type is null then
2213      l_error_msg :=
2214      'Invalid person type passed. Please select a valid person type.';
2215      raise e_InValid_PerType_Id;
2216   end if;
2217 
2218   p_Input_PerType := l_pty_rec.system_person_type;
2219   l_person_id     := p_dup_person_id;
2220   l_party_id      := p_dup_party_id;
2221 
2222 
2223   if l_person_id is null then
2224     l_person_id := Chk_NI_Exists
2225                   (p_national_identifier => g_per_rec.national_identifier
2226                   ,p_business_group_id   => p_business_group_id
2227                   ,p_effective_date      => p_effective_date
2228                   ,p_dup_person_id       => p_dup_person_id
2229                    );
2230   end if;
2231 
2232   if l_party_id is null then
2233      l_party_id := g_per_rec.party_id;
2234   else
2235      g_per_rec.party_id := l_party_id;
2236   end if;
2237 
2238 
2239   if (l_person_id is not null or
2240         l_party_id  is not null) then
2241 
2242       --
2243       -- Loop thru all the person types that person has as of the
2244       -- effective date he is being created/updated in HRMS.
2245       --
2246             for per_rec in chk_party
2247                           (c_party_id       => l_party_id
2248                           ,c_bg_grp_id      => p_business_group_id
2249                           ,c_person_id      => l_person_id
2250                           ,c_effective_date => p_effective_date)
2251       loop
2252 
2253 
2254         g_per_rec.person_id := per_rec.person_id;
2255         if l_pty_rec.system_person_type = 'EMP' then
2256            -- If person is EMP or CWK raise an error
2257            if per_rec.system_person_type = 'CWK' then
2258               l_error_msg :=
2259               'Person already exits as an: '||per_rec.user_person_type||
2260               ' as of the '||p_effective_date;
2261               raise e_active_empcwk;
2262            elsif per_rec.system_person_type = ('EMP') then
2263               l_user_person_type := per_rec.user_person_type;
2264               l_effective_date   := p_effective_date;
2265               p_Input_PerType := 'UPD_PERSON';
2266            elsif per_rec.system_person_type in ('EX_EMP','EX_CWK'
2267                                                ,'EX_APL','OTHER') then
2268               p_hire_Into_Employee := true;
2269            elsif per_rec.system_person_type in ('APL') then
2270               p_hire_Applicant := true;
2271            end if;
2272 
2273         elsif l_pty_rec.system_person_type = 'APL' then
2274            -- If perosn is APL, the update person details
2275            if per_rec.system_person_type in ('APL') then
2276               l_error_msg :=
2277               'Person already exits as an: '||per_rec.user_person_type||
2278               ' as of the '||p_effective_date;
2279               l_user_person_type := per_rec.user_person_type;
2280               l_effective_date   := p_effective_date;
2281               p_Input_PerType := 'UPD_PERSON';
2282            elsif per_rec.system_person_type in ('EX_EMP','EX_CWK'
2283                                                ,'EX_APL','OTHER') then
2284               p_Convert_To_Applicant := true;
2285 
2286            elsif per_rec.system_person_type in ('CWK','EMP') then
2287               p_Apply_For_Job := true;
2288 
2289            end if;
2290 
2291         elsif l_pty_rec.system_person_type = 'CWK' then
2292            -- If person is CWK raise error
2293            if per_rec.system_person_type = 'EMP' then
2294               l_error_msg :=
2295               'Person already exits as an: '||per_rec.user_person_type||
2296               ' as of the '||p_effective_date;
2297               l_user_person_type := per_rec.user_person_type;
2298               l_effective_date   := p_effective_date;
2299               raise e_active_empcwk;
2300            elsif per_rec.system_person_type = 'CWK' then
2301               l_user_person_type := per_rec.user_person_type;
2302               l_effective_date   := p_effective_date;
2303               p_Input_PerType    := 'UPD_PERSON';
2304 
2305            elsif per_rec.system_person_type in ('EX_EMP','EX_CWK','APL'
2306                                                ,'EX_APL','OTHER') then
2307               p_Convert_To_CWK := true;
2308            end if;
2309 
2310         elsif l_pty_rec.system_person_type = 'OTHER' then
2311               p_Per_Exists_InHR := true;
2312         end if;
2313 
2314       end loop;
2315   end if;
2316 
2317   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
2318 
2319 exception
2320   when e_InValid_PerType_Id then
2321     hr_utility.set_message(8303, 'PQP_230492_RIW_INVAL_PER_TYPE');
2322     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2323     hr_utility.raise_error;
2324 
2325   when e_active_empcwk then
2326     hr_utility.set_message(8303, 'PQP_230493_RIW_PERSON_EXISTS');
2327     hr_utility.set_message_token('TOKEN1',l_user_person_type );
2328     hr_utility.set_message_token('TOKEN2',l_effective_date );
2329     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2330     hr_utility.raise_error;
2331 
2332   when e_active_apl then
2333     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
2334     hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
2335     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2336     hr_utility.raise_error;
2337 
2338   when Others then
2339   hr_utility.set_location('SQLERRM[CODE] :' || SQLCODE,90);
2340   hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2341   raise;
2342 
2343 end Chk_Person_InHR;
2344 
2345 -- =============================================================================
2346 -- ~ Upd_Applicant_Asg :
2347 -- =============================================================================
2348 procedure Upd_Applicant_Asg
2349          (p_effective_date in date
2350          ,p_asg_crit_out   in out NOCOPY t_AsgUpdCrit_Api
2351          --,p_UpdEmpAsg_out  IN OUT NOCOPY t_Upd_Emp_Asg_Api
2352           ) as
2353 
2354   -- Cursor to get Assignment details
2355   cursor csr_asg (c_effective_date in date
2356                  ,c_assignment_id  in number
2357                  ,c_business_group_id in number)is
2358   select *
2359     from per_all_assignments_f paf
2360    where paf.assignment_id = c_assignment_id
2361      and paf.business_group_id = c_business_group_id
2362      and c_effective_date between paf.effective_start_date
2363                               and paf.effective_end_date;
2364 
2365   l_cur_asg_rec            csr_asg%rowtype;
2366 
2367   -- Cursor to get people group flexfield details
2368   cursor csr_ppg (c_people_grp_id in number) is
2369   select *
2370     from pay_people_groups
2371    where people_group_id = c_people_grp_id;
2372 
2373   l_cur_ppl_grp_rec        pay_people_groups%rowtype;
2374 
2375   -- Cursor to get Soft coding flexfield details
2376   cursor csr_scl (c_scl_kff_id in number) is
2377   select *
2378     from hr_soft_coding_keyflex
2379    where soft_coding_keyflex_id = c_scl_kff_id;
2380 
2381   l_cur_scl_rec        hr_soft_coding_keyflex%rowtype;
2382 
2383   l_proc_name  constant    varchar2(150):= g_pkg ||'Upd_Applicant_Asg';
2384   l_error_msg              varchar2(2000);
2385   l_datetrack_update_mode  varchar2(50);
2386   l_dt_correction          boolean;
2387   l_dt_update              boolean;
2388   l_dt_upd_override        boolean;
2389   l_upd_chg_ins            boolean;
2390   e_empasg_notfound        exception;
2391   l_UpdEmpAsg_out          t_Upd_Emp_Asg_Api;
2392   l_asg_rec                per_all_assignments_f%rowtype;
2393   l_grp_rec                pay_people_groups%rowtype;
2394   l_scl_rec                hr_soft_coding_keyflex%rowtype;
2395   l_expected_system_status varchar2(20);
2396   l_return_status          varchar2(100);
2397 
2398 begin
2399   hr_utility.set_location('Entering: ' || l_proc_name, 10);
2400 
2401   l_asg_rec := Get_AsgRecord_Values(g_interface_code);
2402   l_grp_rec := Get_GrpRecord_Values(g_interface_code);
2403   l_scl_rec := Get_ScflxRecord_Values(g_interface_code);
2404 
2405   open  csr_asg (c_effective_date    => p_effective_date
2406                 ,c_assignment_id     => g_asg_rec.assignment_id
2407                 ,c_business_group_id => g_asg_rec.business_group_id
2408                  );
2409   fetch csr_asg into l_cur_asg_rec;
2410   if csr_asg%notfound then
2411      close csr_asg;
2412      raise e_empasg_notfound;
2413   end if;
2414   close csr_asg;
2415   hr_utility.set_location(' l_cur_asg_rec: ' || p_effective_date, 20);
2416   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.assignment_id, 20);
2417   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.business_group_id, 20);
2418   --
2419   -- Check is the People Group Id is passed
2420   --
2421   open  csr_ppg(c_people_grp_id => g_asg_rec.people_group_id);
2422   fetch csr_ppg into l_cur_ppl_grp_rec;
2423  --$ Do not assign people group id from existing record but from the combination
2424    -- of the segments obtained from user
2425    if csr_ppg%found then
2426      p_asg_crit_out.people_group_id := g_asg_rec.people_group_id;
2427      l_asg_rec.people_group_id := g_asg_rec.people_group_id;
2428 
2429   /*if csr_ppg%notfound then
2430      g_asg_rec.people_group_id
2431        := l_cur_asg_rec.people_group_id;
2432      l_asg_rec.people_group_id
2433        := l_cur_asg_rec.people_group_id;*/
2434 
2435   end if;
2436   close csr_ppg;
2437   hr_utility.set_location(' people_group_id: ' || g_asg_rec.people_group_id, 30);
2438   --
2439   -- check if the Soft-Coding KFF id is passed
2440   --
2441   open  csr_scl(c_scl_kff_id => g_asg_rec.soft_coding_keyflex_id);
2442   fetch csr_scl into l_cur_scl_rec;
2443   --$ Do not assign soft keyflex id from existing record but from the combination
2444    -- of the segments obtained from user
2445  if csr_scl%found then
2446      p_asg_crit_out.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
2447      l_asg_rec.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
2448  /*   if csr_scl%notfound then
2449      g_asg_rec.soft_coding_keyflex_id
2450        := l_cur_asg_rec.soft_coding_keyflex_id;
2451      l_asg_rec.soft_coding_keyflex_id
2452        := l_cur_asg_rec.soft_coding_keyflex_id; */
2453 
2454   end if;
2455 
2456   close csr_scl;
2457   hr_utility.set_location(' soft_coding_keyflex_id: ' ||
2458                             g_asg_rec.soft_coding_keyflex_id, 40);
2459   --
2460   -- Get the datetrack mode based on the effective date passed
2461   --
2462   Dt_Api.Find_DT_Upd_Modes
2463   (p_effective_date        =>  p_effective_date
2464   ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
2465   ,p_base_key_column       => 'ASSIGNMENT_ID'
2466   ,p_base_key_value        => g_asg_rec.assignment_id
2467   ,p_correction            => l_dt_correction
2468   ,p_update                => l_dt_update
2469   ,p_update_override       => l_dt_upd_override
2470   ,p_update_change_insert  => l_upd_chg_ins
2471    );
2472 
2473   if l_dt_update then
2474      l_datetrack_update_mode := 'UPDATE';
2475   elsif l_dt_upd_override or
2476         l_upd_chg_ins then
2477              --Else USE Correction Mode
2478         l_datetrack_update_mode := 'CORRECTION';
2479      hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 50);
2480   else
2481      l_datetrack_update_mode := 'CORRECTION';
2482   end if;
2483   hr_utility.set_location(' l_datetrack_update_mode: ' ||
2484                             l_datetrack_update_mode, 60);
2485 
2486   g_asg_rec.cagr_grade_def_id := nvl(g_asg_rec.cagr_grade_def_id,
2487                                      l_cur_asg_rec.cagr_grade_def_id);
2488   l_asg_rec.cagr_grade_def_id := g_asg_rec.cagr_grade_def_id;
2489 
2490 -- added by psengupt
2491 -- first we need to change the assignment status using hr_assignment_internal package
2492 --then change the other assignment details
2493    Select PER_SYSTEM_STATUS into l_expected_system_status
2494      from per_assignment_status_types
2495     where assignment_status_type_id = l_asg_rec.assignment_status_type_id;
2496 
2497        hr_assignment_swi.update_apl_asg
2498   (p_effective_date               => p_effective_date
2499   ,p_datetrack_update_mode        => l_datetrack_update_mode
2500   ,p_assignment_id                => g_asg_rec.assignment_id
2501   ,p_object_version_number        => l_cur_asg_rec.object_version_number
2502   ,p_recruiter_id                 => l_cur_asg_rec.recruiter_id
2503   ,p_grade_id                     => l_asg_rec.grade_id
2504   ,p_position_id                  => l_asg_rec.position_id
2505   ,p_job_id                       => l_asg_rec.job_id
2506   ,p_payroll_id                   => l_asg_rec.payroll_id
2507   ,p_location_id                  => l_asg_rec.location_id
2508   ,p_organization_id              => l_asg_rec.organization_id
2509   ,p_assignment_status_type_id    => l_asg_rec.assignment_status_type_id
2510   ,p_person_referred_by_id        => l_cur_asg_rec.person_referred_by_id
2511   ,p_supervisor_id                => l_asg_rec.supervisor_id
2512   ,p_special_ceiling_step_id      => l_asg_rec.special_ceiling_step_id
2513   ,p_source_organization_id       => l_asg_rec.source_organization_id
2514   ,p_recruitment_activity_id      => l_cur_asg_rec.recruitment_activity_id
2515   ,p_vacancy_id                   => l_cur_asg_rec.vacancy_id
2516   ,p_pay_basis_id                 => l_asg_rec.pay_basis_id
2517   ,p_application_id               => l_cur_asg_rec.application_id
2518   ,p_change_reason                => l_asg_rec.change_reason
2519   ,p_comments                     => g_asg_comments
2520   ,p_date_probation_end           => l_asg_rec.date_probation_end
2521   ,p_default_code_comb_id         => l_asg_rec.default_code_comb_id
2522   ,p_employment_category          => l_asg_rec.employment_category
2523   ,p_frequency                    => l_asg_rec.frequency
2524   ,p_normal_hours                 => l_asg_rec.normal_hours
2525   ,p_internal_address_line        => l_asg_rec.internal_address_line
2526   ,p_manager_flag                 => l_asg_rec.manager_flag
2527   ,p_probation_period             => l_asg_rec.probation_period
2528   ,p_probation_unit               => l_asg_rec.probation_unit
2529   ,p_perf_review_period           => l_asg_rec.perf_review_period
2530   ,p_perf_review_period_frequency => l_asg_rec.perf_review_period_frequency
2531   ,p_sal_review_period            => l_asg_rec.sal_review_period
2532   ,p_sal_review_period_frequency  => l_asg_rec.sal_review_period_frequency
2533   ,p_set_of_books_id              => l_asg_rec.set_of_books_id
2534   ,p_source_type                  => l_asg_rec.source_type
2535   ,p_bargaining_unit_code         => l_asg_rec.bargaining_unit_code
2536   ,p_time_normal_finish           => l_asg_rec.time_normal_finish
2537   ,p_time_normal_start            => l_asg_rec.time_normal_start
2538   ,p_ass_attribute_category       => l_asg_rec.ass_attribute_category
2539   ,p_ass_attribute1               => l_asg_rec.ass_attribute1
2540   ,p_ass_attribute2               => l_asg_rec.ass_attribute2
2541   ,p_ass_attribute3               => l_asg_rec.ass_attribute3
2542   ,p_ass_attribute4               => l_asg_rec.ass_attribute4
2543   ,p_ass_attribute5               => l_asg_rec.ass_attribute5
2544   ,p_ass_attribute6               => l_asg_rec.ass_attribute6
2545   ,p_ass_attribute7               => l_asg_rec.ass_attribute7
2546   ,p_ass_attribute8               => l_asg_rec.ass_attribute8
2547   ,p_ass_attribute9               => l_asg_rec.ass_attribute9
2548   ,p_ass_attribute10              => l_asg_rec.ass_attribute10
2549   ,p_ass_attribute11              => l_asg_rec.ass_attribute11
2550   ,p_ass_attribute12              => l_asg_rec.ass_attribute12
2551   ,p_ass_attribute13              => l_asg_rec.ass_attribute13
2552   ,p_ass_attribute14              => l_asg_rec.ass_attribute14
2553   ,p_ass_attribute15              => l_asg_rec.ass_attribute15
2554   ,p_ass_attribute16              => l_asg_rec.ass_attribute16
2555   ,p_ass_attribute17              => l_asg_rec.ass_attribute17
2556   ,p_ass_attribute18              => l_asg_rec.ass_attribute18
2557   ,p_ass_attribute19              => l_asg_rec.ass_attribute19
2558   ,p_ass_attribute20              => l_asg_rec.ass_attribute20
2559   ,p_ass_attribute21              => l_asg_rec.ass_attribute21
2560   ,p_ass_attribute22              => l_asg_rec.ass_attribute22
2561   ,p_ass_attribute23              => l_asg_rec.ass_attribute23
2562   ,p_ass_attribute24              => l_asg_rec.ass_attribute24
2563   ,p_ass_attribute25              => l_asg_rec.ass_attribute25
2564   ,p_ass_attribute26              => l_asg_rec.ass_attribute26
2565   ,p_ass_attribute27              => l_asg_rec.ass_attribute27
2566   ,p_ass_attribute28              => l_asg_rec.ass_attribute28
2567   ,p_ass_attribute29              => l_asg_rec.ass_attribute29
2568   ,p_ass_attribute30              => l_asg_rec.ass_attribute30
2569   ,p_title                        => l_asg_rec.title
2570   ,p_concatenated_segments        => l_UpdEmpAsg_out.concatenated_segments
2571   ,p_contract_id                  => l_asg_rec.contract_id
2572   ,p_establishment_id             => l_asg_rec.establishment_id
2573   ,p_job_post_source_name         => l_asg_rec.job_post_source_name
2574   ,p_posting_content_id           => l_asg_rec.posting_content_id
2575   ,p_applicant_rank               => l_asg_rec.applicant_rank
2576   ,p_cagr_grade_def_id            => g_asg_rec.cagr_grade_def_id
2577   --,p_collective_agreement_id      in     number    default hr_api.g_number
2578   ,p_notice_period                => l_asg_rec.notice_period
2579   ,p_notice_period_uom            => l_asg_rec.notice_period_uom
2580   ,p_employee_category            => l_asg_rec.employee_category
2581   ,p_work_at_home                 => l_asg_rec.work_at_home
2582   ,p_cagr_concatenated_segments   => l_UpdEmpAsg_out.cagr_concatenated_segments
2583   ,p_group_name                   => l_UpdEmpAsg_out.concatenated_segments
2584   ,p_comment_id                   => l_UpdEmpAsg_out.comment_id
2585   ,p_effective_start_date         => l_UpdEmpAsg_out.effective_start_date
2586   ,p_effective_end_date           => l_UpdEmpAsg_out.effective_end_date
2587   ,p_people_group_id              => g_asg_rec.people_group_id
2588   ,p_soft_coding_keyflex_id       => g_asg_rec.soft_coding_keyflex_id
2589   ,p_return_status                => l_return_status
2590   );
2591 
2592 
2593   /* if l_expected_system_status = 'TERM_APL' then
2594        hr_assignment_api.terminate_apl_asg
2595               (p_validate                   => false
2596               ,p_effective_date             => p_effective_date
2597               ,p_assignment_id              => g_asg_rec.assignment_id
2598               ,p_assignment_status_type_id  => l_asg_rec.assignment_status_type_id
2599               ,p_object_version_number      => l_cur_asg_rec.object_version_number
2600               ,p_effective_start_date       => l_UpdEmpAsg_out.effective_start_date
2601               ,p_effective_end_date         => l_UpdEmpAsg_out.effective_end_date
2602               );
2603    else
2604        hr_utility.set_location('Inside Update Assignment :'||l_asg_rec.assignment_status_type_id, 8);
2605        hr_assignment_internal.update_status_type_apl_asg
2606               (p_effective_date             => p_effective_date
2607               ,p_datetrack_update_mode      => l_datetrack_update_mode
2608               ,p_assignment_id              => g_asg_rec.assignment_id
2609               ,p_object_version_number      => l_cur_asg_rec.object_version_number
2610               ,p_expected_system_status     => l_expected_system_status
2611               ,p_assignment_status_type_id  => l_asg_rec.assignment_status_type_id
2612               ,p_change_reason              => l_asg_rec.change_reason
2613               ,p_effective_start_date       => l_UpdEmpAsg_out.effective_start_date
2614               ,p_effective_end_date         => l_UpdEmpAsg_out.effective_end_date
2615               );
2616    end if;
2617 
2618   Dt_Api.Find_DT_Upd_Modes
2619   (p_effective_date        =>  p_effective_date
2620   ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
2621   ,p_base_key_column       => 'ASSIGNMENT_ID'
2622   ,p_base_key_value        => g_asg_rec.assignment_id
2623   ,p_correction            => l_dt_correction
2624   ,p_update                => l_dt_update
2625   ,p_update_override       => l_dt_upd_override
2626   ,p_update_change_insert  => l_upd_chg_ins
2627    );
2628 
2629   if l_dt_update then
2630      l_datetrack_update_mode := 'UPDATE';
2631   elsif l_dt_upd_override or
2632         l_upd_chg_ins then
2633              --Else USE Correction Mode
2634         l_datetrack_update_mode := 'CORRECTION';
2635      hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 50);
2636   else
2637      l_datetrack_update_mode := 'CORRECTION';
2638   end if;
2639 
2640 
2641 --l_asg_rec.application_id := 1103;
2642  --l_asg_rec.application_id := l_cur_asg_rec.application_id; -- Changed By Dbansal
2643 
2644   --$ replace l_asg_rec with l_cur_asg_rec
2645   HR_Assignment_API.Update_APL_Asg
2646   (p_validate                     => false
2647   ,p_effective_date               => p_effective_date
2648   ,p_datetrack_update_mode        => l_datetrack_update_mode
2649   ,p_assignment_id                => g_asg_rec.assignment_id
2650   ,p_recruiter_id                 => l_cur_asg_rec.recruiter_id
2651   ,p_recruitment_activity_id      => l_cur_asg_rec.recruitment_activity_id
2652   ,p_person_referred_by_id        => l_cur_asg_rec.person_referred_by_id
2653   ,p_vacancy_id                   => l_cur_asg_rec.vacancy_id
2654   ,p_application_id               => l_cur_asg_rec.application_id
2655   ,p_grade_id                     => l_asg_rec.grade_id
2656   ,p_position_id                  => l_asg_rec.position_id
2657   ,p_job_id                       => l_asg_rec.job_id
2658   ,p_payroll_id                   => l_asg_rec.payroll_id
2659   ,p_location_id                  => l_asg_rec.location_id
2660   ,p_organization_id              => l_asg_rec.organization_id
2661   ,p_pay_basis_id                 => l_asg_rec.pay_basis_id
2662   ,p_assignment_status_type_id    => l_asg_rec.assignment_status_type_id
2663   ,p_supervisor_id                => l_asg_rec.supervisor_id
2664   ,p_special_ceiling_step_id      => l_asg_rec.special_ceiling_step_id
2665   ,p_source_organization_id       => l_asg_rec.source_organization_id
2666   ,p_employment_category          => l_asg_rec.employment_category
2667   ,p_frequency                    => l_asg_rec.frequency
2668   ,p_normal_hours                 => l_asg_rec.normal_hours
2669   ,p_time_normal_finish           => l_asg_rec.time_normal_finish
2670   ,p_time_normal_start            => l_asg_rec.time_normal_start
2671   ,p_probation_period             => l_asg_rec.probation_period
2672   ,p_probation_unit               => l_asg_rec.probation_unit
2673   ,p_perf_review_period           => l_asg_rec.perf_review_period
2674   ,p_perf_review_period_frequency => l_asg_rec.perf_review_period_frequency
2675   ,p_sal_review_period            => l_asg_rec.sal_review_period
2676   ,p_sal_review_period_frequency  => l_asg_rec.sal_review_period_frequency
2677   ,p_change_reason                => l_asg_rec.change_reason
2678   ,p_notice_period                => l_asg_rec.notice_period
2679   ,p_notice_period_uom            => l_asg_rec.notice_period_uom
2680   ,p_employee_category            => l_asg_rec.employee_category
2681   ,p_work_at_home                 => l_asg_rec.work_at_home
2682   --$
2683   ,p_comments                     => g_asg_comments
2684   ,p_date_probation_end           => l_asg_rec.date_probation_end
2685   ,p_default_code_comb_id         => l_asg_rec.default_code_comb_id
2686   ,p_internal_address_line        => l_asg_rec.internal_address_line
2687   ,p_manager_flag                 => l_asg_rec.manager_flag
2688   ,p_set_of_books_id              => l_asg_rec.set_of_books_id
2689   ,p_source_type                  => l_asg_rec.source_type
2690   ,p_bargaining_unit_code         => l_asg_rec.bargaining_unit_code
2691   -- Asg DF
2692   ,p_ass_attribute_category       => l_asg_rec.ass_attribute_category
2693   ,p_ass_attribute1               => l_asg_rec.ass_attribute1
2694   ,p_ass_attribute2               => l_asg_rec.ass_attribute2
2695   ,p_ass_attribute3               => l_asg_rec.ass_attribute3
2696   ,p_ass_attribute4               => l_asg_rec.ass_attribute4
2697   ,p_ass_attribute5               => l_asg_rec.ass_attribute5
2698   ,p_ass_attribute6               => l_asg_rec.ass_attribute6
2699   ,p_ass_attribute7               => l_asg_rec.ass_attribute7
2700   ,p_ass_attribute8               => l_asg_rec.ass_attribute8
2701   ,p_ass_attribute9               => l_asg_rec.ass_attribute9
2702   ,p_ass_attribute10              => l_asg_rec.ass_attribute10
2703   ,p_ass_attribute11              => l_asg_rec.ass_attribute11
2704   ,p_ass_attribute12              => l_asg_rec.ass_attribute12
2705   ,p_ass_attribute13              => l_asg_rec.ass_attribute13
2706   ,p_ass_attribute14              => l_asg_rec.ass_attribute14
2707   ,p_ass_attribute15              => l_asg_rec.ass_attribute15
2708   ,p_ass_attribute16              => l_asg_rec.ass_attribute16
2709   ,p_ass_attribute17              => l_asg_rec.ass_attribute17
2710   ,p_ass_attribute18              => l_asg_rec.ass_attribute18
2711   ,p_ass_attribute19              => l_asg_rec.ass_attribute19
2712   ,p_ass_attribute20              => l_asg_rec.ass_attribute20
2713   ,p_ass_attribute21              => l_asg_rec.ass_attribute21
2714   ,p_ass_attribute22              => l_asg_rec.ass_attribute22
2715   ,p_ass_attribute23              => l_asg_rec.ass_attribute23
2716   ,p_ass_attribute24              => l_asg_rec.ass_attribute24
2717   ,p_ass_attribute25              => l_asg_rec.ass_attribute25
2718   ,p_ass_attribute26              => l_asg_rec.ass_attribute26
2719   ,p_ass_attribute27              => l_asg_rec.ass_attribute27
2720   ,p_ass_attribute28              => l_asg_rec.ass_attribute28
2721   ,p_ass_attribute29              => l_asg_rec.ass_attribute29
2722   ,p_ass_attribute30              => l_asg_rec.ass_attribute30
2723   ,p_title                        => l_asg_rec.title
2724   -- Asg Soft Coding KFF
2725   ,p_scl_segment1                 => l_scl_rec.segment1
2726   ,p_scl_segment2                 => l_scl_rec.segment2
2727   ,p_scl_segment3                 => l_scl_rec.segment3
2728   ,p_scl_segment4                 => l_scl_rec.segment4
2729   ,p_scl_segment5                 => l_scl_rec.segment5
2730   ,p_scl_segment6                 => l_scl_rec.segment6
2731   ,p_scl_segment7                 => l_scl_rec.segment7
2732   ,p_scl_segment8                 => l_scl_rec.segment8
2733   ,p_scl_segment9                 => l_scl_rec.segment9
2734   ,p_scl_segment10                => l_scl_rec.segment10
2735   ,p_scl_segment11                => l_scl_rec.segment11
2736   ,p_scl_segment12                => l_scl_rec.segment12
2737   ,p_scl_segment13                => l_scl_rec.segment13
2738   ,p_scl_segment14                => l_scl_rec.segment14
2739   ,p_scl_segment15                => l_scl_rec.segment15
2740   ,p_scl_segment16                => l_scl_rec.segment16
2741   ,p_scl_segment17                => l_scl_rec.segment17
2742   ,p_scl_segment18                => l_scl_rec.segment18
2743   ,p_scl_segment19                => l_scl_rec.segment19
2744   ,p_scl_segment20                => l_scl_rec.segment20
2745   ,p_scl_segment21                => l_scl_rec.segment21
2746   ,p_scl_segment22                => l_scl_rec.segment22
2747   ,p_scl_segment23                => l_scl_rec.segment23
2748   ,p_scl_segment24                => l_scl_rec.segment24
2749   ,p_scl_segment25                => l_scl_rec.segment25
2750   ,p_scl_segment26                => l_scl_rec.segment26
2751   ,p_scl_segment27                => l_scl_rec.segment27
2752   ,p_scl_segment28                => l_scl_rec.segment28
2753   ,p_scl_segment29                => l_scl_rec.segment29
2754   ,p_scl_segment30                => l_scl_rec.segment30
2755   --,p_scl_concat_segments          => g_scl_rec.
2756   -- People Group KFF
2757   ,p_pgp_segment1                 => l_grp_rec.segment1
2758   ,p_pgp_segment2                 => l_grp_rec.segment2
2759   ,p_pgp_segment3                 => l_grp_rec.segment3
2760   ,p_pgp_segment4                 => l_grp_rec.segment4
2761   ,p_pgp_segment5                 => l_grp_rec.segment5
2762   ,p_pgp_segment6                 => l_grp_rec.segment6
2763   ,p_pgp_segment7                 => l_grp_rec.segment7
2764   ,p_pgp_segment8                 => l_grp_rec.segment8
2765   ,p_pgp_segment9                 => l_grp_rec.segment9
2766   ,p_pgp_segment10                => l_grp_rec.segment10
2767   ,p_pgp_segment11                => l_grp_rec.segment11
2768   ,p_pgp_segment12                => l_grp_rec.segment12
2769   ,p_pgp_segment13                => l_grp_rec.segment13
2770   ,p_pgp_segment14                => l_grp_rec.segment14
2771   ,p_pgp_segment15                => l_grp_rec.segment15
2772   ,p_pgp_segment16                => l_grp_rec.segment16
2773   ,p_pgp_segment17                => l_grp_rec.segment17
2774   ,p_pgp_segment18                => l_grp_rec.segment18
2775   ,p_pgp_segment19                => l_grp_rec.segment19
2776   ,p_pgp_segment20                => l_grp_rec.segment20
2777   ,p_pgp_segment21                => l_grp_rec.segment21
2778   ,p_pgp_segment22                => l_grp_rec.segment22
2779   ,p_pgp_segment23                => l_grp_rec.segment23
2780   ,p_pgp_segment24                => l_grp_rec.segment24
2781   ,p_pgp_segment25                => l_grp_rec.segment25
2782   ,p_pgp_segment26                => l_grp_rec.segment26
2783   ,p_pgp_segment27                => l_grp_rec.segment27
2784   ,p_pgp_segment28                => l_grp_rec.segment28
2785   ,p_pgp_segment29                => l_grp_rec.segment29
2786   ,p_pgp_segment30                => l_grp_rec.segment30
2787   ,p_concat_segments                => l_grp_rec.group_name
2788 
2789   ,p_contract_id                  => l_asg_rec.contract_id
2790   ,p_establishment_id             => l_asg_rec.establishment_id
2791   ,p_job_post_source_name         => l_asg_rec.job_post_source_name
2792   ,p_posting_content_id           => l_asg_rec.posting_content_id
2793   ,p_applicant_rank               => l_asg_rec.applicant_rank
2794   ,p_grade_ladder_pgm_id          => l_asg_rec.grade_ladder_pgm_id
2795   ,p_supervisor_assignment_id     => l_asg_rec.supervisor_assignment_id
2796   -- In/Out
2797   ,p_cagr_grade_def_id            => g_asg_rec.cagr_grade_def_id
2798   ,p_people_group_id              => g_asg_rec.people_group_id
2799   ,p_soft_coding_keyflex_id       => g_asg_rec.soft_coding_keyflex_id
2800   ,p_object_version_number        => l_cur_asg_rec.object_version_number
2801   -- Out
2802   ,p_concatenated_segments        => l_UpdEmpAsg_out.concatenated_segments
2803   ,p_cagr_concatenated_segments   => l_UpdEmpAsg_out.cagr_concatenated_segments
2804   ,p_group_name                   => l_UpdEmpAsg_out.concatenated_segments
2805   ,p_comment_id                   => l_UpdEmpAsg_out.comment_id
2806   ,p_effective_start_date         => l_UpdEmpAsg_out.effective_start_date
2807   ,p_effective_end_date           => l_UpdEmpAsg_out.effective_end_date
2808   );  */
2809 
2810   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
2811 
2812 exception
2813   when e_empasg_notfound  then
2814    l_error_msg :=
2815               'Applicant Assignment could not be found as of the effective date';
2816    hr_utility.set_message(8303, 'PQP_230494_RIW_ASSGN_NOT_FOUND');
2817    hr_utility.set_message_token('TOKEN','Applicant' );
2818    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
2819    hr_utility.raise_error;
2820 
2821   when Others then
2822    --l_error_msg := SQLERRM;
2823    hr_utility.set_location('SQLCODE :' || SQLCODE,100);
2824    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
2825    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
2826    hr_utility.set_location('Leaving: ' || l_proc_name, 100);
2827    --hr_utility.trace('Error Text = ' ||substr(l_error_msg,1,150));
2828 
2829    hr_utility.raise_error;
2830 
2831 end Upd_Applicant_Asg;
2832 -- =============================================================================
2833 -- ~ Upd_Contingent_Asg :
2834 -- =============================================================================
2835 procedure Upd_Contingent_Asg
2836          (p_effective_date in date
2837          ,p_asg_crit_out   in out NOCOPY t_AsgUpdCrit_Api
2838          --,p_UpdEmpAsg_out  IN OUT NOCOPY t_Upd_Emp_Asg_Api
2839           ) as
2840 
2841   -- Cursor to get Assignment details
2842   cursor csr_asg (c_effective_date in date
2843                  ,c_assignment_id  in number
2844                  ,c_business_group_id in number)is
2845   select *
2846     from per_all_assignments_f paf
2847    where paf.assignment_id = c_assignment_id
2848      and paf.business_group_id = c_business_group_id
2849      and c_effective_date between paf.effective_start_date
2850                               and paf.effective_end_date;
2851 
2852   l_cur_asg_rec            csr_asg%rowtype;
2853 
2854   -- Cursor to get people group flexfield details
2855   cursor csr_ppg (c_people_grp_id in number) is
2856   select *
2857     from pay_people_groups
2858    where people_group_id = c_people_grp_id;
2859 
2860   l_cur_ppl_grp_rec        pay_people_groups%rowtype;
2861 
2862   -- Cursor to get Soft coding flexfield details
2863   cursor csr_scl (c_scl_kff_id in number) is
2864   select *
2865     from hr_soft_coding_keyflex
2866    where soft_coding_keyflex_id = c_scl_kff_id;
2867 
2868   l_cur_scl_rec        hr_soft_coding_keyflex%rowtype;
2869 
2870   l_proc_name  constant    varchar2(150):= g_pkg ||'Upd_Contingent_Asg';
2871   l_error_msg              varchar2(2000);
2872   l_datetrack_update_mode  varchar2(50);
2873   l_dt_correction          boolean;
2874   l_dt_update              boolean;
2875   l_dt_upd_override        boolean;
2876   l_upd_chg_ins            boolean;
2877   e_empasg_notfound        exception;
2878   l_UpdEmpAsg_out          t_Upd_Emp_Asg_Api;
2879   l_asg_rec                per_all_assignments_f%rowtype;
2880   l_grp_rec                pay_people_groups%rowtype;
2881   l_scl_rec                hr_soft_coding_keyflex%rowtype;
2882 
2883 begin
2884   hr_utility.set_location('Entering: ' || l_proc_name, 10);
2885 
2886   l_asg_rec := Get_AsgRecord_Values(g_interface_code);
2887   l_grp_rec := Get_GrpRecord_Values(g_interface_code);
2888   l_scl_rec := Get_ScflxRecord_Values(g_interface_code);
2889 
2890   open  csr_asg (c_effective_date    => p_effective_date
2891                 ,c_assignment_id     => g_asg_rec.assignment_id
2892                 ,c_business_group_id => g_asg_rec.business_group_id
2893                  );
2894   fetch csr_asg into l_cur_asg_rec;
2895   if csr_asg%notfound then
2896      close csr_asg;
2897      raise e_empasg_notfound;
2898   end if;
2899   close csr_asg;
2900   hr_utility.set_location(' l_cur_asg_rec: ' || p_effective_date, 20);
2901   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.assignment_id, 20);
2902   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.business_group_id, 20);
2903   --
2904   -- Check if the People Group Id is passed
2905   --
2906   open  csr_ppg(c_people_grp_id => g_asg_rec.people_group_id);
2907   fetch csr_ppg into l_cur_ppl_grp_rec;
2908   --$ Do not assign people group id from existing record but from the combination
2909    -- of the segments obtained from user
2910    if csr_ppg%found then
2911      p_asg_crit_out.people_group_id := g_asg_rec.people_group_id;
2912      l_asg_rec.people_group_id := g_asg_rec.people_group_id;
2913 
2914   /*if csr_ppg%notfound then
2915      g_asg_rec.people_group_id
2916        := l_cur_asg_rec.people_group_id;
2917      l_asg_rec.people_group_id
2918        := l_cur_asg_rec.people_group_id;*/
2919   end if;
2920 
2921   close csr_ppg;
2922   hr_utility.set_location(' people_group_id: ' || g_asg_rec.people_group_id, 30);
2923   --
2924   -- check if the Soft-Coding KFF id is passed
2925   --
2926   open  csr_scl(c_scl_kff_id => g_asg_rec.soft_coding_keyflex_id);
2927   fetch csr_scl into l_cur_scl_rec;
2928   --$ Do not assign soft keyflex id from existing record but from the combination
2929    -- of the segments obtained from user
2930  if csr_scl%found then
2931      p_asg_crit_out.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
2932      l_asg_rec.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
2933  /*  if csr_scl%notfound then
2934      g_asg_rec.soft_coding_keyflex_id
2935        := l_cur_asg_rec.soft_coding_keyflex_id;
2936      l_asg_rec.soft_coding_keyflex_id
2937        := l_cur_asg_rec.soft_coding_keyflex_id; */
2938 
2939   end if;
2940   close csr_scl;
2941   hr_utility.set_location(' soft_coding_keyflex_id: ' ||
2942                             g_asg_rec.soft_coding_keyflex_id, 40);
2943   --
2944   -- Get the datetrack mode based on the effective date passed
2945   --
2946   Dt_Api.Find_DT_Upd_Modes
2947   (p_effective_date        =>  p_effective_date
2948   ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
2949   ,p_base_key_column       => 'ASSIGNMENT_ID'
2950   ,p_base_key_value        => g_asg_rec.assignment_id
2951   ,p_correction            => l_dt_correction
2952   ,p_update                => l_dt_update
2953   ,p_update_override       => l_dt_upd_override
2954   ,p_update_change_insert  => l_upd_chg_ins
2955    );
2956 
2957   if l_dt_update then
2958      l_datetrack_update_mode := 'UPDATE';
2959   elsif l_dt_upd_override or
2960         l_upd_chg_ins then
2961              --Else USE Correction Mode
2962         l_datetrack_update_mode := 'CORRECTION';
2963      hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 50);
2964   else
2965      l_datetrack_update_mode := 'CORRECTION';
2966   end if;
2967   hr_utility.set_location(' l_datetrack_update_mode: ' ||
2968                             l_datetrack_update_mode, 60);
2969 
2970   g_asg_rec.cagr_grade_def_id := nvl(g_asg_rec.cagr_grade_def_id,
2971                                      l_cur_asg_rec.cagr_grade_def_id);
2972   l_asg_rec.cagr_grade_def_id := g_asg_rec.cagr_grade_def_id;
2973 
2974 
2975   HR_Assignment_API.Update_CWK_Asg_Criteria
2976   (p_validate                     => false
2977   ,p_effective_date               => p_effective_date
2978   ,p_datetrack_update_mode        => l_datetrack_update_mode
2979   ,p_assignment_id                => g_asg_rec.assignment_id
2980   ,p_called_from_mass_update      => false
2981   ,p_grade_id                     => l_asg_rec.grade_id
2982   ,p_position_id                  => l_asg_rec.position_id
2983   ,p_job_id                       => l_asg_rec.job_id
2984   ,p_location_id                  => l_asg_rec.location_id
2985   ,p_organization_id              => l_asg_rec.organization_id
2986   ,p_pay_basis_id                 => l_asg_rec.pay_basis_id
2987   -- People Group Segments
2988   ,p_segment1                     => l_grp_rec.segment1
2989   ,p_segment2                     => l_grp_rec.segment2
2990   ,p_segment3                     => l_grp_rec.segment3
2991   ,p_segment4                     => l_grp_rec.segment4
2992   ,p_segment5                     => l_grp_rec.segment5
2993   ,p_segment6                     => l_grp_rec.segment6
2994   ,p_segment7                     => l_grp_rec.segment7
2995   ,p_segment8                     => l_grp_rec.segment8
2996   ,p_segment9                     => l_grp_rec.segment9
2997   ,p_segment10                    => l_grp_rec.segment10
2998   ,p_segment11                    => l_grp_rec.segment11
2999   ,p_segment12                    => l_grp_rec.segment12
3000   ,p_segment13                    => l_grp_rec.segment13
3001   ,p_segment14                    => l_grp_rec.segment14
3002   ,p_segment15                    => l_grp_rec.segment15
3003   ,p_segment16                    => l_grp_rec.segment16
3004   ,p_segment17                    => l_grp_rec.segment17
3005   ,p_segment18                    => l_grp_rec.segment18
3006   ,p_segment19                    => l_grp_rec.segment19
3007   ,p_segment20                    => l_grp_rec.segment20
3008   ,p_segment21                    => l_grp_rec.segment21
3009   ,p_segment22                    => l_grp_rec.segment22
3010   ,p_segment23                    => l_grp_rec.segment23
3011   ,p_segment24                    => l_grp_rec.segment24
3012   ,p_segment25                    => l_grp_rec.segment25
3013   ,p_segment26                    => l_grp_rec.segment26
3014   ,p_segment27                    => l_grp_rec.segment27
3015   ,p_segment28                    => l_grp_rec.segment28
3016   ,p_segment29                    => l_grp_rec.segment29
3017   ,p_segment30                    => l_grp_rec.segment30
3018   ,p_concat_segments              => l_grp_rec.group_name
3019   -- In/Out
3020   ,p_object_version_number        => l_cur_asg_rec.object_version_number
3021   -- Out
3022   ,p_people_group_name            => p_asg_crit_out.group_name
3023   ,p_people_group_id              => p_asg_crit_out.people_group_id
3024   ,p_effective_start_date         => p_asg_crit_out.asg_effective_start_date
3025   ,p_effective_end_date           => p_asg_crit_out.asg_effective_end_date
3026   ,p_org_now_no_manager_warning   => p_asg_crit_out.org_now_no_manager_warning
3027   ,p_other_manager_warning        => p_asg_crit_out.other_manager_warning
3028   ,p_spp_delete_warning           => p_asg_crit_out.spp_delete_warning
3029   ,p_entries_changed_warning      => p_asg_crit_out.entries_changed_warning
3030   ,p_tax_district_changed_warning => p_asg_crit_out.tax_district_changed_warning
3031    );
3032 
3033 
3034   if g_debug then
3035      hr_utility.set_location(' people_group_id: ' ||
3036                                p_asg_crit_out.people_group_id, 70);
3037      hr_utility.set_location(' soft_coding_keyflex_id: ' ||
3038                                p_asg_crit_out.soft_coding_keyflex_id, 70);
3039      hr_utility.set_location(' group_name: ' ||
3040                                p_asg_crit_out.group_name, 70);
3041      hr_utility.set_location(' asg_effective_start_date: ' ||
3042                                p_asg_crit_out.asg_effective_start_date, 70);
3043   end if;
3044   l_datetrack_update_mode := 'CORRECTION';
3045 
3046 
3047   --hr_utility.trace(' Value of l_asg_rec.assignment_id = '||l_asg_rec.assignment_id);
3048   --hr_utility.trace(' Value of g_asg_rec.assignment_id = '||g_asg_rec.assignment_id);
3049 
3050 
3051    HR_Assignment_API.Update_CWK_Asg
3052   (p_validate                     => false
3053   ,p_effective_date               => p_effective_date
3054   ,p_datetrack_update_mode        => l_datetrack_update_mode
3055   ,p_assignment_id                => g_asg_rec.assignment_id -- l_asg_rec.assignment_id => Changed by pkagrawa
3056   ,p_comments                     => g_asg_comments  --$ null
3057   ,p_project_title                  => null
3058   ,p_concat_segments              => null
3059   ,p_establishment_id             => l_asg_rec.establishment_id
3060   ,p_supervisor_assignment_id     => l_asg_rec.supervisor_assignment_id
3061   ,p_title                        => l_asg_rec.title
3062   ,p_assignment_category          => l_asg_rec.employment_category
3063   ,p_assignment_number            => l_asg_rec.assignment_number
3064   ,p_change_reason                => l_asg_rec.change_reason
3065   ,p_default_code_comb_id         => l_asg_rec.default_code_comb_id
3066   ,p_frequency                    => l_asg_rec.frequency
3067   ,p_internal_address_line        => l_asg_rec.internal_address_line
3068   ,p_labour_union_member_flag     => l_asg_rec.labour_union_member_flag
3069   ,p_manager_flag                 => l_asg_rec.manager_flag
3070   ,p_normal_hours                 => l_asg_rec.normal_hours
3071   ,p_set_of_books_id              => l_asg_rec.set_of_books_id
3072   ,p_source_type                  => l_asg_rec.source_type
3073   ,p_supervisor_id                => l_asg_rec.supervisor_id
3074   ,p_time_normal_finish           => l_asg_rec.time_normal_finish
3075   ,p_time_normal_start            => l_asg_rec.time_normal_start
3076   ,p_vendor_assignment_number     => l_asg_rec.vendor_assignment_number
3077   ,p_vendor_employee_number       => l_asg_rec.vendor_employee_number
3078   ,p_vendor_id                    => l_asg_rec.vendor_id
3079   ,p_vendor_site_id               => l_asg_rec.vendor_site_id
3080   ,p_po_header_id                 => l_asg_rec.po_header_id
3081   ,p_po_line_id                   => l_asg_rec.po_line_id
3082   ,p_projected_assignment_end     => l_asg_rec.projected_assignment_end
3083   ,p_assignment_status_type_id    => l_asg_rec.assignment_status_type_id
3084   -- Asg DF
3085   ,p_attribute_category           => l_asg_rec.ass_attribute_category
3086   ,p_attribute1                   => l_asg_rec.ass_attribute1
3087   ,p_attribute2                   => l_asg_rec.ass_attribute2
3088   ,p_attribute3                   => l_asg_rec.ass_attribute3
3089   ,p_attribute4                   => l_asg_rec.ass_attribute4
3090   ,p_attribute5                   => l_asg_rec.ass_attribute5
3091   ,p_attribute6                   => l_asg_rec.ass_attribute6
3092   ,p_attribute7                   => l_asg_rec.ass_attribute7
3093   ,p_attribute8                   => l_asg_rec.ass_attribute8
3094   ,p_attribute9                   => l_asg_rec.ass_attribute9
3095   ,p_attribute10                  => l_asg_rec.ass_attribute10
3096   ,p_attribute11                  => l_asg_rec.ass_attribute11
3097   ,p_attribute12                  => l_asg_rec.ass_attribute12
3098   ,p_attribute13                  => l_asg_rec.ass_attribute13
3099   ,p_attribute14                  => l_asg_rec.ass_attribute14
3100   ,p_attribute15                  => l_asg_rec.ass_attribute15
3101   ,p_attribute16                  => l_asg_rec.ass_attribute16
3102   ,p_attribute17                  => l_asg_rec.ass_attribute17
3103   ,p_attribute18                  => l_asg_rec.ass_attribute18
3104   ,p_attribute19                  => l_asg_rec.ass_attribute19
3105   ,p_attribute20                  => l_asg_rec.ass_attribute20
3106   ,p_attribute21                  => l_asg_rec.ass_attribute21
3107   ,p_attribute22                  => l_asg_rec.ass_attribute22
3108   ,p_attribute23                  => l_asg_rec.ass_attribute23
3109   ,p_attribute24                  => l_asg_rec.ass_attribute24
3110   ,p_attribute25                  => l_asg_rec.ass_attribute25
3111   ,p_attribute26                  => l_asg_rec.ass_attribute26
3112   ,p_attribute27                  => l_asg_rec.ass_attribute27
3113   ,p_attribute28                  => l_asg_rec.ass_attribute28
3114   ,p_attribute29                  => l_asg_rec.ass_attribute29
3115   ,p_attribute30                  => l_asg_rec.ass_attribute30
3116   -- Soft Coding KFF
3117   ,p_scl_segment1                 => l_scl_rec.segment1
3118   ,p_scl_segment2                 => l_scl_rec.segment2
3119   ,p_scl_segment3                 => l_scl_rec.segment3
3120   ,p_scl_segment4                 => l_scl_rec.segment4
3121   ,p_scl_segment5                 => l_scl_rec.segment5
3122   ,p_scl_segment6                 => l_scl_rec.segment6
3123   ,p_scl_segment7                 => l_scl_rec.segment7
3124   ,p_scl_segment8                 => l_scl_rec.segment8
3125   ,p_scl_segment9                 => l_scl_rec.segment9
3126   ,p_scl_segment10                => l_scl_rec.segment10
3127   ,p_scl_segment11                => l_scl_rec.segment11
3128   ,p_scl_segment12                => l_scl_rec.segment12
3129   ,p_scl_segment13                => l_scl_rec.segment13
3130   ,p_scl_segment14                => l_scl_rec.segment14
3131   ,p_scl_segment15                => l_scl_rec.segment15
3132   ,p_scl_segment16                => l_scl_rec.segment16
3133   ,p_scl_segment17                => l_scl_rec.segment17
3134   ,p_scl_segment18                => l_scl_rec.segment18
3135   ,p_scl_segment19                => l_scl_rec.segment19
3136   ,p_scl_segment20                => l_scl_rec.segment20
3137   ,p_scl_segment21                => l_scl_rec.segment21
3138   ,p_scl_segment22                => l_scl_rec.segment22
3139   ,p_scl_segment23                => l_scl_rec.segment23
3140   ,p_scl_segment24                => l_scl_rec.segment24
3141   ,p_scl_segment25                => l_scl_rec.segment25
3142   ,p_scl_segment26                => l_scl_rec.segment26
3143   ,p_scl_segment27                => l_scl_rec.segment27
3144   ,p_scl_segment28                => l_scl_rec.segment28
3145   ,p_scl_segment29                => l_scl_rec.segment29
3146   ,p_scl_segment30                => l_scl_rec.segment30
3147   -- In/Out
3148   ,p_object_version_number        => l_cur_asg_rec.object_version_number
3149   -- Out
3150   ,p_org_now_no_manager_warning   => p_asg_crit_out.org_now_no_manager_warning
3151   ,p_effective_start_date         => l_UpdEmpAsg_out.effective_start_date
3152   ,p_effective_end_date           => l_UpdEmpAsg_out.effective_end_date
3153   ,p_comment_id                   => l_UpdEmpAsg_out.comment_id
3154   ,p_no_managers_warning          => l_UpdEmpAsg_out.no_managers_warning
3155   ,p_other_manager_warning        => l_UpdEmpAsg_out.other_manager_warning
3156   ,p_soft_coding_keyflex_id       => l_asg_rec.soft_coding_keyflex_id
3157   ,p_concatenated_segments        => l_UpdEmpAsg_out.concatenated_segments
3158   ,p_hourly_salaried_warning      => l_UpdEmpAsg_out.hourly_salaried_warning
3159    );
3160 
3161   if g_debug then
3162      hr_utility.set_location(' Asg OVN: ' ||
3163                                l_cur_asg_rec.object_version_number, 75);
3164      hr_utility.set_location(' soft_coding_keyflex_id: ' ||
3165                                p_asg_crit_out.soft_coding_keyflex_id, 75);
3166      hr_utility.set_location(' group_name: ' ||
3167                                l_UpdEmpAsg_out.concatenated_segments, 75);
3168      hr_utility.set_location(' asg_effective_start_date: ' ||
3169                                l_UpdEmpAsg_out.effective_start_date, 75);
3170   end if;
3171 
3172   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
3173 
3174 exception
3175   when e_empasg_notfound  then
3176    l_error_msg :=
3177               'Contingent Assignment could not be found as of the effective date';
3178    hr_utility.set_message(8303, 'PQP_230494_RIW_ASSGN_NOT_FOUND');
3179    hr_utility.set_message_token('TOKEN','Contingent' );
3180    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
3181    hr_utility.raise_error;
3182 
3183   when Others then
3184    --l_error_msg := SQLERRM;
3185 
3186    --hr_utility.trace(' Upd_Contingent_Asg Error = '||sqlerrm);
3187 
3188    hr_utility.set_location('SQLCODE :' || SQLCODE,100);
3189    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
3190    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
3191    hr_utility.set_location('Leaving: ' || l_proc_name, 100);
3192    hr_utility.raise_error;
3193 
3194 end Upd_Contingent_Asg;
3195 
3196 -- =============================================================================
3197 -- ~ Update_Employee_Asg :
3198 -- =============================================================================
3199 procedure Update_Employee_Asg
3200          (p_effective_date in date
3201          ,p_asg_crit_out   in out NOCOPY t_AsgUpdCrit_Api
3202          --,p_UpdEmpAsg_out  IN OUT NOCOPY t_Upd_Emp_Asg_Api
3203           ) as
3204 
3205   -- Cursor to get Assignment details
3206   cursor csr_asg (c_effective_date in date
3207                  ,c_assignment_id  in number
3208                  ,c_business_group_id in number)is
3209   select *
3210     from per_all_assignments_f paf
3211    where paf.assignment_id = c_assignment_id
3212      and paf.business_group_id = c_business_group_id
3213      and c_effective_date between paf.effective_start_date
3214                               and paf.effective_end_date;
3215 
3216   l_cur_asg_rec            csr_asg%rowtype;
3217 
3218   -- Cursor to get people group flexfield details
3219   cursor csr_ppg (c_people_grp_id in number) is
3220   select *
3221     from pay_people_groups
3222    where people_group_id = c_people_grp_id;
3223 
3224   l_cur_ppl_grp_rec        pay_people_groups%rowtype;
3225 
3226   -- Cursor to get Soft coding flexfield details
3227   cursor csr_scl (c_scl_kff_id in number) is
3228   select *
3229     from hr_soft_coding_keyflex
3230    where soft_coding_keyflex_id = c_scl_kff_id;
3231 
3232   l_cur_scl_rec        hr_soft_coding_keyflex%rowtype;
3233 
3234   l_proc_name  constant    varchar2(150):= g_pkg ||'Update_Employee_Asg';
3235   l_error_msg              varchar2(2000);
3236   l_datetrack_update_mode  varchar2(50);
3237   l_dt_correction          boolean;
3238   l_dt_update              boolean;
3239   l_dt_upd_override        boolean;
3240   l_upd_chg_ins            boolean;
3241   e_empasg_notfound        exception;
3242   l_UpdEmpAsg_out          t_Upd_Emp_Asg_Api;
3243   l_asg_rec                per_all_assignments_f%rowtype;
3244   l_grp_rec                pay_people_groups%rowtype;
3245   l_scl_rec                hr_soft_coding_keyflex%rowtype;
3246 begin
3247   hr_utility.set_location('Entering: ' || l_proc_name, 10);
3248 
3249   l_asg_rec := Get_AsgRecord_Values(g_interface_code);
3250   l_grp_rec := Get_GrpRecord_Values(g_interface_code);
3251   l_scl_rec := Get_ScflxRecord_Values(g_interface_code);
3252 
3253   open  csr_asg (c_effective_date    => p_effective_date
3254                 ,c_assignment_id     => g_asg_rec.assignment_id
3255                 ,c_business_group_id => g_asg_rec.business_group_id
3256                  );
3257   fetch csr_asg into l_cur_asg_rec;
3258   if csr_asg%notfound then
3259      close csr_asg;
3260      raise e_empasg_notfound;
3261   end if;
3262   close csr_asg;
3263   hr_utility.set_location(' l_cur_asg_rec: ' || p_effective_date, 20);
3264   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.assignment_id, 20);
3265   hr_utility.set_location(' l_cur_asg_rec: ' || g_asg_rec.business_group_id, 20);
3266 
3267   open  csr_ppg(c_people_grp_id => g_asg_rec.people_group_id);
3268   fetch csr_ppg into l_cur_ppl_grp_rec;
3269   if csr_ppg%found then
3270      p_asg_crit_out.people_group_id := g_asg_rec.people_group_id;
3271      l_asg_rec.people_group_id := g_asg_rec.people_group_id;
3272   end if;
3273   close csr_ppg;
3274   hr_utility.set_location(' people_group_id: ' || g_asg_rec.people_group_id, 30);
3275 
3276   open  csr_scl(c_scl_kff_id => g_asg_rec.soft_coding_keyflex_id);
3277   fetch csr_scl into l_cur_scl_rec;
3278   if csr_scl%found then
3279      p_asg_crit_out.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
3280      l_asg_rec.soft_coding_keyflex_id := g_asg_rec.soft_coding_keyflex_id;
3281   end if;
3282   close csr_scl;
3283   hr_utility.set_location(' soft_coding_keyflex_id: ' ||
3284                             g_asg_rec.soft_coding_keyflex_id, 40);
3285 
3286   Dt_Api.Find_DT_Upd_Modes
3287   (p_effective_date        =>  p_effective_date
3288   ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
3289   ,p_base_key_column       => 'ASSIGNMENT_ID'
3290   ,p_base_key_value        => g_asg_rec.assignment_id
3291   ,p_correction            => l_dt_correction
3292   ,p_update                => l_dt_update
3293   ,p_update_override       => l_dt_upd_override
3294   ,p_update_change_insert  => l_upd_chg_ins
3295    );
3296 
3297   if l_dt_update then
3298      l_datetrack_update_mode := 'UPDATE';
3299   elsif l_dt_upd_override or
3300         l_upd_chg_ins then
3301      l_datetrack_update_mode := 'CORRECTION' ; --$ 'UPDATE' not possible
3302      hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 50);
3303   else
3304      l_datetrack_update_mode := 'CORRECTION';
3305   end if;
3306   hr_utility.set_location(' l_datetrack_update_mode: ' ||
3307                             l_datetrack_update_mode, 60);
3308 
3309   /*Hr_Assignment_Api.Update_Emp_Asg_Criteria
3310   (p_effective_date               => p_effective_date
3311   ,p_datetrack_update_mode        => l_datetrack_update_mode
3312   ,p_assignment_id                => g_asg_rec.assignment_id
3313   ,p_validate                     => false
3314   ,p_called_from_mass_update      => false
3315   ,p_grade_id                     => l_asg_rec.grade_id
3316   ,p_position_id                  => l_asg_rec.position_id
3317   ,p_job_id                       => l_asg_rec.job_id
3318   ,p_payroll_id                   => l_asg_rec.payroll_id
3319   ,p_location_id                  => l_asg_rec.location_id
3320   ,p_organization_id              => l_asg_rec.organization_id
3321   ,p_pay_basis_id                 => l_asg_rec.pay_basis_id
3322   ,p_employment_category          => l_asg_rec.employment_category
3323 
3324   ,p_segment1                     => l_grp_rec.segment1
3325   ,p_segment2                     => l_grp_rec.segment2
3326   ,p_segment3                     => l_grp_rec.segment3
3327   ,p_segment4                     => l_grp_rec.segment4
3328   ,p_segment5                     => l_grp_rec.segment5
3329   ,p_segment6                     => l_grp_rec.segment6
3330   ,p_segment7                     => l_grp_rec.segment7
3331   ,p_segment8                     => l_grp_rec.segment8
3332   ,p_segment9                     => l_grp_rec.segment9
3333   ,p_segment10                    => l_grp_rec.segment10
3334   ,p_segment11                    => l_grp_rec.segment11
3335   ,p_segment12                    => l_grp_rec.segment12
3336   ,p_segment13                    => l_grp_rec.segment13
3337   ,p_segment14                    => l_grp_rec.segment14
3338   ,p_segment15                    => l_grp_rec.segment15
3339   ,p_segment16                    => l_grp_rec.segment16
3340   ,p_segment17                    => l_grp_rec.segment17
3341   ,p_segment18                    => l_grp_rec.segment18
3342   ,p_segment19                    => l_grp_rec.segment19
3343   ,p_segment20                    => l_grp_rec.segment20
3344   ,p_segment21                    => l_grp_rec.segment21
3345   ,p_segment22                    => l_grp_rec.segment22
3346   ,p_segment23                    => l_grp_rec.segment23
3347   ,p_segment24                    => l_grp_rec.segment24
3348   ,p_segment25                    => l_grp_rec.segment25
3349   ,p_segment26                    => l_grp_rec.segment26
3350   ,p_segment27                    => l_grp_rec.segment27
3351   ,p_segment28                    => l_grp_rec.segment28
3352   ,p_segment29                    => l_grp_rec.segment29
3353   ,p_segment30                    => l_grp_rec.segment30
3354   ,p_concat_segments              => l_grp_rec.group_name
3355 
3356   ,p_scl_segment1                 => l_scl_rec.segment1
3357   ,p_object_version_number        => l_cur_asg_rec.object_version_number
3358   ,p_special_ceiling_step_id      => p_asg_crit_out.special_ceiling_step_id
3359   ,p_people_group_id              => p_asg_crit_out.people_group_id
3360   ,p_soft_coding_keyflex_id       => p_asg_crit_out.soft_coding_keyflex_id
3361   ,p_group_name                   => p_asg_crit_out.group_name
3362   ,p_effective_start_date         => p_asg_crit_out.asg_effective_start_date
3363   ,p_effective_end_date           => p_asg_crit_out.asg_effective_end_date
3364   ,p_org_now_no_manager_warning   => p_asg_crit_out.org_now_no_manager_warning
3365   ,p_other_manager_warning        => p_asg_crit_out.other_manager_warning
3366   ,p_spp_delete_warning           => p_asg_crit_out.spp_delete_warning
3367   ,p_entries_changed_warning      => p_asg_crit_out.entries_changed_warning
3368   ,p_tax_district_changed_warning => p_asg_crit_out.tax_district_changed_warning
3369   ,p_concatenated_segments        => p_asg_crit_out.concatenated_segments
3370   ,p_gsp_post_process_warning     => p_asg_crit_out.gsp_post_process_warning
3371   );
3372 
3373 
3374   if g_debug then
3375      hr_utility.set_location(' people_group_id: ' ||
3376                                p_asg_crit_out.people_group_id, 70);
3377      hr_utility.set_location(' soft_coding_keyflex_id: ' ||
3378                                p_asg_crit_out.soft_coding_keyflex_id, 70);
3379      hr_utility.set_location(' group_name: ' ||
3380                                p_asg_crit_out.group_name, 70);
3381      hr_utility.set_location(' asg_effective_start_date: ' ||
3382                                p_asg_crit_out.asg_effective_start_date, 70);
3383   end if;*/
3384 
3385   --l_datetrack_update_mode := 'CORRECTION';
3386 
3387   g_asg_rec.cagr_grade_def_id := NVL(g_asg_rec.cagr_grade_def_id,
3388                                      l_cur_asg_rec.cagr_grade_def_id);
3389   g_asg_rec.soft_coding_keyflex_id := p_asg_crit_out.soft_coding_keyflex_id;
3390   --
3391   -- Hr_Assignment_Api.Update_Emp_Asg: Use the overloaded update_emp_asg(NEW3)
3392   --
3393  --hr_utility.trace('ass_attribute1 = ' ||l_asg_rec.ass_attribute1);
3394  --hr_utility.trace('ass_attribute2 = ' ||l_asg_rec.ass_attribute2);
3395  --hr_utility.trace('ass_attribute3 = ' ||l_asg_rec.ass_attribute3);
3396  --hr_utility.trace('ass_attribute4 = ' ||l_asg_rec.ass_attribute4);
3397  --hr_utility.trace('ass_attribute5 = ' ||l_asg_rec.ass_attribute5);
3398  --hr_utility.trace('ass_attribute6 = ' ||l_asg_rec.ass_attribute6);
3399  --hr_utility.trace('ass_attribute7 = ' ||l_asg_rec.ass_attribute7);
3400  --hr_utility.trace('ass_attribute8 = ' ||l_asg_rec.ass_attribute8);
3401  --hr_utility.trace('ass_attribute9 = ' ||l_asg_rec.ass_attribute9);
3402  --hr_utility.trace('ass_attribute10 = ' ||l_asg_rec.ass_attribute10);
3403  --hr_utility.trace('ass_attribute11 = ' ||l_asg_rec.ass_attribute11);
3404  --hr_utility.trace('ass_attribute12 = ' ||l_asg_rec.ass_attribute12);
3405  --hr_utility.trace('ass_attribute13 = ' ||l_asg_rec.ass_attribute13);
3406  --hr_utility.trace('ass_attribute14 = ' ||l_asg_rec.ass_attribute14);
3407  --hr_utility.trace('ass_attribute15 = ' ||l_asg_rec.ass_attribute15);
3408 
3409   Hr_Assignment_Api.Update_Emp_Asg
3410   (p_validate                     => false
3411   ,p_effective_date               => p_effective_date
3412   ,p_datetrack_update_mode        => l_datetrack_update_mode
3413   ,p_assignment_id                => l_cur_asg_rec.assignment_id
3414   ,p_object_version_number        => l_cur_asg_rec.object_version_number
3415   ,p_supervisor_id                => l_asg_rec.supervisor_id
3416   ,p_assignment_number            => nvl(l_asg_rec.assignment_number,
3417                                          l_cur_asg_rec.assignment_number)
3418   ,p_change_reason                => l_asg_rec.change_reason
3419   ,p_date_probation_end           => l_asg_rec.date_probation_end
3420   ,p_default_code_comb_id         => l_asg_rec.default_code_comb_id
3421   ,p_frequency                    => l_asg_rec.frequency
3422   ,p_internal_address_line        => l_asg_rec.internal_address_line
3423   ,p_manager_flag                 => l_asg_rec.manager_flag
3424   ,p_normal_hours                 => l_asg_rec.normal_hours
3425   ,p_perf_review_period           => l_asg_rec.perf_review_period
3426   ,p_perf_review_period_frequency => l_asg_rec.perf_review_period_frequency
3427   ,p_probation_period             => l_asg_rec.probation_period
3428   ,p_probation_unit               => l_asg_rec.probation_unit
3429   ,p_sal_review_period            => l_asg_rec.sal_review_period
3430   ,p_sal_review_period_frequency  => l_asg_rec.sal_review_period_frequency
3431   ,p_set_of_books_id              => l_asg_rec.set_of_books_id
3432   ,p_source_type                  => l_asg_rec.source_type
3433   ,p_time_normal_finish           => l_asg_rec.time_normal_finish
3434   ,p_time_normal_start            => l_asg_rec.time_normal_start
3435   ,p_bargaining_unit_code         => l_asg_rec.bargaining_unit_code
3436   ,p_labour_union_member_flag     => l_asg_rec.labour_union_member_flag
3437   ,p_hourly_salaried_code         => l_asg_rec.hourly_salaried_code
3438   ,p_title                        => l_asg_rec.title
3439   --Added by DBANSAL
3440   ,p_employee_category            =>  l_asg_rec.employee_category
3441   ,p_comments                     =>  g_asg_comments
3442   -- Assignment DF
3443   ,p_ass_attribute_category       => l_asg_rec.ass_attribute_category
3444   ,p_ass_attribute1               => l_asg_rec.ass_attribute1
3445   ,p_ass_attribute2               => l_asg_rec.ass_attribute2
3446   ,p_ass_attribute3               => l_asg_rec.ass_attribute3
3447   ,p_ass_attribute4               => l_asg_rec.ass_attribute4
3448   ,p_ass_attribute5               => l_asg_rec.ass_attribute5
3449   ,p_ass_attribute6               => l_asg_rec.ass_attribute6
3450   ,p_ass_attribute7               => l_asg_rec.ass_attribute7
3451   ,p_ass_attribute8               => l_asg_rec.ass_attribute8
3452   ,p_ass_attribute9               => l_asg_rec.ass_attribute9
3453   ,p_ass_attribute10              => l_asg_rec.ass_attribute10
3454   ,p_ass_attribute11              => l_asg_rec.ass_attribute11
3455   ,p_ass_attribute12              => l_asg_rec.ass_attribute12
3456   ,p_ass_attribute13              => l_asg_rec.ass_attribute13
3457   ,p_ass_attribute14              => l_asg_rec.ass_attribute14
3458   ,p_ass_attribute15              => l_asg_rec.ass_attribute15
3459   ,p_ass_attribute16              => l_asg_rec.ass_attribute16
3460   ,p_ass_attribute17              => l_asg_rec.ass_attribute17
3461   ,p_ass_attribute18              => l_asg_rec.ass_attribute18
3462   ,p_ass_attribute19              => l_asg_rec.ass_attribute19
3463   ,p_ass_attribute20              => l_asg_rec.ass_attribute20
3464   ,p_ass_attribute21              => l_asg_rec.ass_attribute21
3465   ,p_ass_attribute22              => l_asg_rec.ass_attribute22
3466   ,p_ass_attribute23              => l_asg_rec.ass_attribute23
3467   ,p_ass_attribute24              => l_asg_rec.ass_attribute24
3468   ,p_ass_attribute25              => l_asg_rec.ass_attribute25
3469   ,p_ass_attribute26              => l_asg_rec.ass_attribute26
3470   ,p_ass_attribute27              => l_asg_rec.ass_attribute27
3471   ,p_ass_attribute28              => l_asg_rec.ass_attribute28
3472   ,p_ass_attribute29              => l_asg_rec.ass_attribute29
3473   ,p_ass_attribute30              => l_asg_rec.ass_attribute30
3474   -- Hr Soft Coding KeyFlex segments
3475   ,p_segment1                     => l_scl_rec.segment1
3476   ,p_segment2                     => l_scl_rec.segment2
3477   ,p_segment3                     => l_scl_rec.segment3
3478   ,p_segment4                     => l_scl_rec.segment4
3479   ,p_segment5                     => l_scl_rec.segment5
3480   ,p_segment6                     => l_scl_rec.segment6
3481   ,p_segment7                     => l_scl_rec.segment7
3482   ,p_segment8                     => l_scl_rec.segment8
3483   ,p_segment9                     => l_scl_rec.segment9
3484   ,p_segment10                    => l_scl_rec.segment10
3485   ,p_segment11                    => l_scl_rec.segment11
3486   ,p_segment12                    => l_scl_rec.segment12
3487   ,p_segment13                    => l_scl_rec.segment13
3488   ,p_segment14                    => l_scl_rec.segment14
3489   ,p_segment15                    => l_scl_rec.segment15
3490   ,p_segment16                    => l_scl_rec.segment16
3491   ,p_segment17                    => l_scl_rec.segment17
3492   ,p_segment18                    => l_scl_rec.segment18
3493   ,p_segment19                    => l_scl_rec.segment19
3494   ,p_segment20                    => l_scl_rec.segment20
3495   ,p_segment21                    => l_scl_rec.segment21
3496   ,p_segment22                    => l_scl_rec.segment22
3497   ,p_segment23                    => l_scl_rec.segment23
3498   ,p_segment24                    => l_scl_rec.segment24
3499   ,p_segment25                    => l_scl_rec.segment25
3500   ,p_segment26                    => l_scl_rec.segment26
3501   ,p_segment27                    => l_scl_rec.segment27
3502   ,p_segment28                    => l_scl_rec.segment28
3503   ,p_segment29                    => l_scl_rec.segment29
3504   ,p_segment30                    => l_scl_rec.segment30
3505   ,p_concat_segments              => l_scl_rec.concatenated_segments
3506   -- Out Parameters
3507   ,p_cagr_grade_def_id            => l_asg_rec.cagr_grade_def_id
3508   ,p_soft_coding_keyflex_id       => g_asg_rec.soft_coding_keyflex_id
3509   ,p_cagr_concatenated_segments   => l_UpdEmpAsg_out.cagr_concatenated_segments
3510   ,p_comment_id                   => l_UpdEmpAsg_out.comment_id
3511   ,p_effective_start_date         => l_UpdEmpAsg_out.effective_start_date
3512   ,p_effective_end_date           => l_UpdEmpAsg_out.effective_end_date
3513   ,p_concatenated_segments        => l_UpdEmpAsg_out.concatenated_segments
3514   ,p_no_managers_warning          => l_UpdEmpAsg_out.no_managers_warning
3515   ,p_other_manager_warning        => l_UpdEmpAsg_out.other_manager_warning
3516   ,p_hourly_salaried_warning      => l_UpdEmpAsg_out.hourly_salaried_warning
3517   ,p_gsp_post_process_warning     => l_UpdEmpAsg_out.gsp_post_process_warning
3518   );
3519 
3520   l_datetrack_update_mode := 'CORRECTION';
3521 
3522 Hr_Assignment_Api.Update_Emp_Asg_Criteria
3523   (p_effective_date               => p_effective_date
3524   ,p_datetrack_update_mode        => l_datetrack_update_mode
3525   ,p_assignment_id                => g_asg_rec.assignment_id
3526   ,p_validate                     => false
3527   ,p_called_from_mass_update      => false
3528   ,p_grade_id                     => l_asg_rec.grade_id
3529   ,p_position_id                  => l_asg_rec.position_id
3530   ,p_job_id                       => l_asg_rec.job_id
3531   ,p_payroll_id                   => l_asg_rec.payroll_id
3532   ,p_location_id                  => l_asg_rec.location_id
3533   ,p_organization_id              => l_asg_rec.organization_id
3534   ,p_pay_basis_id                 => l_asg_rec.pay_basis_id
3535   ,p_employment_category          => l_asg_rec.employment_category
3536 
3537   ,p_segment1                     => l_grp_rec.segment1
3538   ,p_segment2                     => l_grp_rec.segment2
3539   ,p_segment3                     => l_grp_rec.segment3
3540   ,p_segment4                     => l_grp_rec.segment4
3541   ,p_segment5                     => l_grp_rec.segment5
3542   ,p_segment6                     => l_grp_rec.segment6
3543   ,p_segment7                     => l_grp_rec.segment7
3544   ,p_segment8                     => l_grp_rec.segment8
3545   ,p_segment9                     => l_grp_rec.segment9
3546   ,p_segment10                    => l_grp_rec.segment10
3547   ,p_segment11                    => l_grp_rec.segment11
3548   ,p_segment12                    => l_grp_rec.segment12
3549   ,p_segment13                    => l_grp_rec.segment13
3550   ,p_segment14                    => l_grp_rec.segment14
3551   ,p_segment15                    => l_grp_rec.segment15
3552   ,p_segment16                    => l_grp_rec.segment16
3553   ,p_segment17                    => l_grp_rec.segment17
3554   ,p_segment18                    => l_grp_rec.segment18
3555   ,p_segment19                    => l_grp_rec.segment19
3556   ,p_segment20                    => l_grp_rec.segment20
3557   ,p_segment21                    => l_grp_rec.segment21
3558   ,p_segment22                    => l_grp_rec.segment22
3559   ,p_segment23                    => l_grp_rec.segment23
3560   ,p_segment24                    => l_grp_rec.segment24
3561   ,p_segment25                    => l_grp_rec.segment25
3562   ,p_segment26                    => l_grp_rec.segment26
3563   ,p_segment27                    => l_grp_rec.segment27
3564   ,p_segment28                    => l_grp_rec.segment28
3565   ,p_segment29                    => l_grp_rec.segment29
3566   ,p_segment30                    => l_grp_rec.segment30
3567   ,p_concat_segments              => l_grp_rec.group_name
3568 
3569   ,p_scl_segment1                 => l_scl_rec.segment1
3570   ,p_object_version_number        => l_cur_asg_rec.object_version_number
3571   ,p_special_ceiling_step_id      => p_asg_crit_out.special_ceiling_step_id
3572   ,p_people_group_id              => p_asg_crit_out.people_group_id
3573   ,p_soft_coding_keyflex_id       => p_asg_crit_out.soft_coding_keyflex_id
3574   ,p_group_name                   => p_asg_crit_out.group_name
3575   ,p_effective_start_date         => p_asg_crit_out.asg_effective_start_date
3576   ,p_effective_end_date           => p_asg_crit_out.asg_effective_end_date
3577   ,p_org_now_no_manager_warning   => p_asg_crit_out.org_now_no_manager_warning
3578   ,p_other_manager_warning        => p_asg_crit_out.other_manager_warning
3579   ,p_spp_delete_warning           => p_asg_crit_out.spp_delete_warning
3580   ,p_entries_changed_warning      => p_asg_crit_out.entries_changed_warning
3581   ,p_tax_district_changed_warning => p_asg_crit_out.tax_district_changed_warning
3582   ,p_concatenated_segments        => p_asg_crit_out.concatenated_segments
3583   ,p_gsp_post_process_warning     => p_asg_crit_out.gsp_post_process_warning
3584   );
3585 
3586 
3587   if g_debug then
3588      hr_utility.set_location(' people_group_id: ' ||
3589                                p_asg_crit_out.people_group_id, 70);
3590      hr_utility.set_location(' soft_coding_keyflex_id: ' ||
3591                                p_asg_crit_out.soft_coding_keyflex_id, 70);
3592      hr_utility.set_location(' group_name: ' ||
3593                                p_asg_crit_out.group_name, 70);
3594      hr_utility.set_location(' asg_effective_start_date: ' ||
3595                                p_asg_crit_out.asg_effective_start_date, 70);
3596   end if;
3597 
3598 
3599   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
3600 
3601 exception
3602   when e_empasg_notfound  then
3603    l_error_msg := 'Employee Assignment could not be found as of the effective date';
3604 
3605    hr_utility.set_message(8303, 'PQP_230494_RIW_ASSGN_NOT_FOUND');
3606    hr_utility.set_message_token('TOKEN','Employee' );
3607    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
3608    hr_utility.raise_error;
3609 
3610   when Others then
3611    --l_error_msg := SQLERRM;
3612    hr_utility.set_location('SQLCODE :' || SQLCODE,100);
3613    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
3614    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
3615    hr_utility.set_location('Leaving: ' || l_proc_name, 100);
3616    hr_utility.raise_error;
3617 
3618 end Update_Employee_Asg;
3619 -- =============================================================================
3620 -- ~ Upd_Batch_Person:
3621 -- =============================================================================
3622 procedure Upd_Batch_Person
3623          (p_batch_id                in number
3624          ,p_user_sequence           in out nocopy number
3625          ,p_link_value              in number
3626          ,p_person_user_key         in varchar2
3627          ,p_user_person_type        in varchar2
3628          ,p_datetrack_update_mode   in varchar2
3629          ,p_adjusted_svc_date       in date default null  -- Added by pkagrawa
3630           ) is
3631 
3632   l_proc_name  constant    varchar2(150):= g_pkg ||'Upd_Batch_Person';
3633   l_per_rec                per_all_people_f%rowtype;
3634   l_cur_per_rec            per_all_people_f%rowtype;
3635   l_ptu_rec                chk_perType_usage%rowtype;
3636   l_datetrack_update_mode  varchar2(50);
3637   l_dt_correction          boolean;
3638   l_dt_update              boolean;
3639   l_dt_upd_override        boolean;
3640   l_upd_chg_ins            boolean;
3641   e_future_chgs_exists     exception;
3642   l_error_msg              varchar2(3000);
3643 
3644 begin
3645   hr_utility.set_location('Entering: ' || l_proc_name, 5);
3646 
3647   l_per_rec := Get_PerRecord_Values(g_interface_code);
3648   if p_datetrack_update_mode is not null then
3649      l_datetrack_update_mode := p_datetrack_update_mode;
3650   else
3651      open  csr_per(c_person_id         => g_per_rec.person_id
3652                   ,c_business_group_id => g_per_rec.business_group_id
3653                   ,c_effective_date    => g_per_rec.start_date);
3654      fetch csr_per into l_cur_per_rec;
3655      close csr_per;
3656      hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
3657      Dt_Api.Find_DT_Upd_Modes
3658      (p_effective_date        => g_per_rec.start_date
3659      ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
3660      ,p_base_key_column       => 'PERSON_ID'
3661      ,p_base_key_value        => l_cur_per_rec.person_id
3662      ,p_correction            => l_dt_correction
3663      ,p_update                => l_dt_update
3664      ,p_update_override       => l_dt_upd_override
3665      ,p_update_change_insert  => l_upd_chg_ins
3666       );
3667      if l_dt_update then
3668         l_datetrack_update_mode := 'UPDATE';
3669      elsif l_dt_upd_override or
3670            l_upd_chg_ins then
3671            -- Need to check if person type in future is EMP, APL or CWK , if yes
3672            -- then raise error
3673            open chk_perType_usage
3674               (c_person_id         => l_cur_per_rec.person_id
3675               ,c_effective_date    => g_per_rec.start_date
3676               ,c_business_group_id => g_per_rec.business_group_id);
3677            fetch chk_perType_usage into l_ptu_rec;
3678            if chk_perType_usage%found then
3679               close chk_perType_usage;
3680               raise e_future_chgs_exists;
3681            end if;
3682            close chk_perType_usage;
3683            --$ Else Correction Mode
3684            l_datetrack_update_mode := 'CORRECTION';
3685      else
3686         l_datetrack_update_mode := 'CORRECTION';
3687      end if;
3688   end if;
3689   hr_utility.set_location(' l_datetrack_update_mode: ' ||
3690                             l_datetrack_update_mode, 30);
3691 
3692   Hrdpp_Update_Person.Insert_Batch_Lines
3693   (p_batch_id                     => p_batch_id
3694   ,p_user_sequence                => p_user_sequence
3695   ,p_link_value                   => p_link_value
3696   ,p_effective_date               => g_per_rec.start_date
3697   ,p_datetrack_update_mode        => l_datetrack_update_mode
3698   ,p_person_user_key              => p_person_user_key
3699   ,p_user_person_type             => p_user_person_type
3700   ,p_language_code                => Userenv('lang')
3701   ,p_party_id                     => nvl(l_per_rec.party_id,
3702                                          l_cur_per_rec.party_id)
3703   ,p_employee_number              => nvl(l_per_rec.employee_number,
3704                                          l_cur_per_rec.employee_number)
3705   ,p_applicant_number             => nvl(l_per_rec.applicant_number,
3706                                          l_cur_per_rec.applicant_number)
3707   ,p_npw_number                   => nvl(l_per_rec.npw_number,
3708                                          l_cur_per_rec.npw_number)
3709   ,p_last_name                    => nvl(l_per_rec.last_name,
3710                                          l_cur_per_rec.last_name)
3711   ,p_first_name                   => l_per_rec.first_name
3712   ,p_date_of_birth                => nvl(l_per_rec.date_of_birth,
3713                                          l_cur_per_rec.date_of_birth)
3714   ,p_marital_status               => l_per_rec.marital_status
3715   ,p_middle_names                 => l_per_rec.middle_names
3716   ,p_sex                          => nvl(l_per_rec.sex,
3717                                          l_cur_per_rec.sex)
3718   ,p_title                        => l_per_rec.title
3719   ,p_nationality                  => l_per_rec.nationality
3720   ,p_previous_last_name           => l_per_rec.previous_last_name
3721   ,p_national_identifier          => l_per_rec.national_identifier
3722   ,p_known_as                     => l_per_rec.known_as
3723   ,p_email_address                => l_per_rec.email_address
3724   ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
3725   ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
3726   ,p_expense_check_send_to_addres => l_per_rec.expense_check_send_to_address
3727   ,p_per_information_category     => l_per_rec.per_information_category
3728   ,p_per_information1             => l_per_rec.per_information1
3729   ,p_per_information2             => l_per_rec.per_information2
3730   ,p_per_information3             => l_per_rec.per_information3
3731   ,p_per_information4             => l_per_rec.per_information4
3732   ,p_per_information5             => l_per_rec.per_information5
3733   ,p_per_information6             => l_per_rec.per_information6
3734   ,p_per_information7             => l_per_rec.per_information7
3735   ,p_per_information8             => l_per_rec.per_information8
3736   ,p_per_information9             => l_per_rec.per_information9
3737   ,p_per_information10            => l_per_rec.per_information10
3738   ,p_per_information11            => l_per_rec.per_information11
3739   ,p_per_information12            => l_per_rec.per_information12
3740   ,p_per_information13            => l_per_rec.per_information13
3741   ,p_per_information14            => l_per_rec.per_information14
3742   ,p_per_information15            => l_per_rec.per_information15
3743   ,p_per_information16            => l_per_rec.per_information16
3744   ,p_per_information17            => l_per_rec.per_information17
3745   ,p_per_information18            => l_per_rec.per_information18
3746   ,p_per_information19            => l_per_rec.per_information19
3747   ,p_per_information20            => l_per_rec.per_information20
3748   ,p_per_information21            => l_per_rec.per_information21
3749   ,p_per_information22            => l_per_rec.per_information22
3750   ,p_per_information23            => l_per_rec.per_information23
3751   ,p_per_information24            => l_per_rec.per_information24
3752   ,p_per_information25            => l_per_rec.per_information25
3753   ,p_per_information26            => l_per_rec.per_information26
3754   ,p_per_information27            => l_per_rec.per_information27
3755   ,p_per_information28            => l_per_rec.per_information28
3756   ,p_per_information29            => l_per_rec.per_information29
3757   ,p_per_information30            => l_per_rec.per_information30
3758   -- Person DF
3759   ,p_attribute_category           => l_per_rec.attribute_category
3760   ,p_attribute1                   => l_per_rec.attribute1
3761   ,p_attribute2                   => l_per_rec.attribute2
3762   ,p_attribute3                   => l_per_rec.attribute3
3763   ,p_attribute4                   => l_per_rec.attribute4
3764   ,p_attribute5                   => l_per_rec.attribute5
3765   ,p_attribute6                   => l_per_rec.attribute6
3766   ,p_attribute7                   => l_per_rec.attribute7
3767   ,p_attribute8                   => l_per_rec.attribute8
3768   ,p_attribute9                   => l_per_rec.attribute9
3769   ,p_attribute10                  => l_per_rec.attribute10
3770   ,p_attribute11                  => l_per_rec.attribute11
3771   ,p_attribute12                  => l_per_rec.attribute12
3772   ,p_attribute13                  => l_per_rec.attribute13
3773   ,p_attribute14                  => l_per_rec.attribute14
3774   ,p_attribute15                  => l_per_rec.attribute15
3775   ,p_attribute16                  => l_per_rec.attribute16
3776   ,p_attribute17                  => l_per_rec.attribute17
3777   ,p_attribute18                  => l_per_rec.attribute18
3778   ,p_attribute19                  => l_per_rec.attribute19
3779   ,p_attribute20                  => l_per_rec.attribute20
3780   ,p_attribute21                  => l_per_rec.attribute21
3781   ,p_attribute22                  => l_per_rec.attribute22
3782   ,p_attribute23                  => l_per_rec.attribute23
3783   ,p_attribute24                  => l_per_rec.attribute24
3784   ,p_attribute25                  => l_per_rec.attribute25
3785   ,p_attribute26                  => l_per_rec.attribute26
3786   ,p_attribute27                  => l_per_rec.attribute27
3787   ,p_attribute28                  => l_per_rec.attribute28
3788   ,p_attribute29                  => l_per_rec.attribute29
3789   ,p_attribute30                  => l_per_rec.attribute30
3790 
3791   ,p_date_of_death                => l_per_rec.date_of_death
3792   ,p_background_date_check        => l_per_rec.background_date_check
3793   ,p_hold_applicant_date_until    => l_per_rec.hold_applicant_date_until
3794   ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
3795   ,p_projected_start_date         => l_per_rec.projected_start_date
3796   ,p_resume_last_updated          => l_per_rec.resume_last_updated
3797   ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
3798   ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
3799   ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
3800   ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
3801   ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
3802 
3803   ,p_background_check_status      => l_per_rec.background_check_status
3804   ,p_blood_type                   => l_per_rec.blood_type
3805   ,p_correspondence_language      => l_per_rec.correspondence_language
3806   ,p_fte_capacity                 => l_per_rec.fte_capacity
3807   ,p_honors                       => l_per_rec.honors
3808   ,p_internal_location            => l_per_rec.internal_location
3809   ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
3810   ,p_mailstop                     => l_per_rec.mailstop
3811   ,p_office_number                => l_per_rec.office_number
3812   ,p_on_military_service          => l_per_rec.on_military_service
3813   ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
3814   ,p_rehire_authorizor            => l_per_rec.rehire_authorizor
3815   ,p_rehire_recommendation        => l_per_rec.rehire_recommendation
3816   ,p_resume_exists                => l_per_rec.resume_exists
3817   ,p_second_passport_exists       => l_per_rec.second_passport_exists
3818   ,p_student_status               => l_per_rec.student_status
3819   ,p_work_schedule                => l_per_rec.work_schedule
3820   ,p_rehire_reason                => l_per_rec.rehire_reason
3821   ,p_suffix                       => l_per_rec.suffix
3822 --$ In Batch Lines Benefit Group Name has to be passed instead of ID
3823 --  ,p_benefit_group                => l_per_rec.benefit_group_id
3824   ,p_benefit_group                =>  g_benefit_grp_name
3825 
3826   ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
3827   ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
3828   ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
3829   ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
3830   ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
3831   ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
3832   ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
3833   ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
3834   ,p_town_of_birth                => l_per_rec.town_of_birth
3835   ,p_region_of_birth              => l_per_rec.region_of_birth
3836   ,p_country_of_birth             => l_per_rec.country_of_birth
3837   ,p_global_person_id             => l_per_rec.global_person_id
3838   ,p_vendor_name                  => null
3839   ,p_adjusted_svc_date            => p_adjusted_svc_date --Added By pkagrawa
3840   );
3841 
3842   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
3843 
3844 exception
3845   when e_future_chgs_exists then
3846     l_error_msg := 'This person cannot be created in HRMS as a Student '||
3847                    'Employee due to future changes beyond the date: '||g_per_rec.start_date;
3848 
3849     hr_utility.set_location('..Future Update exists for the Student Employee', 60);
3850     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
3851     hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
3852     hr_utility.set_location('Leaving: ' || l_proc_name, 60);
3853     hr_utility.raise_error;
3854 
3855   when Others then
3856   hr_utility.set_location('SQLERRM :' || SQLCODE,90);
3857   hr_utility.set_location('Leaving: ' || l_proc_name, 90);
3858   raise;
3859 end Upd_Batch_Person;
3860 -- =============================================================================
3861 -- InsUpd_Batch_Applicant:
3862 -- =============================================================================
3863 procedure InsUpd_Batch_Applicant
3864          (p_batch_id                in number
3865          ,p_data_pump_batch_line_id in number default null
3866          ,p_user_sequence           in out nocopy number
3867          ,p_link_value              in number
3868          ,p_assignment_user_key     in varchar2
3869          ,p_person_user_key         in varchar2
3870          ,p_user_person_type        in varchar2
3871          ,p_action_mode             in varchar2
3872          ,p_datetrack_update_mode   in varchar2
3873          ,p_vacancy_user_key        in varchar2
3874          ,p_application_user_key    in varchar2
3875           ) is
3876 
3877   l_proc_name  constant     varchar2(150):= g_pkg ||'InsUpd_Batch_Applicant';
3878 
3879 begin
3880 
3881   hr_utility.set_location('Entering: ' || l_proc_name, 5);
3882   hr_utility.set_location('p_action_mode: ' || p_action_mode, 6);
3883 
3884   if p_action_mode = 'CREATE_APPLICANT' then
3885 
3886     Hrdpp_Create_Applicant.Insert_Batch_Lines
3887     (p_batch_id                     => p_batch_id
3888     ,p_data_pump_batch_line_id      => p_data_pump_batch_line_id
3889     ,p_user_sequence                => p_user_sequence
3890     ,p_link_value                   => p_link_value
3891     ,p_person_user_key              => p_person_user_key
3892     ,p_assignment_user_key          => p_assignment_user_key
3893     ,p_user_person_type             => p_user_person_type
3894     ,p_application_user_key         => p_application_user_key
3895     ,p_vacancy_user_key             => p_vacancy_user_key
3896     ,p_language_code                => Userenv('lang')
3897     ,p_applicant_number             => g_per_rec.applicant_number
3898 
3899     ,p_date_received                => g_per_rec.start_date
3900     ,p_last_name                    => g_per_rec.last_name
3901     ,p_sex                          => g_per_rec.sex
3902     ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
3903     ,p_date_of_birth                => g_per_rec.date_of_birth
3904     ,p_email_address                => g_per_rec.email_address
3905     ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
3906     ,p_first_name                   => g_per_rec.first_name
3907     ,p_known_as                     => g_per_rec.known_as
3908     ,p_marital_status               => g_per_rec.marital_status
3909     ,p_middle_names                 => g_per_rec.middle_names
3910     ,p_nationality                  => g_per_rec.nationality
3911     ,p_national_identifier          => g_per_rec.national_identifier
3912     ,p_previous_last_name           => g_per_rec.previous_last_name
3913     ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
3914     ,p_title                        => g_per_rec.title
3915 
3916     ,p_attribute_category           => g_per_rec.attribute_category
3917     ,p_attribute1                   => g_per_rec.attribute1
3918     ,p_attribute2                   => g_per_rec.attribute2
3919     ,p_attribute3                   => g_per_rec.attribute3
3920     ,p_attribute4                   => g_per_rec.attribute4
3921     ,p_attribute5                   => g_per_rec.attribute5
3922     ,p_attribute6                   => g_per_rec.attribute6
3923     ,p_attribute7                   => g_per_rec.attribute7
3924     ,p_attribute8                   => g_per_rec.attribute8
3925     ,p_attribute9                   => g_per_rec.attribute9
3926     ,p_attribute10                  => g_per_rec.attribute10
3927     ,p_attribute11                  => g_per_rec.attribute11
3928     ,p_attribute12                  => g_per_rec.attribute12
3929     ,p_attribute13                  => g_per_rec.attribute13
3930     ,p_attribute14                  => g_per_rec.attribute14
3931     ,p_attribute15                  => g_per_rec.attribute15
3932     ,p_attribute16                  => g_per_rec.attribute16
3933     ,p_attribute17                  => g_per_rec.attribute17
3934     ,p_attribute18                  => g_per_rec.attribute18
3935     ,p_attribute19                  => g_per_rec.attribute19
3936     ,p_attribute20                  => g_per_rec.attribute20
3937     ,p_attribute21                  => g_per_rec.attribute21
3938     ,p_attribute22                  => g_per_rec.attribute22
3939     ,p_attribute23                  => g_per_rec.attribute23
3940     ,p_attribute24                  => g_per_rec.attribute24
3941     ,p_attribute25                  => g_per_rec.attribute25
3942     ,p_attribute26                  => g_per_rec.attribute26
3943     ,p_attribute27                  => g_per_rec.attribute27
3944     ,p_attribute28                  => g_per_rec.attribute28
3945     ,p_attribute29                  => g_per_rec.attribute29
3946     ,p_attribute30                  => g_per_rec.attribute30
3947 
3948     ,p_per_information_category     => g_per_rec.per_information_category
3949     ,p_per_information1             => g_per_rec.per_information1
3950     ,p_per_information2             => g_per_rec.per_information2
3951     ,p_per_information3             => g_per_rec.per_information3
3952     ,p_per_information4             => g_per_rec.per_information4
3953     ,p_per_information5             => g_per_rec.per_information5
3954     ,p_per_information6             => g_per_rec.per_information6
3955     ,p_per_information7             => g_per_rec.per_information7
3956     ,p_per_information8             => g_per_rec.per_information8
3957     ,p_per_information9             => g_per_rec.per_information9
3958     ,p_per_information10            => g_per_rec.per_information10
3959     ,p_per_information11            => g_per_rec.per_information11
3960     ,p_per_information12            => g_per_rec.per_information12
3961     ,p_per_information13            => g_per_rec.per_information13
3962     ,p_per_information14            => g_per_rec.per_information14
3963     ,p_per_information15            => g_per_rec.per_information15
3964     ,p_per_information16            => g_per_rec.per_information16
3965     ,p_per_information17            => g_per_rec.per_information17
3966     ,p_per_information18            => g_per_rec.per_information18
3967     ,p_per_information19            => g_per_rec.per_information19
3968     ,p_per_information20            => g_per_rec.per_information20
3969     ,p_per_information21            => g_per_rec.per_information21
3970     ,p_per_information22            => g_per_rec.per_information22
3971     ,p_per_information23            => g_per_rec.per_information23
3972     ,p_per_information24            => g_per_rec.per_information24
3973     ,p_per_information25            => g_per_rec.per_information25
3974     ,p_per_information26            => g_per_rec.per_information26
3975     ,p_per_information27            => g_per_rec.per_information27
3976     ,p_per_information28            => g_per_rec.per_information28
3977     ,p_per_information29            => g_per_rec.per_information29
3978     ,p_per_information30            => g_per_rec.per_information30
3979 
3980     ,p_background_check_status      => g_per_rec.background_check_status
3981     ,p_background_date_check        => g_per_rec.background_date_check
3982     ,p_fte_capacity                 => g_per_rec.fte_capacity
3983     ,p_honors                       => g_per_rec.honors
3984     ,p_on_military_service          => g_per_rec.on_military_service
3985     ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
3986     ,p_projected_start_date         => g_per_rec.projected_start_date
3987     ,p_resume_exists                => g_per_rec.resume_exists
3988     ,p_resume_last_updated          => g_per_rec.resume_last_updated
3989     ,p_work_schedule                => g_per_rec.work_schedule
3990     ,p_suffix                       => g_per_rec.suffix
3991     ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
3992     ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
3993     ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
3994     ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
3995     ,p_town_of_birth                => g_per_rec.town_of_birth
3996     ,p_region_of_birth              => g_per_rec.region_of_birth
3997     ,p_country_of_birth             => g_per_rec.country_of_birth
3998     ,p_global_person_id             => g_per_rec.global_person_id
3999     ,p_party_id                     => g_per_rec.party_id
4000     ,p_correspondence_language      => g_per_rec.correspondence_language
4001  --$ In Batch Lines Benefit Group Name has to be passed instead of ID
4002     ,p_benefit_group                => g_benefit_grp_name
4003     );
4004 
4005   end if;
4006   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
4007 
4008 end InsUpd_Batch_Applicant;
4009 -- =============================================================================
4010 -- ~ InsUpd_Batch_ContactPerson:
4011 -- =============================================================================
4012 procedure InsUpd_Batch_ContactPerson
4013          (p_batch_id                in number
4014          ,p_data_pump_batch_line_id in number default null
4015          ,p_user_sequence           in out nocopy number
4016          ,p_link_value              in number
4017          ,p_person_user_key         in varchar2
4018          ,p_user_person_type        in varchar2
4019           ) is
4020 
4021   l_proc_name  constant     varchar2(150):= g_pkg ||'InsUpd_Batch_ContactPerson';
4022 
4023 begin
4024 
4025   hr_utility.set_location('Entering: ' || l_proc_name, 5);
4026 
4027   HrDpp_Create_Person.Insert_Batch_Lines
4028  (p_batch_id                     => p_batch_id
4029  ,p_data_pump_batch_line_id      => p_data_pump_batch_line_id
4030  --,p_data_pump_business_grp_name
4031  ,p_user_sequence                => p_user_sequence
4032  ,p_link_value                   => p_link_value
4033  ,p_person_user_key              => p_person_user_key
4034  ,p_user_person_type             => p_user_person_type
4035  ,p_start_date                   => g_per_rec.start_date
4036  ,p_last_name                    => g_per_rec.last_name
4037  ,p_sex                          => g_per_rec.sex
4038  ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
4039  ,p_date_of_birth                => g_per_rec.date_of_birth
4040  ,p_email_address                => g_per_rec.email_address
4041  ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
4042  ,p_first_name                   => g_per_rec.first_name
4043  ,p_known_as                     => g_per_rec.known_as
4044  ,p_marital_status               => g_per_rec.marital_status
4045  ,p_middle_names                 => g_per_rec.middle_names
4046  ,p_nationality                  => g_per_rec.nationality
4047  ,p_national_identifier          => g_per_rec.national_identifier
4048  ,p_previous_last_name           => g_per_rec.previous_last_name
4049  ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
4050  ,p_title                        => g_per_rec.title
4051  ,p_work_telephone               => g_per_rec.work_telephone
4052  ,p_attribute_category           => g_per_rec.attribute_category
4053  ,p_attribute1                   => g_per_rec.attribute1
4054  ,p_attribute2                   => g_per_rec.attribute2
4055  ,p_attribute3                   => g_per_rec.attribute3
4056  ,p_attribute4                   => g_per_rec.attribute4
4057  ,p_attribute5                   => g_per_rec.attribute5
4058  ,p_attribute6                   => g_per_rec.attribute6
4059  ,p_attribute7                   => g_per_rec.attribute7
4060  ,p_attribute8                   => g_per_rec.attribute8
4061  ,p_attribute9                   => g_per_rec.attribute9
4062  ,p_attribute10                  => g_per_rec.attribute10
4063  ,p_attribute11                  => g_per_rec.attribute11
4064  ,p_attribute12                  => g_per_rec.attribute12
4065  ,p_attribute13                  => g_per_rec.attribute13
4066  ,p_attribute14                  => g_per_rec.attribute14
4067  ,p_attribute15                  => g_per_rec.attribute15
4068  ,p_attribute16                  => g_per_rec.attribute16
4069  ,p_attribute17                  => g_per_rec.attribute17
4070  ,p_attribute18                  => g_per_rec.attribute18
4071  ,p_attribute19                  => g_per_rec.attribute19
4072  ,p_attribute20                  => g_per_rec.attribute20
4073  ,p_attribute21                  => g_per_rec.attribute21
4074  ,p_attribute22                  => g_per_rec.attribute22
4075  ,p_attribute23                  => g_per_rec.attribute23
4076  ,p_attribute24                  => g_per_rec.attribute24
4077  ,p_attribute25                  => g_per_rec.attribute25
4078  ,p_attribute26                  => g_per_rec.attribute26
4079  ,p_attribute27                  => g_per_rec.attribute27
4080  ,p_attribute28                  => g_per_rec.attribute28
4081  ,p_attribute29                  => g_per_rec.attribute29
4082  ,p_attribute30                  => g_per_rec.attribute30
4083 
4084  ,p_per_information_category     => g_per_rec.per_information_category
4085  ,p_per_information1             => g_per_rec.per_information1
4086  ,p_per_information2             => g_per_rec.per_information2
4087  ,p_per_information3             => g_per_rec.per_information3
4088  ,p_per_information4             => g_per_rec.per_information4
4089  ,p_per_information5             => g_per_rec.per_information5
4090  ,p_per_information6             => g_per_rec.per_information6
4091  ,p_per_information7             => g_per_rec.per_information7
4092  ,p_per_information8             => g_per_rec.per_information8
4093  ,p_per_information9             => g_per_rec.per_information9
4094  ,p_per_information10            => g_per_rec.per_information10
4095  ,p_per_information11            => g_per_rec.per_information11
4096  ,p_per_information12            => g_per_rec.per_information12
4097  ,p_per_information13            => g_per_rec.per_information13
4098  ,p_per_information14            => g_per_rec.per_information14
4099  ,p_per_information15            => g_per_rec.per_information15
4100  ,p_per_information16            => g_per_rec.per_information16
4101  ,p_per_information17            => g_per_rec.per_information17
4102  ,p_per_information18            => g_per_rec.per_information18
4103  ,p_per_information19            => g_per_rec.per_information19
4104  ,p_per_information20            => g_per_rec.per_information20
4105  ,p_per_information21            => g_per_rec.per_information21
4106  ,p_per_information22            => g_per_rec.per_information22
4107  ,p_per_information23            => g_per_rec.per_information23
4108  ,p_per_information24            => g_per_rec.per_information24
4109  ,p_per_information25            => g_per_rec.per_information25
4110  ,p_per_information26            => g_per_rec.per_information26
4111  ,p_per_information27            => g_per_rec.per_information27
4112  ,p_per_information28            => g_per_rec.per_information28
4113  ,p_per_information29            => g_per_rec.per_information29
4114  ,p_per_information30            => g_per_rec.per_information30
4115 
4116  ,p_correspondence_language      => g_per_rec.correspondence_language
4117  ,p_honors                       => g_per_rec.honors
4118  ,p_on_military_service          => g_per_rec.on_military_service
4119  ,p_student_status               => g_per_rec.student_status
4120  ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
4121  ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
4122  ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
4123  ,p_suffix                       => g_per_rec.suffix
4124  ,p_town_of_birth                => g_per_rec.town_of_birth
4125  ,p_region_of_birth              => g_per_rec.region_of_birth
4126  ,p_country_of_birth             => g_per_rec.country_of_birth
4127  ,p_global_person_id             => g_per_rec.global_person_id
4128  --,p_vendor_name                  => null
4129 
4130  --$ In Batch Lines Benefit Group Name has to be passed instead of ID
4131  ,p_benefit_group                => g_benefit_grp_name
4132  ,p_language_code                => Userenv('lang')
4133   );
4134   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
4135 
4136 end InsUpd_Batch_ContactPerson;
4137 
4138 -- =============================================================================
4139 -- ~ InsUpd_Batch_Employee:
4140 -- =============================================================================
4141 procedure InsUpd_Batch_Employee
4142          (p_batch_id                in number
4143          ,p_data_pump_batch_line_id in number default null
4144          ,p_user_sequence           in out nocopy number
4145          ,p_link_value              in number
4146          ,p_assignment_user_key     in varchar2
4147          ,p_person_user_key         in varchar2
4148          ,p_user_person_type        in varchar2
4149          ,p_action_mode             in varchar2
4150          ,p_datetrack_update_mode   in varchar2
4151          ,p_cur_rec                 in per_all_people_f%rowtype
4152          ,p_adjusted_svc_date   in date default null  -- Added by pkagrawa
4153           ) is
4154 
4155   l_proc_name  constant     varchar2(150):= g_pkg ||'InsUpd_Batch_Employee';
4156 
4157 begin
4158 
4159   hr_utility.set_location('Entering: ' || l_proc_name, 5);
4160   hr_utility.set_location('p_action_mode: ' || p_action_mode, 6);
4161 
4162   if p_action_mode = 'CREATE_EMPLOYEE' then
4163 
4164     Hrdpp_Create_Employee.Insert_Batch_Lines
4165     (p_batch_id                     => p_batch_id
4166     ,p_data_pump_batch_line_id      => p_data_pump_batch_line_id
4167     ,p_user_sequence                => p_user_sequence
4168     ,p_link_value                   => p_link_value
4169     ,p_person_user_key              => p_person_user_key
4170     ,p_assignment_user_key          => p_assignment_user_key
4171     ,p_user_person_type             => p_user_person_type
4172     ,p_hire_date                    => g_per_rec.start_date
4173     ,p_last_name                    => g_per_rec.last_name
4174     ,p_sex                          => g_per_rec.sex
4175     ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
4176     ,p_date_of_birth                => g_per_rec.date_of_birth
4177     ,p_email_address                => g_per_rec.email_address
4178     ,p_employee_number              => g_per_rec.employee_number
4179     ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
4180     ,p_first_name                   => g_per_rec.first_name
4181     ,p_known_as                     => g_per_rec.known_as
4182     ,p_marital_status               => g_per_rec.marital_status
4183     ,p_middle_names                 => g_per_rec.middle_names
4184     ,p_nationality                  => g_per_rec.nationality
4185     ,p_national_identifier          => g_per_rec.national_identifier
4186     ,p_previous_last_name           => g_per_rec.previous_last_name
4187     ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
4188     ,p_title                        => g_per_rec.title
4189     ,p_attribute_category           => g_per_rec.attribute_category
4190     ,p_attribute1                   => g_per_rec.attribute1
4191     ,p_attribute2                   => g_per_rec.attribute2
4192     ,p_attribute3                   => g_per_rec.attribute3
4193     ,p_attribute4                   => g_per_rec.attribute4
4194     ,p_attribute5                   => g_per_rec.attribute5
4195     ,p_attribute6                   => g_per_rec.attribute6
4196     ,p_attribute7                   => g_per_rec.attribute7
4197     ,p_attribute8                   => g_per_rec.attribute8
4198     ,p_attribute9                   => g_per_rec.attribute9
4199     ,p_attribute10                  => g_per_rec.attribute10
4200     ,p_attribute11                  => g_per_rec.attribute11
4201     ,p_attribute12                  => g_per_rec.attribute12
4202     ,p_attribute13                  => g_per_rec.attribute13
4203     ,p_attribute14                  => g_per_rec.attribute14
4204     ,p_attribute15                  => g_per_rec.attribute15
4205     ,p_attribute16                  => g_per_rec.attribute16
4206     ,p_attribute17                  => g_per_rec.attribute17
4207     ,p_attribute18                  => g_per_rec.attribute18
4208     ,p_attribute19                  => g_per_rec.attribute19
4209     ,p_attribute20                  => g_per_rec.attribute20
4210     ,p_attribute21                  => g_per_rec.attribute21
4211     ,p_attribute22                  => g_per_rec.attribute22
4212     ,p_attribute23                  => g_per_rec.attribute23
4213     ,p_attribute24                  => g_per_rec.attribute24
4214     ,p_attribute25                  => g_per_rec.attribute25
4215     ,p_attribute26                  => g_per_rec.attribute26
4216     ,p_attribute27                  => g_per_rec.attribute27
4217     ,p_attribute28                  => g_per_rec.attribute28
4218     ,p_attribute29                  => g_per_rec.attribute29
4219     ,p_attribute30                  => g_per_rec.attribute30
4220     ,p_per_information_category     => g_per_rec.per_information_category
4221     ,p_per_information1             => g_per_rec.per_information1
4222     ,p_per_information2             => g_per_rec.per_information2
4223     ,p_per_information3             => g_per_rec.per_information3
4224     ,p_per_information4             => g_per_rec.per_information4
4225     ,p_per_information5             => g_per_rec.per_information5
4226     ,p_per_information6             => g_per_rec.per_information6
4227     ,p_per_information7             => g_per_rec.per_information7
4228     ,p_per_information8             => g_per_rec.per_information8
4229     ,p_per_information9             => g_per_rec.per_information9
4230     ,p_per_information10            => g_per_rec.per_information10
4231     ,p_per_information11            => g_per_rec.per_information11
4232     ,p_per_information12            => g_per_rec.per_information12
4233     ,p_per_information13            => g_per_rec.per_information13
4234     ,p_per_information14            => g_per_rec.per_information14
4235     ,p_per_information15            => g_per_rec.per_information15
4236     ,p_per_information16            => g_per_rec.per_information16
4237     ,p_per_information17            => g_per_rec.per_information17
4238     ,p_per_information18            => g_per_rec.per_information18
4239     ,p_per_information19            => g_per_rec.per_information19
4240     ,p_per_information20            => g_per_rec.per_information20
4241     ,p_per_information21            => g_per_rec.per_information21
4242     ,p_per_information22            => g_per_rec.per_information22
4243     ,p_per_information23            => g_per_rec.per_information23
4244     ,p_per_information24            => g_per_rec.per_information24
4245     ,p_per_information25            => g_per_rec.per_information25
4246     ,p_per_information26            => g_per_rec.per_information26
4247     ,p_per_information27            => g_per_rec.per_information27
4248     ,p_per_information28            => g_per_rec.per_information28
4249     ,p_per_information29            => g_per_rec.per_information29
4250     ,p_per_information30            => g_per_rec.per_information30
4251 
4252     ,p_date_of_death                => g_per_rec.date_of_death
4253     ,p_background_check_status      => g_per_rec.background_check_status
4254     ,p_background_date_check        => g_per_rec.background_date_check
4255     ,p_blood_type                   => g_per_rec.blood_type
4256     ,p_fast_path_employee           => g_per_rec.fast_path_employee
4257     ,p_fte_capacity                 => g_per_rec.fte_capacity
4258     ,p_honors                       => g_per_rec.honors
4259     ,p_internal_location            => g_per_rec.internal_location
4260     ,p_last_medical_test_by         => g_per_rec.last_medical_test_by
4261     ,p_last_medical_test_date       => g_per_rec.last_medical_test_date
4262     ,p_mailstop                     => g_per_rec.mailstop
4263     ,p_office_number                => g_per_rec.office_number
4264     ,p_on_military_service          => g_per_rec.on_military_service
4265     ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
4266     ,p_projected_start_date         => g_per_rec.projected_start_date
4267     ,p_resume_exists                => g_per_rec.resume_exists
4268     ,p_resume_last_updated          => g_per_rec.resume_last_updated
4269     ,p_second_passport_exists       => g_per_rec.second_passport_exists
4270     ,p_student_status               => g_per_rec.student_status
4271     ,p_work_schedule                => g_per_rec.work_schedule
4272     ,p_suffix                       => g_per_rec.suffix
4273     ,p_receipt_of_death_cert_date   => g_per_rec.receipt_of_death_cert_date
4274     ,p_coord_ben_med_pln_no         => g_per_rec.coord_ben_med_pln_no
4275     ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
4276     ,p_coord_ben_med_ext_er         => g_per_rec.coord_ben_med_ext_er
4277     ,p_coord_ben_med_pl_name        => g_per_rec.coord_ben_med_pl_name
4278     ,p_coord_ben_med_insr_crr_name  => g_per_rec.coord_ben_med_insr_crr_name
4279     ,p_coord_ben_med_insr_crr_ident => g_per_rec.coord_ben_med_insr_crr_ident
4280     ,p_coord_ben_med_cvg_strt_dt    => g_per_rec.coord_ben_med_cvg_strt_dt
4281     ,p_coord_ben_med_cvg_end_dt     => g_per_rec.coord_ben_med_cvg_end_dt
4282     ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
4283     ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
4284     ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
4285     ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
4286     ,p_town_of_birth                => g_per_rec.town_of_birth
4287     ,p_region_of_birth              => g_per_rec.region_of_birth
4288     ,p_country_of_birth             => g_per_rec.country_of_birth
4289     ,p_global_person_id             => g_per_rec.global_person_id
4290     ,p_party_id                     => g_per_rec.party_id
4291     ,p_correspondence_language      => g_per_rec.correspondence_language
4292 --$ In Batch Lines Benefit Group Name has to be passed instead of ID
4293     ,p_benefit_group                => g_benefit_grp_name
4294     ,p_language_code                => Userenv('lang')
4295     --,p_vendor_name                  => null
4296     ,p_adjusted_svc_date            => p_adjusted_svc_date --Added By pkagrawa
4297     );
4298 
4299   elsif p_action_mode = 'HIRE_INTO_JOB' then
4300 
4301     hr_pump_utils.add_user_key
4302       (p_user_key_value => p_person_user_key
4303       ,p_unique_key_id  => g_per_rec.person_id
4304        );
4305 
4306     Hrdpp_Hire_Into_Job.Insert_Batch_Lines
4307     (p_batch_id                     => p_batch_id
4308     ,p_user_sequence                => p_user_sequence
4309     ,p_link_value                   => p_link_value
4310     ,p_effective_date               => g_per_rec.start_date
4311     ,p_object_version_number        => g_per_rec.object_version_number
4312     ,p_employee_number              => g_per_rec.employee_number
4313     ,p_datetrack_update_mode        => p_datetrack_update_mode
4314     ,p_national_identifier          => g_per_rec.national_identifier
4315     ,p_per_information7             => null
4316     ,p_person_user_key              => p_person_user_key
4317     ,p_assignment_user_key          => p_assignment_user_key
4318     ,p_user_person_type             => p_user_person_type
4319     ,p_language_code                => Userenv('LANG')
4320     );
4321 
4322     p_user_sequence := p_user_sequence + 1;
4323 
4324     hr_utility.set_location(' Calling : ' ||
4325                             'Hrdpp_Update_Person.Insert_Batch_Lines', 7);
4326 
4327     Upd_Batch_Person
4328     (p_batch_id                => p_batch_id
4329     ,p_user_sequence           => p_user_sequence
4330     ,p_link_value              => p_link_value
4331     ,p_person_user_key         => p_person_user_key
4332     ,p_user_person_type        => p_user_person_type
4333     ,p_datetrack_update_mode   => 'CORRECTION'
4334      );
4335 
4336   end if;
4337   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
4338 
4339 end InsUpd_Batch_Employee;
4340 -- =============================================================================
4341 -- ~ InsUpd_Batch_Address:
4342 -- =============================================================================
4343 procedure InsUpd_Batch_Address
4344           (p_batch_id             in number
4345           ,p_user_sequence        in number
4346           ,p_link_value           in number
4347           ,p_person_user_key      in varchar2
4348           ,p_address_user_key     in varchar2
4349           ) is
4350 
4351 --  p_effective_date => g_per_rec.start_date => g_per_rec.start_date := trunc(p_date_of_hire);
4352 
4353   cursor csr_primary_add (c_person_id         in number
4354 		                 ,c_business_group_id in number
4355 		                 ,c_date_from		  in date
4356 		                 ,c_primary_flag      in varchar2) is
4357   select *
4358     from per_addresses pad
4359    where pad.person_id = c_person_id
4360      and pad.business_group_id = c_business_group_id
4361      and pad.primary_flag = c_primary_flag
4362      and c_date_from between pad.date_from
4363                               and NVL(pad.date_to, c_date_from);
4364 
4365   cursor csr_secondary_add (c_person_id          in number
4366                  		   ,c_business_group_id  in number
4367 		                   ,c_primary_flag       in varchar2
4368 		                   ,c_style				 in varchar2
4369 		                   ,c_address_type       in varchar2
4370 		                   ,c_date_from			 in date
4371 		                   ,c_effective_date     in date) is
4372   select *
4373     from per_addresses pad
4374    where pad.business_group_id = c_business_group_id
4375      and pad.person_id = c_person_id
4376      and pad.primary_flag = c_primary_flag
4377      and pad.STYLE = c_style
4378      and nvl(pad.ADDRESS_TYPE,0) = nvl(c_address_type,nvl(pad.ADDRESS_TYPE,0))
4379      and trunc(pad.date_from) = trunc(c_date_from);
4380 /*     and c_effective_date between pad.date_from
4381                               and NVL(pad.date_to, c_effective_date); */
4382 
4383   l_cur_add_rec             per_addresses%rowtype;
4384   l_proc_name  constant     varchar2(150):= g_pkg ||'InsUpd_Batch_Address';
4385   l_pradd_ovlapval_override boolean;
4386   l_error_msg               varchar2(2000);
4387 
4388   l_effective_date           date;
4389 begin
4390   hr_utility.set_location('Entering: ' || l_proc_name, 10);
4391 
4392   l_effective_date := g_add_rec.date_from;
4393 
4394   if g_add_rec.address_line1 is null and g_add_rec.style is null then
4395       return;
4396   end if;
4397 
4398 --hr_utility.trace('MSG_AD c_person_id='||g_add_rec.person_id);
4399 --hr_utility.trace('MSG_AD c_business_group_id='||g_add_rec.business_group_id);
4400 --hr_utility.trace('MSG_AD c_primary_flag='|| g_add_rec.primary_flag);
4401 --hr_utility.trace('MSG_AD c_effective_date='||l_effective_date);
4402 
4403   l_pradd_ovlapval_override := false;
4404 
4405      if Trunc(g_add_rec.date_from) > Trunc(l_cur_add_rec.date_from) then
4406         hr_utility.set_location(' g_add_rec.date_from: ' ||g_add_rec.date_from, 40);
4407         hr_utility.set_location(' g_add_rec.date_to: ' ||g_add_rec.date_to, 40);
4408 
4409         l_pradd_ovlapval_override := true;
4410      end if;
4411 
4412 
4413  IF g_add_rec.primary_flag = 'Y' Then
4414 
4415   open  csr_primary_add(c_person_id         => g_add_rec.person_id
4416                ,c_business_group_id 		=> g_add_rec.business_group_id
4417                ,c_date_from			        => g_add_rec.date_from
4418                ,c_primary_flag      		=> g_add_rec.primary_flag);
4419   fetch csr_primary_add into l_cur_add_rec;
4420 
4421   if csr_primary_add%notfound then
4422      hr_utility.set_location(' Primary Address Not found', 20);
4423      hr_utility.set_location(' Person ID'||g_add_rec.person_id, 25);
4424 
4425 --hr_utility.trace('MSG_AD l_effective_date:'||l_effective_date);
4426 --hr_utility.trace('MSG_AD primary_flag:'||g_add_rec.primary_flag);
4427 --hr_utility.trace('MSG_AD address_id:'||g_add_rec.address_id);
4428 --hr_utility.trace('MSG_AD object_version_number:'||g_add_rec.object_version_number);
4429     if (g_crt_upd = 'C') then
4430      Hrdpp_Create_Person_Address.Insert_Batch_Lines
4431     (p_batch_id                 => p_batch_id
4432     ,p_user_sequence            => p_user_sequence
4433     ,p_link_value               => p_link_value
4434     ,p_effective_date           => g_add_rec.date_from
4435     ,p_pradd_ovlapval_override  => l_pradd_ovlapval_override
4436     ,p_validate_county          => true
4437     ,p_primary_flag             => nvl(g_add_rec.primary_flag, 'Y')
4438     ,p_address_user_key         => p_address_user_key
4439     ,p_person_user_key          => p_person_user_key
4440     ,p_style                    => g_add_rec.style
4441     ,p_date_from                => g_add_rec.date_from
4442     ,p_date_to                  => g_add_rec.date_to
4443     ,p_address_type             => g_add_rec.address_type
4444     ,p_address_line1            => g_add_rec.address_line1
4445     ,p_address_line2            => g_add_rec.address_line2
4446     ,p_address_line3            => g_add_rec.address_line3
4447     ,p_town_or_city             => g_add_rec.town_or_city
4448     ,p_region_1                 => g_add_rec.region_1
4449     ,p_region_2                 => g_add_rec.region_2
4450     ,p_region_3                 => g_add_rec.region_3
4451     ,p_postal_code              => g_add_rec.postal_code
4452     ,p_telephone_number_1       => g_add_rec.telephone_number_1
4453     ,p_telephone_number_2       => g_add_rec.telephone_number_2
4454     ,p_telephone_number_3       => g_add_rec.telephone_number_3
4455     ,p_addr_attribute_category  => g_add_rec.addr_attribute_category
4456     ,p_addr_attribute1          => g_add_rec.addr_attribute1
4457     ,p_addr_attribute2          => g_add_rec.addr_attribute2
4458     ,p_addr_attribute3          => g_add_rec.addr_attribute3
4459     ,p_addr_attribute4          => g_add_rec.addr_attribute4
4460     ,p_addr_attribute5          => g_add_rec.addr_attribute5
4461     ,p_addr_attribute6          => g_add_rec.addr_attribute6
4462     ,p_addr_attribute7          => g_add_rec.addr_attribute7
4463     ,p_addr_attribute8          => g_add_rec.addr_attribute8
4464     ,p_addr_attribute9          => g_add_rec.addr_attribute9
4465     ,p_addr_attribute10         => g_add_rec.addr_attribute10
4466     ,p_addr_attribute11         => g_add_rec.addr_attribute11
4467     ,p_addr_attribute12         => g_add_rec.addr_attribute12
4468     ,p_addr_attribute13         => g_add_rec.addr_attribute13
4469     ,p_addr_attribute14         => g_add_rec.addr_attribute14
4470     ,p_addr_attribute15         => g_add_rec.addr_attribute15
4471     ,p_addr_attribute16         => g_add_rec.addr_attribute16
4472     ,p_addr_attribute17         => g_add_rec.addr_attribute17
4473     ,p_addr_attribute18         => g_add_rec.addr_attribute18
4474     ,p_addr_attribute19         => g_add_rec.addr_attribute19
4475     ,p_addr_attribute20         => g_add_rec.addr_attribute20
4476     ,p_add_information13        => g_add_rec.add_information13
4477     ,p_add_information14        => g_add_rec.add_information14
4478     ,p_add_information15        => g_add_rec.add_information15
4479     ,p_add_information16        => g_add_rec.add_information16
4480     ,p_add_information17        => g_add_rec.add_information17
4481     ,p_add_information18        => g_add_rec.add_information18
4482     ,p_add_information19        => g_add_rec.add_information19
4483     ,p_add_information20        => g_add_rec.add_information20
4484     ,p_party_id                 => g_add_rec.party_id
4485     ,p_country                  => g_add_rec.country
4486     );
4487     else
4488         raise e_crt_add_not_allowed;
4489     end if;
4490   else
4491      hr_utility.set_location(' Primary Address found: ' ||
4492                                l_cur_add_rec.address_id, 30);
4493 
4494      if g_add_rec.date_from is null then
4495         g_add_rec.date_from := trunc(l_effective_date);
4496      end if;
4497 
4498 --hr_utility.trace('MSG_AD l_effective_date:'||l_effective_date);
4499 --hr_utility.trace('MSG_AD primary_flag:'||g_add_rec.primary_flag);
4500 --hr_utility.trace('MSG_AD address_id:'||g_add_rec.address_id);
4501 --hr_utility.trace('MSG_AD object_version_number:'||g_add_rec.object_version_number);
4502 
4503 
4504 --hr_utility.trace('MSG_AD 11:'||l_effective_date);
4505 
4506         g_add_rec.address_id := l_cur_add_rec.address_id;
4507         g_add_rec.object_version_number := l_cur_add_rec.object_version_number;
4508         g_add_rec.style := l_cur_add_rec.style;
4509 
4510 --hr_utility.trace('MSG_AD 12:'||l_effective_date);
4511 
4512     --hr_utility.trace('$$_PSG InsUpd_Batch_Address Y p_address_user_key: '||p_address_user_key);
4513 
4514      hr_pump_utils.add_user_key
4515      (p_user_key_value => p_address_user_key
4516      ,p_unique_key_id  => g_add_rec.address_id
4517       );
4518 
4519      hr_utility.set_location(' HrDpp_Update_Person_Address.Insert_Batch_Lines: ' , 51);
4520      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
4521      HrDpp_Update_Person_Address.Insert_Batch_Lines
4522     (p_batch_id                 => p_batch_id
4523     ,p_user_sequence            => p_user_sequence
4524     ,p_link_value               => p_link_value
4525     --,p_data_pump_batch_line_id     => p_data_pump_batch_line_id
4526     --,p_data_pump_business_grp_name =>
4527     ,p_address_user_key         => p_address_user_key
4528     ,p_effective_date           => g_add_rec.date_from
4529     ,p_validate_county          => true
4530     ,p_date_from                => g_add_rec.date_from
4531     ,p_date_to                  => g_add_rec.date_to
4532     ,p_primary_flag             => nvl(g_add_rec.primary_flag, 'Y')
4533     ,p_address_type             => g_add_rec.address_type
4534     ,p_address_line1            => g_add_rec.address_line1
4535     ,p_address_line2            => g_add_rec.address_line2
4536     ,p_address_line3            => g_add_rec.address_line3
4537     ,p_town_or_city             => g_add_rec.town_or_city
4538     ,p_region_1                 => g_add_rec.region_1
4539     ,p_region_2                 => g_add_rec.region_2
4540     ,p_region_3                 => g_add_rec.region_3
4541     ,p_postal_code              => g_add_rec.postal_code
4542     ,p_telephone_number_1       => g_add_rec.telephone_number_1
4543     ,p_telephone_number_2       => g_add_rec.telephone_number_2
4544     ,p_telephone_number_3       => g_add_rec.telephone_number_3
4545     ,p_addr_attribute_category  => g_add_rec.addr_attribute_category
4546     ,p_addr_attribute1          => g_add_rec.addr_attribute1
4547     ,p_addr_attribute2          => g_add_rec.addr_attribute2
4548     ,p_addr_attribute3          => g_add_rec.addr_attribute3
4549     ,p_addr_attribute4          => g_add_rec.addr_attribute4
4550     ,p_addr_attribute5          => g_add_rec.addr_attribute5
4551     ,p_addr_attribute6          => g_add_rec.addr_attribute6
4552     ,p_addr_attribute7          => g_add_rec.addr_attribute7
4553     ,p_addr_attribute8          => g_add_rec.addr_attribute8
4554     ,p_addr_attribute9          => g_add_rec.addr_attribute9
4555     ,p_addr_attribute10         => g_add_rec.addr_attribute10
4556     ,p_addr_attribute11         => g_add_rec.addr_attribute11
4557     ,p_addr_attribute12         => g_add_rec.addr_attribute12
4558     ,p_addr_attribute13         => g_add_rec.addr_attribute13
4559     ,p_addr_attribute14         => g_add_rec.addr_attribute14
4560     ,p_addr_attribute15         => g_add_rec.addr_attribute15
4561     ,p_addr_attribute16         => g_add_rec.addr_attribute16
4562     ,p_addr_attribute17         => g_add_rec.addr_attribute17
4563     ,p_addr_attribute18         => g_add_rec.addr_attribute18
4564     ,p_addr_attribute19         => g_add_rec.addr_attribute19
4565     ,p_addr_attribute20         => g_add_rec.addr_attribute20
4566     ,p_party_id                 => g_add_rec.party_id
4567     ,p_country                  => g_add_rec.country
4568     );
4569     else
4570        raise e_upl_not_allowed;
4571     end if;
4572   end if;
4573 
4574 --hr_utility.trace('MSG_AD 13:'||l_effective_date);
4575 
4576 --  end if;
4577   close csr_primary_add;
4578 
4579 -- For Secondary Address
4580 
4581  ELSIF g_add_rec.primary_flag = 'N' Then
4582 
4583 --hr_utility.trace('Testing cursor');
4584 --hr_utility.trace('c_person_id :'||g_add_rec.person_id);
4585 --hr_utility.trace('c_business_group_id :'||g_add_rec.business_group_id);
4586 --hr_utility.trace('c_primary_flag :'||g_add_rec.primary_flag);
4587 --hr_utility.trace('c_style :'||g_add_rec.style);
4588 --hr_utility.trace('c_address_type :'||g_add_rec.address_type);
4589 --hr_utility.trace('c_date_from :'||g_add_rec.date_from);
4590 --hr_utility.trace('c_effective_date :'||l_effective_date);
4591 
4592     open csr_secondary_add (c_person_id          => g_add_rec.person_id
4593                  		   ,c_business_group_id  => g_add_rec.business_group_id
4594 		                   ,c_primary_flag       => g_add_rec.primary_flag
4595 		                   ,c_style				 => g_add_rec.style
4596 		                   ,c_address_type       => g_add_rec.address_type
4597   		                   ,c_date_from			 => g_add_rec.date_from
4598 		                   ,c_effective_date     => l_effective_date);
4599 
4600 		  fetch csr_secondary_add into l_cur_add_rec;
4601 
4602   if csr_secondary_add%notfound then
4603      hr_utility.set_location(' Secondary Address Not found', 40);
4604      hr_utility.set_location(' Person ID'||g_add_rec.person_id, 45);
4605      if (g_crt_upd = 'C') then
4606      Hrdpp_Create_Person_Address.Insert_Batch_Lines
4607     (p_batch_id                 => p_batch_id
4608     ,p_user_sequence            => p_user_sequence
4609     ,p_link_value               => p_link_value
4610     ,p_effective_date           => g_add_rec.date_from
4611     ,p_pradd_ovlapval_override  => l_pradd_ovlapval_override
4612     ,p_validate_county          => true
4613     ,p_primary_flag             => nvl(g_add_rec.primary_flag, 'Y')
4614     ,p_address_user_key         => p_address_user_key
4615     ,p_person_user_key          => p_person_user_key
4616     ,p_style                    => g_add_rec.style
4617     ,p_date_from                => g_add_rec.date_from
4618     ,p_date_to                  => g_add_rec.date_to
4619     ,p_address_type             => g_add_rec.address_type
4620     ,p_address_line1            => g_add_rec.address_line1
4621     ,p_address_line2            => g_add_rec.address_line2
4622     ,p_address_line3            => g_add_rec.address_line3
4623     ,p_town_or_city             => g_add_rec.town_or_city
4624     ,p_region_1                 => g_add_rec.region_1
4625     ,p_region_2                 => g_add_rec.region_2
4626     ,p_region_3                 => g_add_rec.region_3
4627     ,p_postal_code              => g_add_rec.postal_code
4628     ,p_telephone_number_1       => g_add_rec.telephone_number_1
4629     ,p_telephone_number_2       => g_add_rec.telephone_number_2
4630     ,p_telephone_number_3       => g_add_rec.telephone_number_3
4631     ,p_addr_attribute_category  => g_add_rec.addr_attribute_category
4632     ,p_addr_attribute1          => g_add_rec.addr_attribute1
4633     ,p_addr_attribute2          => g_add_rec.addr_attribute2
4634     ,p_addr_attribute3          => g_add_rec.addr_attribute3
4635     ,p_addr_attribute4          => g_add_rec.addr_attribute4
4636     ,p_addr_attribute5          => g_add_rec.addr_attribute5
4637     ,p_addr_attribute6          => g_add_rec.addr_attribute6
4638     ,p_addr_attribute7          => g_add_rec.addr_attribute7
4639     ,p_addr_attribute8          => g_add_rec.addr_attribute8
4640     ,p_addr_attribute9          => g_add_rec.addr_attribute9
4641     ,p_addr_attribute10         => g_add_rec.addr_attribute10
4642     ,p_addr_attribute11         => g_add_rec.addr_attribute11
4643     ,p_addr_attribute12         => g_add_rec.addr_attribute12
4644     ,p_addr_attribute13         => g_add_rec.addr_attribute13
4645     ,p_addr_attribute14         => g_add_rec.addr_attribute14
4646     ,p_addr_attribute15         => g_add_rec.addr_attribute15
4647     ,p_addr_attribute16         => g_add_rec.addr_attribute16
4648     ,p_addr_attribute17         => g_add_rec.addr_attribute17
4649     ,p_addr_attribute18         => g_add_rec.addr_attribute18
4650     ,p_addr_attribute19         => g_add_rec.addr_attribute19
4651     ,p_addr_attribute20         => g_add_rec.addr_attribute20
4652     ,p_add_information13        => g_add_rec.add_information13
4653     ,p_add_information14        => g_add_rec.add_information14
4654     ,p_add_information15        => g_add_rec.add_information15
4655     ,p_add_information16        => g_add_rec.add_information16
4656     ,p_add_information17        => g_add_rec.add_information17
4657     ,p_add_information18        => g_add_rec.add_information18
4658     ,p_add_information19        => g_add_rec.add_information19
4659     ,p_add_information20        => g_add_rec.add_information20
4660     ,p_party_id                 => g_add_rec.party_id
4661     ,p_country                  => g_add_rec.country
4662     );
4663     else
4664         raise e_crt_add_not_allowed;
4665     end if;
4666   else
4667      hr_utility.set_location(' Secondary Address found: ' ||
4668                                l_cur_add_rec.address_id, 50);
4669      if g_add_rec.date_from is null then
4670         g_add_rec.date_from := trunc(l_effective_date);
4671      end if;
4672 
4673         g_add_rec.address_id := l_cur_add_rec.address_id;
4674         g_add_rec.object_version_number := l_cur_add_rec.object_version_number;
4675         g_add_rec.style := l_cur_add_rec.style;
4676 
4677     --hr_utility.trace('$$_PSG InsUpd_Batch_Address N p_address_user_key: '||p_address_user_key);
4678 
4679      hr_pump_utils.add_user_key
4680      (p_user_key_value => p_address_user_key
4681      ,p_unique_key_id  => g_add_rec.address_id
4682       );
4683 
4684      hr_utility.set_location(' Hrdpp_Create_Person_Address.Insert_Batch_Lines: ' , 51);
4685      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
4686      HrDpp_Update_Person_Address.Insert_Batch_Lines
4687     (p_batch_id                 => p_batch_id
4688     ,p_user_sequence            => p_user_sequence
4689     ,p_link_value               => p_link_value
4690     --,p_data_pump_batch_line_id     => p_data_pump_batch_line_id
4691     --,p_data_pump_business_grp_name =>
4692     ,p_address_user_key         => p_address_user_key
4693     ,p_effective_date           => g_add_rec.date_from
4694     ,p_validate_county          => true
4695     ,p_date_from                => g_add_rec.date_from
4696     ,p_date_to                  => g_add_rec.date_to
4697     ,p_primary_flag             => nvl(g_add_rec.primary_flag, 'Y')
4698     ,p_address_type             => g_add_rec.address_type
4699     ,p_address_line1            => g_add_rec.address_line1
4700     ,p_address_line2            => g_add_rec.address_line2
4701     ,p_address_line3            => g_add_rec.address_line3
4702     ,p_town_or_city             => g_add_rec.town_or_city
4703     ,p_region_1                 => g_add_rec.region_1
4704     ,p_region_2                 => g_add_rec.region_2
4705     ,p_region_3                 => g_add_rec.region_3
4706     ,p_postal_code              => g_add_rec.postal_code
4707     ,p_telephone_number_1       => g_add_rec.telephone_number_1
4708     ,p_telephone_number_2       => g_add_rec.telephone_number_2
4709     ,p_telephone_number_3       => g_add_rec.telephone_number_3
4710     ,p_addr_attribute_category  => g_add_rec.addr_attribute_category
4711     ,p_addr_attribute1          => g_add_rec.addr_attribute1
4712     ,p_addr_attribute2          => g_add_rec.addr_attribute2
4713     ,p_addr_attribute3          => g_add_rec.addr_attribute3
4714     ,p_addr_attribute4          => g_add_rec.addr_attribute4
4715     ,p_addr_attribute5          => g_add_rec.addr_attribute5
4716     ,p_addr_attribute6          => g_add_rec.addr_attribute6
4717     ,p_addr_attribute7          => g_add_rec.addr_attribute7
4718     ,p_addr_attribute8          => g_add_rec.addr_attribute8
4719     ,p_addr_attribute9          => g_add_rec.addr_attribute9
4720     ,p_addr_attribute10         => g_add_rec.addr_attribute10
4721     ,p_addr_attribute11         => g_add_rec.addr_attribute11
4722     ,p_addr_attribute12         => g_add_rec.addr_attribute12
4723     ,p_addr_attribute13         => g_add_rec.addr_attribute13
4724     ,p_addr_attribute14         => g_add_rec.addr_attribute14
4725     ,p_addr_attribute15         => g_add_rec.addr_attribute15
4726     ,p_addr_attribute16         => g_add_rec.addr_attribute16
4727     ,p_addr_attribute17         => g_add_rec.addr_attribute17
4728     ,p_addr_attribute18         => g_add_rec.addr_attribute18
4729     ,p_addr_attribute19         => g_add_rec.addr_attribute19
4730     ,p_addr_attribute20         => g_add_rec.addr_attribute20
4731     ,p_party_id                 => g_add_rec.party_id
4732     ,p_country                  => g_add_rec.country
4733     );
4734      else
4735       raise e_upl_not_allowed;
4736      end if;
4737   end if;
4738     close csr_secondary_add;
4739  end if;
4740 
4741   hr_utility.set_location('Leaving: ' || l_proc_name, 60);
4742 
4743 exception
4744    when Others then
4745    if  csr_primary_add%isopen then
4746     close csr_primary_add;
4747    end if;
4748 
4749    if  csr_secondary_add%isopen then
4750     close csr_secondary_add;
4751    end if;
4752 
4753    --l_error_msg := Substr(SQLERRM,1,2000);
4754    hr_utility.set_location('SQLCODE :' || SQLCODE,90);
4755    hr_utility.set_location('SQLERRM :' || SQLERRM,90);
4756    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
4757    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
4758    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
4759    hr_utility.raise_error;
4760 
4761 end InsUpd_Batch_Address;
4762 
4763 -- =============================================================================
4764 -- ~ InsUpd_Address:
4765 -- =============================================================================
4766 -- Changed procedure
4767  procedure InsUpd_Address
4768           (p_effective_date           in date
4769           ,p_HR_address_id            out NOCOPY number
4770           ,p_HR_object_version_number out NOCOPY number ) as
4771 
4772 --  p_effective_date => g_per_rec.start_date => g_per_rec.start_date := trunc(p_date_of_hire);
4773 
4774   cursor csr_primary_add (c_person_id         in number
4775 		                 ,c_business_group_id in number
4776 		                 ,c_date_from		  in date
4777 		                 ,c_primary_flag      in varchar2) is
4778   select *
4779     from per_addresses pad
4780    where pad.person_id = c_person_id
4781      and pad.business_group_id = c_business_group_id
4782      and pad.primary_flag = c_primary_flag
4783      and c_date_from between pad.date_from
4784                               and NVL(pad.date_to, c_date_from);
4785 
4786   cursor csr_secondary_add (c_person_id          in number
4787                  		   ,c_business_group_id  in number
4788 		                   ,c_primary_flag       in varchar2
4789 		                   ,c_style				 in varchar2
4790 		                   ,c_address_type       in varchar2
4791 		                   ,c_date_from			 in date
4792 		                   ,c_effective_date     in date) is
4793   select *
4794     from per_addresses pad
4795    where pad.business_group_id = c_business_group_id
4796      and pad.person_id = c_person_id
4797      and pad.primary_flag = c_primary_flag
4798      and pad.STYLE = c_style
4799      and nvl(pad.ADDRESS_TYPE,0) = nvl(c_address_type,nvl(pad.ADDRESS_TYPE,0))
4800      and trunc(pad.date_from) = trunc(c_date_from);
4801 /*     and c_effective_date between pad.date_from
4802                               and NVL(pad.date_to, c_effective_date); */
4803 
4804   l_cur_add_rec            per_addresses%rowtype;
4805   l_proc_name  constant    varchar2(150):= g_pkg ||'InsUpd_Address';
4806   l_error_msg              varchar2(2000);
4807   l_party_id               per_people_f.party_id%type;
4808 
4809 
4810 begin
4811   hr_utility.set_location('Entering: ' || l_proc_name, 10);
4812 
4813   if g_add_rec.address_line1 is null and g_add_rec.style is null then
4814       return;
4815   end if;
4816 
4817 --hr_utility.trace('MSG_AD c_person_id='||g_add_rec.person_id);
4818 --hr_utility.trace('MSG_AD c_business_group_id='||g_add_rec.business_group_id);
4819 --hr_utility.trace('MSG_AD c_primary_flag='|| g_add_rec.primary_flag);
4820 --hr_utility.trace('MSG_AD c_effective_date='||p_effective_date);
4821 
4822 
4823  IF g_add_rec.primary_flag = 'Y' Then
4824 
4825   open  csr_primary_add(c_person_id         => g_add_rec.person_id
4826                ,c_business_group_id 		=> g_add_rec.business_group_id
4827                ,c_date_from			        => g_add_rec.date_from
4828                ,c_primary_flag      		=> g_add_rec.primary_flag);
4829   fetch csr_primary_add into l_cur_add_rec;
4830 
4831   if csr_primary_add%notfound then
4832      hr_utility.set_location(' Primary Address Not found', 20);
4833      hr_utility.set_location(' Person ID'||g_add_rec.person_id, 25);
4834 
4835 --hr_utility.trace('MSG_AD p_effective_date:'||p_effective_date);
4836 --hr_utility.trace('MSG_AD primary_flag:'||g_add_rec.primary_flag);
4837 --hr_utility.trace('MSG_AD address_id:'||g_add_rec.address_id);
4838 --hr_utility.trace('MSG_AD object_version_number:'||g_add_rec.object_version_number);
4839     if (g_crt_upd = 'C') then
4840      Pqp_Hrtca_Integration.Person_Address_Api
4841      (p_HR_Address_Rec           => g_add_rec
4842      ,p_validate                 => false
4843      ,p_action                   => 'CREATE'
4844      ,p_effective_date           => p_effective_date
4845      ,p_pradd_ovlapval_override  => false
4846      ,p_primary_flag             => NVL(g_add_rec.primary_flag,'Y') --'Y'
4847      ,p_validate_county          => true
4848      ,p_HR_address_id            => g_add_rec.address_id
4849      ,p_HR_object_version_number => g_add_rec.object_version_number
4850      );
4851     else
4852         raise e_crt_add_not_allowed;
4853     end if;
4854   else
4855      hr_utility.set_location(' Primary Address found: ' ||
4856                                l_cur_add_rec.address_id, 30);
4857 
4858      if g_add_rec.date_from is null then
4859         g_add_rec.date_from := trunc(p_effective_date);
4860      end if;
4861 
4862 --hr_utility.trace('MSG_AD p_effective_date:'||p_effective_date);
4863 --hr_utility.trace('MSG_AD primary_flag:'||g_add_rec.primary_flag);
4864 --hr_utility.trace('MSG_AD address_id:'||g_add_rec.address_id);
4865 --hr_utility.trace('MSG_AD object_version_number:'||g_add_rec.object_version_number);
4866 
4867 
4868 --hr_utility.trace('MSG_AD 11:'||p_effective_date);
4869 
4870         g_add_rec.address_id := l_cur_add_rec.address_id;
4871         g_add_rec.object_version_number := l_cur_add_rec.object_version_number;
4872         g_add_rec.style := l_cur_add_rec.style;
4873 
4874 --hr_utility.trace('MSG_AD 12:'||p_effective_date);
4875      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
4876        Pqp_Hrtca_Integration.Person_Address_Api
4877         (p_HR_Address_Rec           => g_add_rec
4878         ,p_validate                 => false
4879         ,p_action                   => 'UPDATE'
4880         ,p_effective_date           => trunc(g_add_rec.date_from)
4881         ,p_pradd_ovlapval_override  => false
4882         ,p_primary_flag             => g_add_rec.primary_flag -- 'Y'
4883         ,p_validate_county          => true
4884         ,p_HR_address_id            => g_add_rec.address_id
4885         ,p_HR_object_version_number => g_add_rec.object_version_number
4886         );
4887      else
4888         raise e_upl_not_allowed;
4889      end if;
4890 --hr_utility.trace('MSG_AD 13:'||p_effective_date);
4891 
4892   end if;
4893   close csr_primary_add;
4894 -- For Secondary Address
4895  ELSIF g_add_rec.primary_flag = 'N' Then
4896 
4897 --hr_utility.trace('Testing cursor');
4898 --hr_utility.trace('c_person_id :'||g_add_rec.person_id);
4899 --hr_utility.trace('c_business_group_id :'||g_add_rec.business_group_id);
4900 --hr_utility.trace('c_primary_flag :'||g_add_rec.primary_flag);
4901 --hr_utility.trace('c_style :'||g_add_rec.style);
4902 --hr_utility.trace('c_address_type :'||g_add_rec.address_type);
4903 --hr_utility.trace('c_date_from :'||g_add_rec.date_from);
4904 --hr_utility.trace('c_effective_date :'||p_effective_date);
4905 
4906     open csr_secondary_add (c_person_id          => g_add_rec.person_id
4907                  		   ,c_business_group_id  => g_add_rec.business_group_id
4908 		                   ,c_primary_flag       => g_add_rec.primary_flag
4909 		                   ,c_style				 => g_add_rec.style
4910 		                   ,c_address_type       => g_add_rec.address_type
4911   		                   ,c_date_from			 => g_add_rec.date_from
4912 		                   ,c_effective_date     => p_effective_date);
4913 
4914 		  fetch csr_secondary_add into l_cur_add_rec;
4915 
4916   if csr_secondary_add%notfound then
4917      hr_utility.set_location(' Secondary Address Not found', 40);
4918      hr_utility.set_location(' Person ID'||g_add_rec.person_id, 45);
4919     if (g_crt_upd = 'C') then
4920      Pqp_Hrtca_Integration.Person_Address_Api
4921      (p_HR_Address_Rec           => g_add_rec
4922      ,p_validate                 => false
4923      ,p_action                   => 'CREATE'
4924      ,p_effective_date           => p_effective_date
4925      ,p_pradd_ovlapval_override  => false
4926      ,p_primary_flag             => g_add_rec.primary_flag
4927      ,p_validate_county          => true
4928      ,p_HR_address_id            => g_add_rec.address_id
4929      ,p_HR_object_version_number => g_add_rec.object_version_number
4930      );
4931     else
4932         raise e_crt_add_not_allowed;
4933     end if;
4934   else
4935      hr_utility.set_location(' Secondary Address found: ' ||
4936                                l_cur_add_rec.address_id, 50);
4937      if g_add_rec.date_from is null then
4938         g_add_rec.date_from := trunc(p_effective_date);
4939      end if;
4940 
4941         g_add_rec.address_id := l_cur_add_rec.address_id;
4942         g_add_rec.object_version_number := l_cur_add_rec.object_version_number;
4943         g_add_rec.style := l_cur_add_rec.style;
4944        if (g_crt_upd = 'C' or g_crt_upd = 'U') then
4945         Pqp_Hrtca_Integration.Person_Address_Api
4946         (p_HR_Address_Rec           => g_add_rec
4947         ,p_validate                 => false
4948         ,p_action                   => 'UPDATE'
4949         ,p_effective_date           => trunc(g_add_rec.date_from)
4950         ,p_pradd_ovlapval_override  => false
4951         ,p_primary_flag             => g_add_rec.primary_flag -- 'N'
4952         ,p_validate_county          => true
4953         ,p_HR_address_id            => g_add_rec.address_id
4954         ,p_HR_object_version_number => g_add_rec.object_version_number
4955         );
4956         else
4957          raise e_upl_not_allowed;
4958         end if;
4959   end if;
4960     close csr_secondary_add;
4961  end if;
4962 
4963   hr_utility.set_location('Leaving: ' || l_proc_name, 60);
4964 
4965 exception
4966    when Others then
4967    if  csr_primary_add%isopen then
4968     close csr_primary_add;
4969    end if;
4970 
4971    if  csr_secondary_add%isopen then
4972     close csr_secondary_add;
4973    end if;
4974 
4975    --l_error_msg := Substr(SQLERRM,1,2000);
4976    hr_utility.set_location('SQLCODE :' || SQLCODE,90);
4977    hr_utility.set_location('SQLERRM :' || SQLERRM,90);
4978    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
4979    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
4980    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
4981    hr_utility.raise_error;
4982 
4983 end InsUpd_Address;
4984 -- =============================================================================
4985 -- ~ Upd_Person_Details:
4986 -- =============================================================================
4987 procedure Upd_Person_Details
4988          (p_validate            in boolean
4989          ,p_effective_date      in date
4990          ,p_person_id           number
4991          ,p_adjusted_svc_date   date       default null
4992          ,p_updper_api_out      out NOCOPY t_UpdEmp_Api
4993           ) as
4994 
4995   l_cur_per_rec            per_all_people_f%rowtype;
4996   l_per_rec                per_all_people_f%rowtype;
4997   l_ptu_rec                chk_perType_usage%rowtype;
4998   l_datetrack_update_mode  varchar2(50);
4999   l_dt_correction          boolean;
5000   l_dt_update              boolean;
5001   l_dt_upd_override        boolean;
5002   l_upd_chg_ins            boolean;
5003   e_future_chgs_exists     exception;
5004   l_error_msg              varchar2(3000);
5005   l_proc_name  constant    varchar2(150):= g_pkg ||'Upd_Person_Details';
5006 
5007 begin
5008   hr_utility.set_location('Entering: ' || l_proc_name, 10);
5009 
5010   l_per_rec := Get_PerRecord_Values(g_interface_code);
5011 
5012   open  csr_per(c_person_id         => g_per_rec.person_id
5013                ,c_business_group_id => g_per_rec.business_group_id
5014                ,c_effective_date    => p_effective_date);
5015   fetch csr_per into l_cur_per_rec;
5016   close csr_per;
5017 
5018   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
5019 
5020   Dt_Api.Find_DT_Upd_Modes
5021   (p_effective_date        => p_effective_date
5022   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
5023   ,p_base_key_column       => 'PERSON_ID'
5024   ,p_base_key_value        => l_cur_per_rec.person_id
5025   ,p_correction            => l_dt_correction
5026   ,p_update                => l_dt_update
5027   ,p_update_override       => l_dt_upd_override
5028   ,p_update_change_insert  => l_upd_chg_ins
5029    );
5030 
5031   if l_dt_update then
5032      l_datetrack_update_mode := 'UPDATE';
5033   elsif l_dt_upd_override or
5034         l_upd_chg_ins then
5035         -- Need to check if person type in future is EMP, APL or CWK , if yes
5036         -- then raise error
5037         open chk_perType_usage
5038            (c_person_id         => l_cur_per_rec.person_id
5039            ,c_effective_date    => p_effective_date
5040            ,c_business_group_id => g_per_rec.business_group_id);
5041         fetch chk_perType_usage into l_ptu_rec;
5042         if chk_perType_usage%found then
5043            close chk_perType_usage;
5044            raise e_future_chgs_exists;
5045         end if;
5046         --$ If no change in person type in future CORRECT the record
5047         l_datetrack_update_mode := 'CORRECTION';
5048         close chk_perType_usage;
5049   else
5050      l_datetrack_update_mode := 'CORRECTION';
5051   end if;
5052 
5053   hr_utility.set_location(' l_datetrack_update_mode: ' ||
5054                             l_datetrack_update_mode, 30);
5055   hr_utility.set_location(' employee_number: ' ||
5056                             l_cur_per_rec.employee_number, 30);
5057   hr_utility.set_location(' per ovn: ' ||
5058                             l_cur_per_rec.object_version_number, 30);
5059 
5060   -- Need to pass the employee number when updating the person
5061   g_per_rec.object_version_number := l_cur_per_rec.object_version_number;
5062   l_cur_per_rec.employee_number   := nvl(g_per_rec.employee_number,
5063                                          l_cur_per_rec.employee_number);
5064   Hr_Person_Api.Update_Person
5065   (p_validate                     => p_validate
5066   ,p_effective_date               => p_effective_date
5067   ,p_datetrack_update_mode        => l_datetrack_update_mode
5068   ,p_person_id                    => l_cur_per_rec.person_id
5069   ,p_party_id                     => nvl(g_per_rec.party_id,
5070                                          l_cur_per_rec.party_id)
5071   ,p_object_version_number        => l_cur_per_rec.object_version_number
5072   ,p_employee_number              => l_cur_per_rec.employee_number
5073   ,p_applicant_number             => nvl(g_per_rec.applicant_number,
5074                                          l_cur_per_rec.applicant_number)
5075   ,p_npw_number                   => nvl(g_per_rec.npw_number,
5076                                          l_cur_per_rec.npw_number)
5077   ,p_last_name                    => l_per_rec.last_name
5078   ,p_first_name                   => l_per_rec.first_name
5079   ,p_date_of_birth                => l_per_rec.date_of_birth
5080   ,p_marital_status               => l_per_rec.marital_status
5081   ,p_middle_names                 => l_per_rec.middle_names
5082   ,p_sex                          => l_per_rec.sex
5083   ,p_title                        => l_per_rec.title
5084   ,p_nationality                  => l_per_rec.nationality
5085   ,p_national_identifier          => l_per_rec.national_identifier
5086   ,p_previous_last_name           => l_per_rec.previous_last_name
5087   ,p_known_as                     => l_per_rec.known_as
5088   ,p_email_address                => l_per_rec.email_address
5089   ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
5090   ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
5091   ,p_expense_check_send_to_addres => l_per_rec.expense_check_send_to_address
5092   --Added by Dbansal
5093   ,p_comments                     => g_per_comments
5094    -- Person DDF
5095   ,p_per_information_category     => l_per_rec.per_information_category
5096   ,p_per_information1             => l_per_rec.per_information1
5097   ,p_per_information2             => l_per_rec.per_information2
5098   ,p_per_information3             => l_per_rec.per_information3
5099   ,p_per_information4             => l_per_rec.per_information4
5100   ,p_per_information5             => l_per_rec.per_information5
5101   ,p_per_information6             => l_per_rec.per_information6
5102   ,p_per_information7             => l_per_rec.per_information7
5103   ,p_per_information8             => l_per_rec.per_information8
5104   ,p_per_information9             => l_per_rec.per_information9
5105   ,p_per_information10            => l_per_rec.per_information10
5106   ,p_per_information11            => l_per_rec.per_information11
5107   ,p_per_information12            => l_per_rec.per_information12
5108   ,p_per_information13            => l_per_rec.per_information13
5109   ,p_per_information14            => l_per_rec.per_information14
5110   ,p_per_information15            => l_per_rec.per_information15
5111   ,p_per_information16            => l_per_rec.per_information16
5112   ,p_per_information17            => l_per_rec.per_information17
5113   ,p_per_information18            => l_per_rec.per_information18
5114   ,p_per_information19            => l_per_rec.per_information19
5115   ,p_per_information20            => l_per_rec.per_information20
5116   ,p_per_information21            => l_per_rec.per_information21
5117   ,p_per_information22            => l_per_rec.per_information22
5118   ,p_per_information23            => l_per_rec.per_information23
5119   ,p_per_information24            => l_per_rec.per_information24
5120   ,p_per_information25            => l_per_rec.per_information25
5121   ,p_per_information26            => l_per_rec.per_information26
5122   ,p_per_information27            => l_per_rec.per_information27
5123   ,p_per_information28            => l_per_rec.per_information28
5124   ,p_per_information29            => l_per_rec.per_information29
5125   ,p_per_information30            => l_per_rec.per_information30
5126   -- Person DF
5127   ,p_attribute_category           => l_per_rec.attribute_category
5128   ,p_attribute1                   => l_per_rec.attribute1
5129   ,p_attribute2                   => l_per_rec.attribute2
5130   ,p_attribute3                   => l_per_rec.attribute3
5131   ,p_attribute4                   => l_per_rec.attribute4
5132   ,p_attribute5                   => l_per_rec.attribute5
5133   ,p_attribute6                   => l_per_rec.attribute6
5134   ,p_attribute7                   => l_per_rec.attribute7
5135   ,p_attribute8                   => l_per_rec.attribute8
5136   ,p_attribute9                   => l_per_rec.attribute9
5137   ,p_attribute10                  => l_per_rec.attribute10
5138   ,p_attribute11                  => l_per_rec.attribute11
5139   ,p_attribute12                  => l_per_rec.attribute12
5140   ,p_attribute13                  => l_per_rec.attribute13
5141   ,p_attribute14                  => l_per_rec.attribute14
5142   ,p_attribute15                  => l_per_rec.attribute15
5143   ,p_attribute16                  => l_per_rec.attribute16
5144   ,p_attribute17                  => l_per_rec.attribute17
5145   ,p_attribute18                  => l_per_rec.attribute18
5146   ,p_attribute19                  => l_per_rec.attribute19
5147   ,p_attribute20                  => l_per_rec.attribute20
5148   ,p_attribute21                  => l_per_rec.attribute21
5149   ,p_attribute22                  => l_per_rec.attribute22
5150   ,p_attribute23                  => l_per_rec.attribute23
5151   ,p_attribute24                  => l_per_rec.attribute24
5152   ,p_attribute25                  => l_per_rec.attribute25
5153   ,p_attribute26                  => l_per_rec.attribute26
5154   ,p_attribute27                  => l_per_rec.attribute27
5155   ,p_attribute28                  => l_per_rec.attribute28
5156   ,p_attribute29                  => l_per_rec.attribute29
5157   ,p_attribute30                  => l_per_rec.attribute30
5158 
5159   ,p_date_of_death                => l_per_rec.date_of_death
5160   ,p_background_check_status      => l_per_rec.background_check_status
5161   ,p_background_date_check        => l_per_rec.background_date_check
5162   ,p_blood_type                   => l_per_rec.blood_type
5163   ,p_correspondence_language      => l_per_rec.correspondence_language
5164   ,p_fte_capacity                 => l_per_rec.fte_capacity
5165   ,p_hold_applicant_date_until    => l_per_rec.hold_applicant_date_until
5166   ,p_honors                       => l_per_rec.honors
5167   ,p_internal_location            => l_per_rec.internal_location
5168   ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
5169   ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
5170   ,p_mailstop                     => l_per_rec.mailstop
5171   ,p_office_number                => l_per_rec.office_number
5172   ,p_on_military_service          => l_per_rec.on_military_service
5173   ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
5174   ,p_projected_start_date         => l_per_rec.projected_start_date
5175   ,p_rehire_authorizor            => l_per_rec.rehire_authorizor
5176   ,p_rehire_recommendation        => l_per_rec.rehire_recommendation
5177   ,p_resume_exists                => l_per_rec.resume_exists
5178   ,p_resume_last_updated          => l_per_rec.resume_last_updated
5179   ,p_second_passport_exists       => l_per_rec.second_passport_exists
5180   ,p_student_status               => l_per_rec.student_status
5181   ,p_work_schedule                => l_per_rec.work_schedule
5182   ,p_rehire_reason                => l_per_rec.rehire_reason
5183   ,p_suffix                       => l_per_rec.suffix
5184   ,p_benefit_group_id             => l_per_rec.benefit_group_id
5185   ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
5186   ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
5187   ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
5188   ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
5189   ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
5190   ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
5191   ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
5192   ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
5193   ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
5194   ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
5195   ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
5196   ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
5197   ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
5198   ,p_town_of_birth                => l_per_rec.town_of_birth
5199   ,p_region_of_birth              => l_per_rec.region_of_birth
5200   ,p_country_of_birth             => l_per_rec.country_of_birth
5201   ,p_global_person_id             => l_per_rec.global_person_id
5202    -- Out Variables
5203   ,p_effective_start_date         => p_updper_api_out.effective_start_date
5204   ,p_effective_end_date           => p_updper_api_out.effective_end_date
5205   ,p_full_name                    => p_updper_api_out.full_name
5206   ,p_comment_id                   => p_updper_api_out.comment_id
5207   ,p_name_combination_warning     => p_updper_api_out.name_combination_warning
5208   ,p_assign_payroll_warning       => p_updper_api_out.assign_payroll_warning
5209   ,p_orig_hire_warning            => p_updper_api_out.orig_hire_warning
5210   ,p_adjusted_svc_date            => p_adjusted_svc_date --Uncommented by pkagrawa
5211   );
5212 
5213   if g_debug then
5214     hr_utility.set_location('..effective_start_date : ' ||
5215                              p_updper_api_out.effective_start_date,40);
5216     hr_utility.set_location('..effective_end_date   : ' ||
5217                              p_updper_api_out.effective_end_date,40);
5218     hr_utility.set_location('..full_name            : ' ||
5219                              p_updper_api_out.full_name,40);
5220     hr_utility.set_location('Leaving: ' || l_proc_name, 40);
5221   end if;
5222 
5223 exception
5224   when e_future_chgs_exists then
5225     l_error_msg := 'This person cannot be created in HRMS as a Student '||
5226                    'Employee due to future changes beyond the date: '||p_effective_date;
5227 
5228     hr_utility.set_location('..Future Update exists for the Student Employee', 60);
5229     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
5230     hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
5231     hr_utility.set_location('Leaving: ' || l_proc_name, 60);
5232     hr_utility.raise_error;
5233 
5234   when Others then
5235   hr_utility.set_location('SQLERRM :' || SQLCODE,90);
5236   hr_utility.set_location('Leaving: ' || l_proc_name, 90);
5237   raise;
5238 
5239 end Upd_Person_Details;
5240 -- =============================================================================
5241 -- ~ Hire_Applicant_IntoEmp:
5242 -- =============================================================================
5243 procedure Hire_Applicant_IntoEmp
5244          (p_validate            boolean  default false
5245          ,p_hire_date           date
5246          ,p_person_id           number
5247          ,p_assignment_id       number
5248          ,p_adjusted_svc_date   date     default null
5249          ,p_updper_api_out      out NOCOPY t_UpdEmp_Api
5250          ,p_HireAppapi_out      out NOCOPY t_HrApp_Api
5251          ) as
5252 
5253   cursor csr_asg (c_person_id in number
5254                  ,c_business_group_id in number
5255                  ,c_effective_date in date
5256                  ,c_asg_type in varchar2
5257                  ,c_assignment_id in number) is
5258   select paf.assignment_id
5259         ,ppf.person_id
5260         ,ppf.object_version_number per_ovn
5261         ,paf.object_version_number asg_ovn
5262 	,paf.effective_start_date -- For Hiring an applicant on the next day
5263     from per_all_assignments_f paf
5264         ,per_all_people_f      ppf
5265    where paf.person_id = c_person_id
5266      and paf.business_group_id = c_business_group_id
5267      and paf.assignment_type = c_asg_type
5268      and paf.assignment_id = c_assignment_id
5269      and paf.person_id = ppf.person_id
5270      and c_effective_date between ppf.effective_start_date
5271                               and ppf.effective_end_date
5272      and c_effective_date between paf.effective_start_date
5273                               and paf.effective_end_date;
5274 
5275    cursor diff_date (date1 in date
5276          	     ,date2 in date) is
5277    select date1-date2      from dual;
5278 
5279   l_UpdEmp_Api             t_UpdEmp_Api;
5280   l_perasg_rec             csr_asg%rowtype;
5281   l_cur_per_rec            csr_per%rowtype;
5282   l_accpetd_asg_rec        csr_accepted_asgs%rowtype;
5283   l_asg_status_rec         csr_asg_status%rowtype;
5284   l_datetrack_update_mode  varchar2(50);
5285   l_dt_correction          boolean;
5286   l_dt_update              boolean;
5287   l_dt_upd_override        boolean;
5288   l_upd_chg_ins            boolean;
5289   l_error_msg              varchar2(2000);
5290   l_proc_name  constant    varchar2(150):= g_pkg ||'Hire_Applicant_IntoEmp';
5291   l_assignment_id          number;
5292   l_appl_asg_start_date    date;
5293   l_appl_asg_end_date      date;
5294   l_accp_asg_count         number;
5295   l_hire_all_accepted_asgs varchar2(3);
5296   l_not_accp_asg_count     number;
5297   l_tot_appl_asgs          number;
5298   l_effective_date         date;
5299   l_unaccepted_asg_del_warning boolean;
5300   l_diff_date		   number; -- For Hiring applicant on the next day.
5301 
5302 begin
5303   hr_utility.set_location('Entering: ' || l_proc_name, 10);
5304 
5305   g_debug := hr_utility.debug_enabled;
5306   l_effective_date := p_hire_date;
5307 
5308   -- Get the person details for the person
5309   open  csr_per(c_person_id         => g_per_rec.person_id
5310                ,c_business_group_id => g_per_rec.business_group_id
5311                ,c_effective_date    => l_effective_date);
5312   fetch csr_per into l_cur_per_rec;
5313   close csr_per;
5314   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
5315 
5316   -- Get the Applicant assignment details
5317   open  csr_asg (c_person_id         => g_per_rec.person_id
5318                 ,c_business_group_id => g_per_rec.business_group_id
5319                 ,c_effective_date    => l_effective_date
5320                 ,c_asg_type          => 'A'
5321                 ,c_assignment_id     => p_assignment_id);
5322   fetch csr_asg into l_perasg_rec;
5323   close csr_asg;
5324 
5325   if g_debug then
5326    hr_utility.set_location(' l_perasg_rec.person_id: ' ||
5327                              l_perasg_rec.person_id, 30);
5328    hr_utility.set_location(' l_perasg_rec.asg_id: ' ||
5329                              l_perasg_rec.assignment_id, 30);
5330    hr_utility.set_location(' l_perasg_rec.person_ovn: ' ||
5331                              l_perasg_rec.per_ovn, 30);
5332    hr_utility.set_location(' l_perasg_rec.asg_ovn: ' ||
5333                              l_perasg_rec.asg_ovn, 30);
5334    hr_utility.set_location(' l_effective_date: ' ||
5335                              l_effective_date, 30);
5336   end if;
5337   l_accp_asg_count := 0;
5338   for accp_ags in csr_accepted_asgs
5339                  (c_person_id         => g_per_rec.person_id
5340                  ,c_business_group_id => g_per_rec.business_group_id
5341                  ,c_effective_date    => l_effective_date
5342                  ,c_assignment_id     => p_assignment_id)
5343   loop
5344     l_accp_asg_count := l_accp_asg_count + 1;
5345   end loop;
5346 
5347   open diff_date (date1 =>l_effective_date
5348 		  ,date2 => l_perasg_rec.effective_start_date);
5349   fetch diff_date into l_diff_date;
5350 
5351   hr_utility.set_location(' l_diff_date: ' || l_diff_date, 40);
5352 
5353   if l_accp_asg_count < 1 then
5354     -- Means the Applicant Assignment is not accepted, so update the applicant
5355     -- as accepted as of the hire date.
5356     hr_utility.set_location(' Asg Id NOT Accepted : ' || p_assignment_id, 40);
5357         if l_diff_date = 1 then  -- Means The Applicant Assignment is to be corrected to
5358     Dt_Api.Find_DT_Upd_Modes -- Accepted.
5359     (p_effective_date        => l_perasg_rec.effective_start_date
5360     ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
5361     ,p_base_key_column       => 'ASSIGNMENT_ID'
5362     ,p_base_key_value        => p_assignment_id
5363     ,p_correction            => l_dt_correction
5364     ,p_update                => l_dt_update
5365     ,p_update_override       => l_dt_upd_override
5366     ,p_update_change_insert  => l_upd_chg_ins
5367      );
5368     else
5369     Dt_Api.Find_DT_Upd_Modes
5370     (p_effective_date        => p_hire_date
5371     ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
5372     ,p_base_key_column       => 'ASSIGNMENT_ID'
5373     ,p_base_key_value        => p_assignment_id
5374     ,p_correction            => l_dt_correction
5375     ,p_update                => l_dt_update
5376     ,p_update_override       => l_dt_upd_override
5377     ,p_update_change_insert  => l_upd_chg_ins
5378      );
5379      end if;
5380 
5381     -- Get the date-track mode
5382     if l_dt_update then
5383        l_datetrack_update_mode := 'UPDATE';
5384     elsif l_dt_upd_override or
5385           l_upd_chg_ins then
5386           -- Need to check if person has future asgs changes, if yes
5387           -- then raise error
5388           l_datetrack_update_mode := 'CORRECTION';
5389     else
5390        l_datetrack_update_mode := 'CORRECTION';
5391     end if;
5392     hr_utility.set_location(' DT Mode for Update of Appl Asg : ' ||
5393                               l_datetrack_update_mode, 50);
5394 
5395     -- Get the Accepted Applicant Status Id
5396     open csr_asg_status (c_leg_code          => g_leg_code
5397                         ,c_business_group_id => g_per_rec.business_group_id
5398                         );
5399     fetch csr_asg_status into l_asg_status_rec;
5400     close csr_asg_status;
5401     hr_utility.set_location(' Accepted Asg Status ID: ' ||
5402                               l_asg_status_rec.assignment_status_type_id, 60);
5403 
5404     -- Now accept the Applicant assigment used to hire the person
5405     HR_Assignment_API.Accept_APL_Asg
5406     (p_validate                    => false
5407     ,p_effective_date              => l_effective_date-1
5408     ,p_datetrack_update_mode       => l_datetrack_update_mode
5409     ,p_assignment_id               => p_assignment_id
5410     ,p_object_version_number       => l_perasg_rec.asg_ovn
5411     ,p_assignment_status_type_id   => l_asg_status_rec.assignment_status_type_id
5412     ,p_change_reason               => null
5413     ,p_effective_start_date        => l_appl_asg_start_date
5414     ,p_effective_end_date          => l_appl_asg_end_date
5415     );
5416     if g_debug then
5417      hr_utility.set_location(' l_appl_asg_start_date: ' ||
5418                                l_appl_asg_start_date, 70);
5419      hr_utility.set_location(' l_appl_asg_end_date: ' ||
5420                                l_appl_asg_end_date, 70);
5421      hr_utility.set_location(' l_perasg_rec.asg_ovn: ' ||
5422                                l_perasg_rec.asg_ovn, 70);
5423     end if;
5424 
5425     -- Get again the person details for the person
5426     open  csr_per(c_person_id         => g_per_rec.person_id
5427                  ,c_business_group_id => g_per_rec.business_group_id
5428                  ,c_effective_date    => l_effective_date);
5429     fetch csr_per into l_cur_per_rec;
5430     close csr_per;
5431     hr_utility.set_location(' per_rec.ovn: ' ||
5432                               l_cur_per_rec.object_version_number, 80);
5433   else
5434     hr_utility.set_location(' Asg Id Accepted Already: ' ||
5435                               p_assignment_id, 90);
5436   end if;
5437 
5438   -- Get the count of accepted Applicant Assignments
5439   l_accp_asg_count := 0;
5440   for accp_ags in csr_accepted_asgs
5441                  (c_person_id         => g_per_rec.person_id
5442                  ,c_business_group_id => g_per_rec.business_group_id
5443                  ,c_effective_date    => l_effective_date
5444                  ,c_assignment_id     => null)
5445   loop
5446     l_accp_asg_count := l_accp_asg_count +1;
5447   end loop;
5448 
5449   -- Get the count of not accepted Applicant Assignments
5450   l_not_accp_asg_count := 0;
5451   for accp_ags in csr_not_accepted_asgs
5452                  (c_person_id         => g_per_rec.person_id
5453                  ,c_business_group_id => g_per_rec.business_group_id
5454                  ,c_effective_date    => l_effective_date
5455                  ,c_assignment_id     => null)
5456   loop
5457     l_not_accp_asg_count := l_not_accp_asg_count +1;
5458   end loop;
5459   -- Get the total no. of Applicant assignments
5460   l_tot_appl_asgs := l_accp_asg_count + l_not_accp_asg_count;
5461 
5462   if l_tot_appl_asgs = 1 then
5463      l_hire_all_accepted_asgs := 'Y';
5464   elsif l_tot_appl_asgs > 2 then
5465      l_hire_all_accepted_asgs := 'N';
5466   end if;
5467 
5468   -- Now get the date-track mode to update the person as an employee
5469   Dt_Api.Find_DT_Upd_Modes
5470   (p_effective_date        => l_effective_date
5471   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
5472   ,p_base_key_column       => 'PERSON_ID'
5473   ,p_base_key_value        => l_cur_per_rec.person_id
5474   ,p_correction            => l_dt_correction
5475   ,p_update                => l_dt_update
5476   ,p_update_override       => l_dt_upd_override
5477   ,p_update_change_insert  => l_upd_chg_ins
5478    );
5479 
5480   -- If person has future changes, like becomes CWK, APL i.e. any person
5481   -- type changes then raise an error, saying that the person has future
5482   -- dated changes.
5483   if l_dt_update then
5484      l_datetrack_update_mode := 'UPDATE';
5485   elsif l_dt_upd_override or
5486         l_upd_chg_ins then
5487         -- Need to check if person type in future is EMP, APL or CWK , if yes
5488         -- then raise error
5489         l_datetrack_update_mode := 'CORRECTION';
5490   else
5491      l_datetrack_update_mode := 'CORRECTION';
5492   end if;
5493 
5494   hr_utility.set_location(' l_datetrack_update_mode: ' ||
5495                             l_datetrack_update_mode, 100);
5496   g_per_rec.object_version_number := l_cur_per_rec.object_version_number;
5497   if l_tot_appl_asgs = 1 then
5498      -- As the person has only one applicant assignment then hire person so that
5499      -- the person type now becomes EMP
5500      HR_Applicant_API.Hire_Applicant
5501      (p_validate                   => false
5502      ,p_hire_date                  => l_effective_date
5503      ,p_person_id                  => l_cur_per_rec.person_id
5504      ,p_assignment_id              => p_assignment_id
5505      ,p_person_type_id             => g_per_rec.person_type_id
5506      ,p_per_object_version_number  => l_cur_per_rec.object_version_number
5507      ,p_employee_number            => g_per_rec.employee_number
5508      ,p_per_effective_start_date   => p_HireAppapi_out.effective_start_date
5509      ,p_per_effective_end_date     => p_HireAppapi_out.effective_end_date
5510      ,p_unaccepted_asg_del_warning => l_unaccepted_asg_del_warning
5511      ,p_assign_payroll_warning     => p_HireAppapi_out.assign_payroll_warning
5512      ,p_original_date_of_hire      => g_per_rec.original_date_of_hire
5513      ,p_migrate                    => true
5514      );
5515   else
5516      -- Now hire the person ONLY for the accepted applicant assignment, so that
5517      -- person type would be EMP_APL
5518      HR_Employee_Applicant_API.Hire_to_Employee_Applicant
5519      (p_validate                   => false
5520      ,p_hire_date                  => l_effective_date
5521      ,p_person_id                  => l_cur_per_rec.person_id
5522      ,p_per_object_version_number  => l_cur_per_rec.object_version_number
5523      ,p_person_type_id             => g_per_rec.person_type_id
5524      ,p_hire_all_accepted_asgs     => l_hire_all_accepted_asgs
5525      ,p_assignment_id              => p_assignment_id
5526      ,p_national_identifier        => g_per_rec.national_identifier
5527      ,p_employee_number            => g_per_rec.employee_number
5528      ,p_per_effective_start_date   => p_HireAppapi_out.effective_start_date
5529      ,p_per_effective_end_date     => p_HireAppapi_out.effective_end_date
5530      ,p_assign_payroll_warning     => p_HireAppapi_out.assign_payroll_warning
5531      ,p_oversubscribed_vacancy_id  => p_HireAppapi_out.oversubscribed_vacancy_id
5532      );
5533   end if;
5534 
5535   -- Get the new employee assignment created after the person is hired
5536   open  csr_asg (c_person_id         => l_cur_per_rec.person_id
5537                 ,c_business_group_id => g_per_rec.business_group_id
5538                 ,c_effective_date    => p_HireAppapi_out.effective_start_date
5539                 ,c_asg_type          => 'E'
5540                 ,c_assignment_id     => p_assignment_id);
5541   fetch csr_asg into l_perasg_rec;
5542   close csr_asg;
5543   g_per_rec.object_version_number := l_perasg_rec.per_ovn;
5544 
5545   -- Get the person record after he is hired
5546   open  csr_per(c_person_id         => g_per_rec.person_id
5547                ,c_business_group_id => g_per_rec.business_group_id
5548                ,c_effective_date    => l_effective_date);
5549   fetch csr_per into l_cur_per_rec;
5550   close csr_per;
5551 
5552   if g_debug then
5553     hr_utility.set_location('..effective_start_date      : ' ||
5554                              p_HireAppapi_out.effective_start_date, 110);
5555     hr_utility.set_location('..effective_end_date        : ' ||
5556                              p_HireAppapi_out.effective_end_date, 110);
5557     hr_utility.set_location('..Old:object_version_number : ' ||
5558                              l_cur_per_rec.object_version_number, 110);
5559   end if;
5560   l_datetrack_update_mode := 'CORRECTION';
5561   --
5562   -- Update the person with the rest of the person details, if any passed.
5563   --
5564   Upd_Person_Details
5565   (p_validate            => p_validate
5566   ,p_effective_date      => p_hire_date
5567   ,p_person_id           => l_cur_per_rec.person_id
5568 --        ,p_adjusted_svc_date   => null  --Commented by pkagrawa
5569   ,p_adjusted_svc_date   => p_adjusted_svc_date -- Added by pkagrawa
5570   ,p_updper_api_out      => l_UpdEmp_Api
5571   );
5572   if g_debug then
5573     hr_utility.set_location('..effective_start_date : ' ||
5574                              p_updper_api_out.effective_start_date, 120);
5575     hr_utility.set_location('..effective_end_date   : ' ||
5576                              p_updper_api_out.effective_end_date, 120);
5577     hr_utility.set_location('..full_name            : ' ||
5578                              p_updper_api_out.full_name, 120);
5579     hr_utility.set_location('Leaving: ' || l_proc_name, 120);
5580   end if;
5581 
5582      --
5583      -- Address record
5584      --
5585      g_add_rec.person_id             :=  l_cur_per_rec.person_id;
5586      g_add_rec.date_from             :=  l_cur_per_rec.start_date;
5587      g_add_rec.date_to               := null;
5588 
5589 exception
5590   when Others then
5591     if csr_asg%isopen then
5592       close csr_asg;
5593     end if;
5594     if csr_per%isopen then
5595       close csr_per;
5596     end if;
5597     if csr_asg_status%isopen then
5598       close csr_asg_status;
5599     end if;
5600     --l_error_msg := Substr(SQLERRM,1,2000);
5601     hr_utility.set_location('SQLCODE :' || SQLCODE, 130);
5602     --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
5603     --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
5604     hr_utility.set_location('Leaving: ' || l_proc_name, 130);
5605     hr_utility.raise_error;
5606 
5607 end Hire_Applicant_IntoEmp;
5608 
5609 -- =============================================================================
5610 -- ~ Hire_Person_IntoEmp:
5611 -- =============================================================================
5612 procedure Hire_Person_IntoEmp
5613          (p_validate            boolean  default false
5614          ,p_hire_date           date
5615          ,p_person_id           number
5616          ,p_adjusted_svc_date   date     default null
5617          ,p_updper_api_out      out NOCOPY t_UpdEmp_Api
5618          ,p_HireToJobapi_out    out NOCOPY t_HrToJob_Api
5619          ) as
5620   cursor csr_asg (c_person_id in number
5621                  ,c_business_group_id in number
5622                  ,c_effective_date in date) is
5623   select paf.assignment_id,
5624          ppf.object_version_number
5625     from per_all_assignments_f paf
5626         ,per_all_people_f      ppf
5627    where paf.person_id         = c_person_id
5628      and paf.business_group_id = c_business_group_id
5629      and paf.person_id         = ppf.person_id
5630      and c_effective_date between ppf.effective_start_date
5631                               and ppf.effective_end_date
5632      and c_effective_date between paf.effective_start_date
5633                               and paf.effective_end_date;
5634   l_UpdEmp_Api             t_UpdEmp_Api;
5635   l_cur_per_rec            csr_per%rowtype;
5636   l_ptu_rec                chk_perType_usage%rowtype;
5637   l_datetrack_update_mode  varchar2(50);
5638   l_dt_correction          boolean;
5639   l_dt_update              boolean;
5640   l_dt_upd_override        boolean;
5641   l_upd_chg_ins            boolean;
5642   l_error_msg              varchar2(2000);
5643   l_proc_name  constant    varchar2(150):= g_pkg ||'Hire_Person_IntoEmp';
5644   e_future_chgs_exists     exception;
5645 begin
5646   hr_utility.set_location('Entering: ' || l_proc_name, 10);
5647 
5648   open  csr_per(c_person_id         => g_per_rec.person_id
5649                ,c_business_group_id => g_per_rec.business_group_id
5650                ,c_effective_date    => p_hire_date);
5651   fetch csr_per into l_cur_per_rec;
5652   close csr_per;
5653   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
5654 
5655   Dt_Api.Find_DT_Upd_Modes
5656   (p_effective_date        => p_hire_date
5657   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
5658   ,p_base_key_column       => 'PERSON_ID'
5659   ,p_base_key_value        => l_cur_per_rec.person_id
5660   ,p_correction            => l_dt_correction
5661   ,p_update                => l_dt_update
5662   ,p_update_override       => l_dt_upd_override
5663   ,p_update_change_insert  => l_upd_chg_ins
5664    );
5665 
5666   if l_dt_update then
5667      l_datetrack_update_mode := 'UPDATE';
5668   elsif l_dt_upd_override or
5669         l_upd_chg_ins then
5670         -- Need to check if person type in future is EMP, APL or CWK , if yes
5671         -- then raise error
5672         open chk_perType_usage
5673            (c_person_id         => l_cur_per_rec.person_id
5674            ,c_effective_date    => p_hire_date
5675            ,c_business_group_id => g_per_rec.business_group_id);
5676 
5677         fetch chk_perType_usage into l_ptu_rec;
5678         if chk_perType_usage%found then
5679            close chk_perType_usage;
5680            raise e_future_chgs_exists;
5681         end if;
5682         close chk_perType_usage;
5683         --Else USE Correction Mode
5684         l_datetrack_update_mode := 'CORRECTION';
5685   else
5686      l_datetrack_update_mode := 'CORRECTION';
5687   end if;
5688 
5689   hr_utility.set_location('l_datetrack_update_mode: ' ||
5690                            l_datetrack_update_mode, 30);
5691   g_per_rec.object_version_number := l_cur_per_rec.object_version_number;
5692 
5693   Hr_Employee_Api.Hire_Into_Job
5694   (p_validate               => false
5695   ,p_effective_date         => p_hire_date
5696   ,p_person_id              => l_cur_per_rec.person_id
5697   ,p_object_version_number  => l_cur_per_rec.object_version_number
5698   ,p_employee_number        => g_per_rec.employee_number
5699   ,p_datetrack_update_mode  => l_datetrack_update_mode
5700   ,p_person_type_id         => g_per_rec.person_type_id
5701   ,p_national_identifier    => g_per_rec.national_identifier
5702   ,p_per_information7       => g_per_rec.per_information7
5703    -- Out Variables
5704   ,p_effective_start_date   => p_HireToJobapi_out.effective_start_date
5705   ,p_effective_end_date     => p_HireToJobapi_out.effective_end_date
5706   ,p_assign_payroll_warning => p_HireToJobapi_out.assign_payroll_warning
5707   ,p_orig_hire_warning      => p_HireToJobapi_out.orig_hire_warning
5708   );
5709   -- Get the new assignment created after the person is hired
5710   open  csr_asg (c_person_id         => l_cur_per_rec.person_id
5711                 ,c_business_group_id => g_per_rec.business_group_id
5712                 ,c_effective_date    => p_HireToJobapi_out.effective_start_date);
5713   fetch csr_asg into p_HireToJobapi_out.assignment_id
5714                     ,g_per_rec.object_version_number;
5715   close csr_asg;
5716   -- Get the person record after he is hired
5717   open  csr_per(c_person_id         => g_per_rec.person_id
5718                ,c_business_group_id => g_per_rec.business_group_id
5719                ,c_effective_date    => p_hire_date);
5720   fetch csr_per into l_cur_per_rec;
5721   close csr_per;
5722 
5723   if g_debug then
5724     hr_utility.set_location('..effective_start_date      : ' ||
5725                              p_HireToJobapi_out.effective_start_date,40);
5726     hr_utility.set_location('..effective_end_date        : ' ||
5727                              p_HireToJobapi_out.effective_end_date,40);
5728     hr_utility.set_location('..New:object_version_number : ' ||
5729                              g_per_rec.object_version_number,40);
5730     hr_utility.set_location('..Old:object_version_number : ' ||
5731                              l_cur_per_rec.object_version_number,40);
5732     hr_utility.set_location('..New:Assignment Id         : ' ||
5733                              p_HireToJobapi_out.assignment_id,40);
5734   end if;
5735   l_datetrack_update_mode := 'CORRECTION';
5736 
5737   Upd_Person_Details
5738   (p_validate            => p_validate
5739   ,p_effective_date      => p_hire_date
5740   ,p_person_id           => l_cur_per_rec.person_id
5741   ,p_adjusted_svc_date   => null
5742   ,p_updper_api_out      => l_UpdEmp_Api
5743   );
5744   if g_debug then
5745     hr_utility.set_location('..effective_start_date : ' ||
5746                              p_updper_api_out.effective_start_date, 50);
5747     hr_utility.set_location('..effective_end_date   : ' ||
5748                              p_updper_api_out.effective_end_date, 50);
5749     hr_utility.set_location('..full_name            : ' ||
5750                              p_updper_api_out.full_name, 50);
5751     hr_utility.set_location('Leaving: ' || l_proc_name, 50);
5752   end if;
5753 
5754 exception
5755   when e_future_chgs_exists then
5756     l_error_msg := 'This person cannot be created/updated in HRMS as the '||
5757                    'Person has future changes beyond the date: '||p_hire_date;
5758 
5759     hr_utility.set_location('..Future Update exists for the Student Employee', 60);
5760     hr_utility.set_message(8303, 'PQP_230491_RIW_PER_NOT_CREATED');
5761     hr_utility.set_message_token('TOKEN',p_hire_date );
5762     hr_utility.set_location('Leaving: ' || l_proc_name, 60);
5763     hr_utility.raise_error;
5764 
5765   when Others then
5766    if csr_asg%isopen then
5767      close csr_asg;
5768    end if;
5769    if csr_per%isopen then
5770      close csr_per;
5771    end if;
5772    --l_error_msg := Substr(SQLERRM,1,2000);
5773    hr_utility.set_location('SQLCODE :' || SQLCODE,90);
5774    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
5775    --hr_utility.set_message_token('GENERIC_TOKEN',substr(l_error_msg,1,50) );
5776    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
5777    hr_utility.raise_error;
5778 
5779 end Hire_Person_IntoEmp;
5780 
5781 -- =============================================================================
5782 -- ~ InsUpd_Employee:
5783 -- =============================================================================
5784 procedure InsUpd_Employee
5785          (p_validate            boolean  default false
5786          ,p_action_mode         varchar2 default null
5787          ,p_effective_date      date
5788          ,p_adjusted_svc_date   date     default null
5789          ,p_per_comments        varchar2 default null
5790          ,p_emp_api_out         out nocopy t_hrEmpApi) as
5791 
5792   l_HireToJobapi_out   t_HrToJob_Api;
5793   l_updper_api_out     t_UpdEmp_Api;
5794 
5795   l_proc_name constant varchar2(150):= g_pkg ||'InsUpd_Employee';
5796 
5797 begin
5798   hr_utility.set_location('Entering: ' || l_proc_name, 10);
5799 
5800   if p_action_mode = 'CREATE_EMPLOYEE' then
5801 
5802    --hr_utility.trace('Before Call to Hr_Employee_Api.Create_Employee:');
5803    --hr_utility.trace('p_employee_number=>'|| g_per_rec.employee_number);
5804    --hr_utility.trace('p_assignment_number=>'|| g_asg_rec.assignment_number);
5805 
5806 
5807      Hr_Employee_Api.Create_Employee
5808      (p_validate                     => p_validate
5809      ,p_hire_date                    => g_per_rec.start_date
5810      ,p_business_group_id            => g_per_rec.business_group_id
5811      ,p_last_name                    => g_per_rec.last_name
5812      ,p_sex                          => g_per_rec.sex
5813      ,p_person_type_id               => g_per_rec.person_type_id
5814      ,p_per_comments                 => p_per_comments
5815      ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
5816      ,p_date_of_birth                => g_per_rec.date_of_birth
5817      ,p_email_address                => g_per_rec.email_address
5818      ,p_employee_number              => g_per_rec.employee_number
5819      ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
5820      ,p_first_name                   => g_per_rec.first_name
5821      ,p_known_as                     => g_per_rec.known_as
5822      ,p_marital_status               => g_per_rec.marital_status
5823      ,p_middle_names                 => g_per_rec.middle_names
5824      ,p_nationality                  => g_per_rec.nationality
5825      ,p_national_identifier          => g_per_rec.national_identifier
5826      ,p_previous_last_name           => g_per_rec.previous_last_name
5827      ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
5828      ,p_title                        => g_per_rec.title
5829      ,p_vendor_id                    => g_per_rec.vendor_id
5830      -- DF
5831      ,p_attribute_category           => g_per_rec.attribute_category
5832      ,p_attribute1                   => g_per_rec.attribute1
5833      ,p_attribute2                   => g_per_rec.attribute2
5834      ,p_attribute3                   => g_per_rec.attribute3
5835      ,p_attribute4                   => g_per_rec.attribute4
5836      ,p_attribute5                   => g_per_rec.attribute5
5837      ,p_attribute6                   => g_per_rec.attribute6
5838      ,p_attribute7                   => g_per_rec.attribute7
5839      ,p_attribute8                   => g_per_rec.attribute8
5840      ,p_attribute9                   => g_per_rec.attribute9
5841      ,p_attribute10                  => g_per_rec.attribute10
5842      ,p_attribute11                  => g_per_rec.attribute11
5843      ,p_attribute12                  => g_per_rec.attribute12
5844      ,p_attribute13                  => g_per_rec.attribute13
5845      ,p_attribute14                  => g_per_rec.attribute14
5846      ,p_attribute15                  => g_per_rec.attribute15
5847      ,p_attribute16                  => g_per_rec.attribute16
5848      ,p_attribute17                  => g_per_rec.attribute17
5849      ,p_attribute18                  => g_per_rec.attribute18
5850      ,p_attribute19                  => g_per_rec.attribute19
5851      ,p_attribute20                  => g_per_rec.attribute20
5852      ,p_attribute21                  => g_per_rec.attribute21
5853      ,p_attribute22                  => g_per_rec.attribute22
5854      ,p_attribute23                  => g_per_rec.attribute23
5855      ,p_attribute24                  => g_per_rec.attribute24
5856      ,p_attribute25                  => g_per_rec.attribute25
5857      ,p_attribute26                  => g_per_rec.attribute26
5858      ,p_attribute27                  => g_per_rec.attribute27
5859      ,p_attribute28                  => g_per_rec.attribute28
5860      ,p_attribute29                  => g_per_rec.attribute29
5861      ,p_attribute30                  => g_per_rec.attribute30
5862       -- DDF
5863      ,p_per_information_category     => g_per_rec.per_information_category
5864      ,p_per_information1             => g_per_rec.per_information1
5865      ,p_per_information2             => g_per_rec.per_information2
5866      ,p_per_information3             => g_per_rec.per_information3
5867      ,p_per_information4             => g_per_rec.per_information4
5868      ,p_per_information5             => g_per_rec.per_information5
5869      ,p_per_information6             => g_per_rec.per_information6
5870      ,p_per_information7             => g_per_rec.per_information7
5871      ,p_per_information8             => g_per_rec.per_information8
5872      ,p_per_information9             => g_per_rec.per_information9
5873      ,p_per_information10            => g_per_rec.per_information10
5874      ,p_per_information11            => g_per_rec.per_information11
5875      ,p_per_information12            => g_per_rec.per_information12
5876      ,p_per_information13            => g_per_rec.per_information13
5877      ,p_per_information14            => g_per_rec.per_information14
5878      ,p_per_information15            => g_per_rec.per_information15
5879      ,p_per_information16            => g_per_rec.per_information16
5880      ,p_per_information17            => g_per_rec.per_information17
5881      ,p_per_information18            => g_per_rec.per_information18
5882      ,p_per_information19            => g_per_rec.per_information19
5883      ,p_per_information20            => g_per_rec.per_information20
5884      ,p_per_information21            => g_per_rec.per_information21
5885      ,p_per_information22            => g_per_rec.per_information22
5886      ,p_per_information23            => g_per_rec.per_information23
5887      ,p_per_information24            => g_per_rec.per_information24
5888      ,p_per_information25            => g_per_rec.per_information25
5889      ,p_per_information26            => g_per_rec.per_information26
5890      ,p_per_information27            => g_per_rec.per_information27
5891      ,p_per_information28            => g_per_rec.per_information28
5892      ,p_per_information29            => g_per_rec.per_information29
5893      ,p_per_information30            => g_per_rec.per_information30
5894      ,p_date_of_death                => g_per_rec.date_of_death
5895      ,p_background_check_status      => g_per_rec.background_check_status
5896      ,p_background_date_check        => g_per_rec.background_date_check
5897      ,p_blood_type                   => g_per_rec.blood_type
5898      ,p_correspondence_language      => g_per_rec.correspondence_language
5899      ,p_fast_path_employee           => g_per_rec.fast_path_employee
5900      ,p_fte_capacity                 => g_per_rec.fte_capacity
5901      ,p_honors                       => g_per_rec.honors
5902      ,p_internal_location            => g_per_rec.internal_location
5903      ,p_last_medical_test_by         => g_per_rec.last_medical_test_by
5904      ,p_last_medical_test_date       => g_per_rec.last_medical_test_date
5905      ,p_mailstop                     => g_per_rec.mailstop
5906      ,p_office_number                => g_per_rec.office_number
5907      ,p_on_military_service          => g_per_rec.on_military_service
5908      ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
5909      ,p_rehire_recommendation        => g_per_rec.rehire_recommendation
5910      ,p_projected_start_date         => g_per_rec.projected_start_date
5911      ,p_resume_exists                => g_per_rec.resume_exists
5912      ,p_resume_last_updated          => g_per_rec.resume_last_updated
5913      ,p_second_passport_exists       => g_per_rec.second_passport_exists
5914      ,p_student_status               => g_per_rec.student_status
5915      ,p_work_schedule                => g_per_rec.work_schedule
5916      ,p_suffix                       => g_per_rec.suffix
5917      ,p_benefit_group_id             => g_per_rec.benefit_group_id
5918      ,p_receipt_of_death_cert_date   => g_per_rec.receipt_of_death_cert_date
5919      ,p_coord_ben_med_pln_no         => g_per_rec.coord_ben_med_pln_no
5920      ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
5921      ,p_coord_ben_med_ext_er         => g_per_rec.coord_ben_med_ext_er
5922      ,p_coord_ben_med_pl_name        => g_per_rec.coord_ben_med_pl_name
5923      ,p_coord_ben_med_insr_crr_name  => g_per_rec.coord_ben_med_insr_crr_name
5924      ,p_coord_ben_med_insr_crr_ident => g_per_rec.coord_ben_med_insr_crr_ident
5925      ,p_coord_ben_med_cvg_strt_dt    => g_per_rec.coord_ben_med_cvg_strt_dt
5926      ,p_coord_ben_med_cvg_end_dt     => g_per_rec.coord_ben_med_cvg_end_dt
5927      ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
5928      ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
5929      ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
5930      ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
5931      ,p_adjusted_svc_date            => p_adjusted_svc_date
5932      ,p_town_of_birth                => g_per_rec.town_of_birth
5933      ,p_region_of_birth              => g_per_rec.region_of_birth
5934      ,p_country_of_birth             => g_per_rec.country_of_birth
5935      ,p_global_person_id             => g_per_rec.global_person_id
5936      ,p_party_id                     => g_per_rec.party_id
5937      -- Out Variables
5938      ,p_person_id                    => p_emp_api_out.person_id
5939      ,p_assignment_id                => p_emp_api_out.assignment_id
5940      ,p_per_object_version_number    => p_emp_api_out.per_object_version_number
5941      ,p_asg_object_version_number    => p_emp_api_out.asg_object_version_number
5942      ,p_per_effective_start_date     => p_emp_api_out.per_effective_start_date
5943      ,p_per_effective_end_date       => p_emp_api_out.per_effective_end_date
5944      ,p_full_name                    => p_emp_api_out.full_name
5945      ,p_per_comment_id               => p_emp_api_out.per_comment_id
5946      ,p_assignment_sequence          => p_emp_api_out.assignment_sequence
5947      ,p_assignment_number            => p_emp_api_out.assignment_number
5948      ,p_name_combination_warning     => p_emp_api_out.name_combination_warning
5949      ,p_assign_payroll_warning       => p_emp_api_out.assign_payroll_warning
5950      ,p_orig_hire_warning            => p_emp_api_out.orig_hire_warning
5951      );
5952      --
5953      -- Person record
5954      --
5955      g_per_rec.person_id             := p_emp_api_out.person_id;
5956      g_per_rec.object_version_number := p_emp_api_out.per_object_version_number;
5957      g_per_rec.effective_start_date  := p_emp_api_out.per_effective_start_date;
5958      g_per_rec.effective_end_date    := p_emp_api_out.per_effective_end_date;
5959      --
5960      -- Assignment record
5961      --
5962      g_asg_rec.person_id             := g_per_rec.person_id;
5963      g_asg_rec.assignment_id         := p_emp_api_out.assignment_id;
5964      g_asg_rec.object_version_number := p_emp_api_out.asg_object_version_number;
5965 
5966 --By DBANSAL, use assignment_number obtained from spreadsheet
5967 -- If the assignment_number obtained from spreadsheet is null then use the generated one
5968    g_asg_rec.assignment_number := NVL(g_asg_rec.assignment_number,
5969                                          p_emp_api_out.assignment_number);
5970      g_asg_rec.assignment_sequence   := p_emp_api_out.assignment_sequence;
5971      --
5972      -- Address record
5973      --
5974      g_add_rec.person_id             := g_per_rec.person_id;
5975      g_add_rec.date_from             := g_per_rec.start_date;
5976      g_add_rec.date_to               := null;
5977 
5978    --hr_utility.trace('After Call to Hr_Employee_Api.Create_Employee:');
5979    --hr_utility.trace('p_employee_number=>'|| g_per_rec.employee_number);
5980    --hr_utility.trace('p_assignment_number=>'|| g_asg_rec.assignment_number);
5981    --hr_utility.trace('assignment_sequence =>'|| g_asg_rec.assignment_sequence);
5982 
5983   elsif p_action_mode = 'HIRE_PERSON_INTOEMP' then
5984 
5985         Hire_Person_IntoEmp
5986        (p_validate            => p_validate
5987        ,p_hire_date           => g_per_rec.start_date
5988        ,p_person_id           => g_per_rec.person_id
5989        ,p_adjusted_svc_date   => p_adjusted_svc_date
5990         -- Out
5991        ,p_updper_api_out      => l_updper_api_out
5992        ,p_HireToJobapi_out    => l_HireToJobapi_out
5993         );
5994        --
5995        -- Person record
5996        --
5997        p_emp_api_out.person_id := g_per_rec.person_id;
5998 
5999        p_emp_api_out.per_effective_start_date
6000            := l_HireToJobapi_out.effective_start_date;
6001        p_emp_api_out.per_effective_end_date
6002            := l_HireToJobapi_out.effective_end_date;
6003        --
6004        -- Assignment record
6005        --
6006        g_asg_rec.person_id      := g_per_rec.person_id;
6007        g_asg_rec.assignment_id  := l_HireToJobapi_out.assignment_id;
6008        --
6009        -- Address record
6010        --
6011        g_add_rec.person_id      := g_per_rec.person_id;
6012        g_add_rec.date_from      := g_per_rec.start_date;
6013        g_add_rec.date_to        := null;
6014 
6015   end if;
6016 
6017   if g_debug then
6018     hr_utility.set_location('..person_id                 : ' ||
6019                              p_emp_api_out.person_id,20);
6020     hr_utility.set_location('..assignment_id             : ' ||
6021                              p_emp_api_out.assignment_id,20);
6022     hr_utility.set_location('..per_object_version_number : ' ||
6023                              p_emp_api_out.per_object_version_number,20);
6024     hr_utility.set_location('..asg_object_version_number : ' ||
6025                              p_emp_api_out.asg_object_version_number,20);
6026     hr_utility.set_location('..per_effective_start_date  : ' ||
6027                              p_emp_api_out.per_effective_start_date,20);
6028     hr_utility.set_location('..per_effective_end_date    : ' ||
6029                              p_emp_api_out.per_effective_end_date,20);
6030     hr_utility.set_location('..full_name                 : ' ||
6031                              p_emp_api_out.full_name,20);
6032     hr_utility.set_location('..per_comment_id            : ' ||
6033                              p_emp_api_out.per_comment_id,20);
6034     hr_utility.set_location('..assignment_sequence       : ' ||
6035                              p_emp_api_out.assignment_sequence,20);
6036     hr_utility.set_location('..assignment_number         : ' ||
6037                              p_emp_api_out.assignment_number,20);
6038   end if;
6039 
6040   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
6041 
6042 exception
6043   when Others then
6044   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
6045   raise;
6046 
6047 end InsUpd_Employee;
6048 
6049 -- =============================================================================
6050 -- ~ InsUpd_Applicant:
6051 -- =============================================================================
6052 procedure InsUpd_Applicant
6053          (p_validate            in boolean  default false
6054          ,p_action_mode         in varchar2 default null
6055          ,p_effective_date      in date
6056          ,p_adjusted_svc_date   in date     default null
6057          ,p_per_comments        in varchar2 default null
6058          ,p_assignment_id       in number   default null
6059          ,p_appl_api_out        out nocopy t_hrEmpApi) as
6060 
6061   l_updper_api_out             t_UpdEmp_Api;
6062   l_HireAppapi_out             t_HrApp_Api;
6063   l_UpdEmp_Api                 t_UpdEmp_Api;
6064 
6065   l_oversubscribed_vacancy_id  number(15);
6066 
6067   l_application_id             number(15);
6068 --  l_application_id             number(15):=1103; --Changed by pkagrawa
6069 
6070   l_apl_object_version_number  number(15);
6071 
6072   l_unaccepted_asg_del_warning boolean;
6073   l_appl_override_warning      boolean;
6074   l_datetrack_update_mode      varchar2(150);
6075 
6076   l_proc_name         constant varchar2(150):= g_pkg ||'InsUpd_Applicant';
6077 
6078 begin
6079   hr_utility.set_location('Entering: ' || l_proc_name, 10);
6080 
6081   Get_DataTrack_Mode
6082   (p_datetrack_update_mode => l_datetrack_update_mode
6083    );
6084 
6085   if p_action_mode ='CREATE_APPLICANT' then
6086 
6087 --hr_utility.trace('Before CREATE_APPLICANT');
6088 
6089      HR_Applicant_API.Create_Applicant
6090      (p_validate                     => p_validate
6091      ,p_date_received                => g_per_rec.start_date
6092      ,p_business_group_id            => g_per_rec.business_group_id
6093      ,p_last_name                    => g_per_rec.last_name
6094      ,p_person_type_id               => g_per_rec.person_type_id
6095      ,p_applicant_number             => g_per_rec.applicant_number
6096      ,p_per_comments                 => p_per_comments
6097      ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
6098      ,p_date_of_birth                => g_per_rec.date_of_birth
6099      ,p_email_address                => g_per_rec.email_address
6100      ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
6101      ,p_first_name                   => g_per_rec.first_name
6102      ,p_known_as                     => g_per_rec.known_as
6103      ,p_marital_status               => g_per_rec.marital_status
6104      ,p_middle_names                 => g_per_rec.middle_names
6105      ,p_nationality                  => g_per_rec.nationality
6106      ,p_national_identifier          => g_per_rec.national_identifier
6107      ,p_previous_last_name           => g_per_rec.previous_last_name
6108      ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
6109      ,p_sex                          => g_per_rec.sex
6110      ,p_title                        => g_per_rec.title
6111      ,p_work_telephone               => g_per_rec.work_telephone
6112      ,p_background_check_status      => g_per_rec.background_check_status
6113      ,p_background_date_check        => g_per_rec.background_date_check
6114      ,p_correspondence_language      => g_per_rec.correspondence_language
6115      ,p_fte_capacity                 => g_per_rec.fte_capacity
6116      ,p_hold_applicant_date_until    => g_per_rec.hold_applicant_date_until
6117      ,p_honors                       => g_per_rec.honors
6118      ,p_mailstop                     => g_per_rec.mailstop
6119      ,p_office_number                => g_per_rec.office_number
6120      ,p_on_military_service          => g_per_rec.on_military_service
6121      ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
6122      ,p_projected_start_date         => g_per_rec.projected_start_date
6123      ,p_resume_exists                => g_per_rec.resume_exists
6124      ,p_resume_last_updated          => g_per_rec.resume_last_updated
6125      ,p_student_status               => g_per_rec.student_status
6126      ,p_work_schedule                => g_per_rec.work_schedule
6127      ,p_suffix                       => g_per_rec.suffix
6128      ,p_date_of_death                => g_per_rec.date_of_death
6129      ,p_benefit_group_id             => g_per_rec.benefit_group_id
6130      ,p_receipt_of_death_cert_date   => g_per_rec.receipt_of_death_cert_date
6131      ,p_coord_ben_med_pln_no         => g_per_rec.coord_ben_med_pln_no
6132      ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
6133      ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
6134      ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
6135      ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
6136      ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
6137      ,p_town_of_birth                => g_per_rec.town_of_birth
6138      ,p_region_of_birth              => g_per_rec.region_of_birth
6139      ,p_country_of_birth             => g_per_rec.country_of_birth
6140      ,p_global_person_id             => g_per_rec.global_person_id
6141      ,p_party_id                     => g_per_rec.party_id
6142       -- DF
6143      ,p_attribute_category           => g_per_rec.attribute_category
6144      ,p_attribute1                   => g_per_rec.attribute1
6145      ,p_attribute2                   => g_per_rec.attribute2
6146      ,p_attribute3                   => g_per_rec.attribute3
6147      ,p_attribute4                   => g_per_rec.attribute4
6148      ,p_attribute5                   => g_per_rec.attribute5
6149      ,p_attribute6                   => g_per_rec.attribute6
6150      ,p_attribute7                   => g_per_rec.attribute7
6151      ,p_attribute8                   => g_per_rec.attribute8
6152      ,p_attribute9                   => g_per_rec.attribute9
6153      ,p_attribute10                  => g_per_rec.attribute10
6154      ,p_attribute11                  => g_per_rec.attribute11
6155      ,p_attribute12                  => g_per_rec.attribute12
6156      ,p_attribute13                  => g_per_rec.attribute13
6157      ,p_attribute14                  => g_per_rec.attribute14
6158      ,p_attribute15                  => g_per_rec.attribute15
6159      ,p_attribute16                  => g_per_rec.attribute16
6160      ,p_attribute17                  => g_per_rec.attribute17
6161      ,p_attribute18                  => g_per_rec.attribute18
6162      ,p_attribute19                  => g_per_rec.attribute19
6163      ,p_attribute20                  => g_per_rec.attribute20
6164      ,p_attribute21                  => g_per_rec.attribute21
6165      ,p_attribute22                  => g_per_rec.attribute22
6166      ,p_attribute23                  => g_per_rec.attribute23
6167      ,p_attribute24                  => g_per_rec.attribute24
6168      ,p_attribute25                  => g_per_rec.attribute25
6169      ,p_attribute26                  => g_per_rec.attribute26
6170      ,p_attribute27                  => g_per_rec.attribute27
6171      ,p_attribute28                  => g_per_rec.attribute28
6172      ,p_attribute29                  => g_per_rec.attribute29
6173      ,p_attribute30                  => g_per_rec.attribute30
6174       -- DDF
6175      ,p_per_information_category     => g_per_rec.per_information_category
6176      ,p_per_information1             => g_per_rec.per_information1
6177      ,p_per_information2             => g_per_rec.per_information2
6178      ,p_per_information3             => g_per_rec.per_information3
6179      ,p_per_information4             => g_per_rec.per_information4
6180      ,p_per_information5             => g_per_rec.per_information5
6181      ,p_per_information6             => g_per_rec.per_information6
6182      ,p_per_information7             => g_per_rec.per_information7
6183      ,p_per_information8             => g_per_rec.per_information8
6184      ,p_per_information9             => g_per_rec.per_information9
6185      ,p_per_information10            => g_per_rec.per_information10
6186      ,p_per_information11            => g_per_rec.per_information11
6187      ,p_per_information12            => g_per_rec.per_information12
6188      ,p_per_information13            => g_per_rec.per_information13
6189      ,p_per_information14            => g_per_rec.per_information14
6190      ,p_per_information15            => g_per_rec.per_information15
6191      ,p_per_information16            => g_per_rec.per_information16
6192      ,p_per_information17            => g_per_rec.per_information17
6193      ,p_per_information18            => g_per_rec.per_information18
6194      ,p_per_information19            => g_per_rec.per_information19
6195      ,p_per_information20            => g_per_rec.per_information20
6196      ,p_per_information21            => g_per_rec.per_information21
6197      ,p_per_information22            => g_per_rec.per_information22
6198      ,p_per_information23            => g_per_rec.per_information23
6199      ,p_per_information24            => g_per_rec.per_information24
6200      ,p_per_information25            => g_per_rec.per_information25
6201      ,p_per_information26            => g_per_rec.per_information26
6202      ,p_per_information27            => g_per_rec.per_information27
6203      ,p_per_information28            => g_per_rec.per_information28
6204      ,p_per_information29            => g_per_rec.per_information29
6205      ,p_per_information30            => g_per_rec.per_information30
6206       -- Out variables
6207      ,p_person_id                    => p_appl_api_out.person_id
6208      ,p_assignment_id                => p_appl_api_out.assignment_id
6209      ,p_application_id               => l_application_id
6210      ,p_per_object_version_number    => p_appl_api_out.per_object_version_number
6211      ,p_asg_object_version_number    => p_appl_api_out.asg_object_version_number
6212      ,p_apl_object_version_number    => l_apl_object_version_number
6213      ,p_per_effective_start_date     => p_appl_api_out.per_effective_start_date
6214      ,p_per_effective_end_date       => p_appl_api_out.per_effective_end_date
6215      ,p_full_name                    => p_appl_api_out.full_name
6216      ,p_per_comment_id               => p_appl_api_out.per_comment_id
6217      ,p_assignment_sequence          => p_appl_api_out.assignment_sequence
6218      ,p_name_combination_warning     => p_appl_api_out.name_combination_warning
6219      ,p_orig_hire_warning            => p_appl_api_out.orig_hire_warning
6220       );
6221 
6222 
6223 --hr_utility.trace('After CREATE_APPLICANT Value of l_application_id'||l_application_id);
6224 
6225      g_asg_rec.application_id := l_application_id; -- Change by pkagrawa
6226      --
6227      -- Person record
6228      --
6229      g_per_rec.person_id             := p_appl_api_out.person_id;
6230      g_per_rec.object_version_number := p_appl_api_out.per_object_version_number;
6231      g_per_rec.effective_start_date  := p_appl_api_out.per_effective_start_date;
6232      g_per_rec.effective_end_date    := p_appl_api_out.per_effective_end_date;
6233      --
6234      -- Assignment record
6235      --
6236      g_asg_rec.person_id             := p_appl_api_out.person_id;
6237      g_asg_rec.assignment_id         := p_appl_api_out.assignment_id;
6238      g_asg_rec.object_version_number := p_appl_api_out.asg_object_version_number;
6239 
6240     --Changes by DBANSAL
6241     g_asg_rec.assignment_number := NVL(g_asg_rec.assignment_number,
6242                                          p_appl_api_out.assignment_number);
6243 
6244      g_asg_rec.assignment_sequence   := p_appl_api_out.assignment_sequence;
6245      --
6246      -- Address record
6247      --
6248      g_add_rec.person_id             := p_appl_api_out.person_id;
6249      g_add_rec.date_from             := g_per_rec.start_date;
6250      g_add_rec.date_to               := null;
6251 
6252   elsif p_action_mode ='CONVERT_TO_APPLICANT' then
6253        --
6254        --   This business process converts a person of type EX_APL, EX_EMP
6255        --   or OTHER to a type of APL_EX_APL, EX_EMP_APL or APL respectively.
6256        --   This is achieved by
6257        --     Setting the person type to APL_EX_APL, EX_EMP_APL or APL
6258        --     Creating an application, Creating a default application
6259        --     assignment.
6260        --
6261        HR_Applicant_API.Convert_To_Applicant
6262        (p_validate              => p_validate
6263        ,p_effective_date        => g_per_rec.start_date
6264        ,p_person_id             => g_per_rec.person_id
6265        ,p_object_version_number => g_per_rec.object_version_number
6266        ,p_applicant_number      => g_per_rec.applicant_number
6267        ,p_person_type_id        => g_per_rec.person_type_id
6268        ,p_effective_start_date  => g_per_rec.effective_start_date
6269        ,p_effective_end_date    => g_per_rec.effective_end_date
6270        ,p_appl_override_warning => l_appl_override_warning
6271         );
6272        --
6273        -- Update Person Details
6274        --
6275        Upd_Person_Details
6276        (p_validate            => false
6277        ,p_effective_date      => g_per_rec.effective_start_date
6278        ,p_person_id           => g_per_rec.person_id
6279        ,p_adjusted_svc_date   => null
6280        ,p_updper_api_out      => l_UpdEmp_Api
6281         );
6282        --
6283        -- Address required values
6284        --
6285         g_add_rec.person_id       := g_per_rec.person_id;
6286         g_add_rec.date_from       := g_per_rec.start_date;
6287         g_add_rec.date_to         := null;
6288 
6289 
6290   elsif p_action_mode = 'HIRE_APPLICANT' then
6291        --
6292        -- This API converts data about a person of type Applicant(APL,
6293        -- APL_EX_APL  or EX_EMP_APL) to a person of type Employee(EMP).
6294        -- This is achieved by:
6295        --    - Terminating the application record.
6296        --    - Terminating unaccepted applicant assignments.
6297        --    - Setting person to be an 'EMP'.
6298        --    - Creating a period of service record.
6299        --    - Converting accepted applicant assignments to
6300        --      active employee assignments.
6301        Hire_Applicant_IntoEmp
6302        (p_validate            => p_validate
6303        ,p_hire_date           => g_per_rec.start_date
6304        ,p_person_id           => g_per_rec.person_id
6305        ,p_assignment_id       => p_assignment_id
6306        ,p_adjusted_svc_date   => p_adjusted_svc_date
6307        ,p_updper_api_out      => l_updper_api_out
6308        ,p_HireAppapi_out      => l_HireAppapi_out
6309         );
6310         p_appl_api_out.per_effective_end_date
6311             := l_HireAppapi_out.effective_end_date;
6312 
6313 
6314         p_appl_api_out.per_effective_start_date
6315             := l_HireAppapi_out.effective_start_date;
6316 
6317         p_appl_api_out.assign_payroll_warning
6318             := l_HireAppapi_out.assign_payroll_warning;
6319 
6320         l_oversubscribed_vacancy_id
6321             := l_HireAppapi_out.oversubscribed_vacancy_id;
6322      --
6323      -- Person record
6324      --
6325      g_per_rec.object_version_number := p_appl_api_out.per_object_version_number;
6326      g_per_rec.effective_start_date  := p_appl_api_out.per_effective_start_date;
6327      g_per_rec.effective_end_date    := p_appl_api_out.per_effective_end_date;
6328      --
6329      -- Now that the person is converted into an employee, update the person
6330      -- details as passed from the spread sheet.
6331      --
6332      Upd_Person_Details
6333      (p_validate            => false
6334      ,p_effective_date      => g_per_rec.effective_start_date
6335      ,p_person_id           => g_per_rec.person_id
6336      ,p_adjusted_svc_date   => null
6337      ,p_updper_api_out      => l_UpdEmp_Api
6338       );
6339      --
6340      -- Assignment record
6341      --
6342      g_asg_rec.person_id             := g_per_rec.person_id;
6343      g_asg_rec.assignment_id         := p_assignment_id;
6344      g_asg_rec.object_version_number := p_appl_api_out.asg_object_version_number;
6345      g_asg_rec.assignment_sequence   := p_appl_api_out.assignment_sequence;
6346      --
6347      -- Address record
6348      --
6349      g_add_rec.person_id             := g_per_rec.person_id;
6350      g_add_rec.date_from             := g_per_rec.start_date;
6351      g_add_rec.date_to               := null;
6352 
6353   elsif p_action_mode = 'APPLY_FOR_JOB' then
6354 
6355       HR_Applicant_API.Apply_For_Job_Anytime
6356       (p_validate                      => p_validate
6357       ,p_effective_date                => g_per_rec.start_date
6358       ,p_person_id                     => g_per_rec.person_id
6359       --,p_vacancy_id                  => g_per_rec.vacancy_id
6360       ,p_person_type_id                => g_per_rec.person_type_id
6361       ,p_assignment_status_type_id     => g_asg_rec.assignment_status_type_id
6362       -- In/Out
6363       ,p_applicant_number              => g_per_rec.applicant_number
6364       ,p_per_object_version_number     => g_per_rec.object_version_number
6365       -- Out
6366       ,p_application_id                => l_application_id
6367       ,p_assignment_id                 => p_appl_api_out.assignment_id
6368       ,p_apl_object_version_number     => p_appl_api_out.per_object_version_number
6369       ,p_asg_object_version_number     => p_appl_api_out.asg_object_version_number
6370       ,p_assignment_sequence           => p_appl_api_out.assignment_sequence
6371       ,p_per_effective_start_date      => p_appl_api_out.per_effective_start_date
6372       ,p_per_effective_end_date        => p_appl_api_out.per_effective_end_date
6373       ,p_appl_override_warning         => l_appl_override_warning
6374        );
6375      --
6376      -- Person record
6377      --
6378      g_asg_rec.application_id := l_application_id; -- Change by pkagrawa
6379 
6380      g_per_rec.object_version_number := p_appl_api_out.per_object_version_number;
6381      g_per_rec.effective_start_date  := p_appl_api_out.per_effective_start_date;
6382      g_per_rec.effective_end_date    := p_appl_api_out.per_effective_end_date;
6383      -- Update the person information
6384      Upd_Person_Details
6385      (p_validate            => false
6386      ,p_effective_date      => g_per_rec.effective_start_date
6387      ,p_person_id           => g_per_rec.person_id
6388      ,p_adjusted_svc_date   => null
6389      ,p_updper_api_out      => l_UpdEmp_Api
6390       );
6391      --
6392      -- Assignment record
6393      --
6394      g_asg_rec.person_id             := g_per_rec.person_id;
6395      g_asg_rec.assignment_id         := p_appl_api_out.assignment_id;
6396      g_asg_rec.object_version_number := p_appl_api_out.asg_object_version_number;
6397      g_asg_rec.assignment_sequence   := p_appl_api_out.assignment_sequence;
6398      --
6399      -- Address record
6400      --
6401      g_add_rec.person_id             := g_per_rec.person_id;
6402      g_add_rec.date_from             := g_per_rec.start_date;
6403      g_add_rec.date_to               := null;
6404 
6405   end if;
6406 
6407   if g_debug then
6408     hr_utility.set_location('..person_id                 : ' ||
6409                              p_appl_api_out.person_id,20);
6410     hr_utility.set_location('..assignment_id             : ' ||
6411                              p_appl_api_out.assignment_id,20);
6412     hr_utility.set_location('..per_object_version_number : ' ||
6413                              p_appl_api_out.per_object_version_number,20);
6414     hr_utility.set_location('..asg_object_version_number : ' ||
6415                              p_appl_api_out.asg_object_version_number,20);
6416     hr_utility.set_location('..per_effective_start_date  : ' ||
6417                              p_appl_api_out.per_effective_start_date,20);
6418     hr_utility.set_location('..per_effective_end_date    : ' ||
6419                              p_appl_api_out.per_effective_end_date,20);
6420     hr_utility.set_location('..full_name                 : ' ||
6421                              p_appl_api_out.full_name,20);
6422     hr_utility.set_location('..per_comment_id            : ' ||
6423                              p_appl_api_out.per_comment_id,20);
6424     hr_utility.set_location('..assignment_sequence       : ' ||
6425                              p_appl_api_out.assignment_sequence,20);
6426     hr_utility.set_location('..assignment_number         : ' ||
6427                              p_appl_api_out.assignment_number,20);
6428   end if;
6429 
6430   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
6431 
6432 exception
6433   when Others then
6434   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
6435   raise;
6436 
6437 end InsUpd_Applicant;
6438 -- =============================================================================
6439 -- ~ InsUpd_Contingent_Worker:
6440 -- =============================================================================
6441 procedure InsUpd_Contingent_Worker
6442          (p_validate              in boolean  default false
6443          ,p_action_mode           in varchar2 default null
6444          ,p_datetrack_update_mode in varchar2 default null
6445          ,p_effective_date        in date
6446          ,p_adjusted_svc_date     in date     default null
6447          ,p_per_comments          in varchar2 default null
6448          ,p_cwk_api_out           out nocopy t_hrEmpApi) as
6449 
6450   l_apl_object_version_number  number(15);
6451   l_application_id             number(15);
6452   l_datetrack_update_mode      varchar2(150);
6453   l_proc_name         constant varchar2(150):= g_pkg ||'InsUpd_Contingent_Worker';
6454 
6455 begin
6456   hr_utility.set_location('Entering: ' || l_proc_name, 10);
6457 
6458   Get_DataTrack_Mode
6459   (p_datetrack_update_mode => l_datetrack_update_mode
6460    );
6461 
6462   --hr_utility.trace('Inside InsUpd_Contingent_Worker before CREATE_CWK');
6463   --hr_utility.trace('p_person_type_id'||g_per_rec.person_type_id);
6464 
6465   if p_action_mode ='CREATE_CWK' then
6466 
6467     HR_Contingent_Worker_API.Create_CWK
6468     (p_validate                    => p_validate
6469     ,p_start_date                  => g_per_rec.start_date
6470     ,p_business_group_id           => g_per_rec.business_group_id
6471     ,p_last_name                   => g_per_rec.last_name
6472     ,p_person_type_id              => g_per_rec.person_type_id
6473     ,p_npw_number                  => g_per_rec.npw_number
6474     ,p_background_check_status     => g_per_rec.background_check_status
6475     ,p_background_date_check       => g_per_rec.background_date_check
6476     ,p_blood_type                  => g_per_rec.blood_type
6477     ,p_comments                    => p_per_comments
6478     ,p_correspondence_language     => g_per_rec.correspondence_language
6479     ,p_country_of_birth            => g_per_rec.country_of_birth
6480     ,p_date_of_birth               => g_per_rec.date_of_birth
6481     ,p_date_of_death               => g_per_rec.date_of_death
6482     ,p_dpdnt_adoption_date         => g_per_rec.dpdnt_adoption_date
6483     ,p_dpdnt_vlntry_svce_flag      => g_per_rec.dpdnt_vlntry_svce_flag
6484     ,p_email_address               => g_per_rec.email_address
6485     ,p_first_name                  => g_per_rec.first_name
6486     ,p_fte_capacity                => g_per_rec.fte_capacity
6487     ,p_honors                      => g_per_rec.honors
6488     ,p_internal_location           => g_per_rec.internal_location
6489     ,p_known_as                    => g_per_rec.known_as
6490     ,p_last_medical_test_by        => g_per_rec.last_medical_test_by
6491     ,p_last_medical_test_date      => g_per_rec.last_medical_test_date
6492     ,p_mailstop                    => g_per_rec.mailstop
6493     ,p_marital_status              => g_per_rec.marital_status
6494     ,p_middle_names                => g_per_rec.middle_names
6495     ,p_national_identifier         => g_per_rec.national_identifier
6496     ,p_nationality                 => g_per_rec.nationality
6497     ,p_office_number               => g_per_rec.office_number
6498     ,p_on_military_service         => g_per_rec.on_military_service
6499     ,p_party_id                    => g_per_rec.party_id
6500     ,p_pre_name_adjunct            => g_per_rec.pre_name_adjunct
6501     ,p_previous_last_name          => g_per_rec.previous_last_name
6502     ,p_receipt_of_death_cert_date  => g_per_rec.receipt_of_death_cert_date
6503     ,p_region_of_birth             => g_per_rec.region_of_birth
6504     ,p_registered_disabled_flag    => g_per_rec.registered_disabled_flag
6505     ,p_resume_exists               => g_per_rec.resume_exists
6506     ,p_resume_last_updated         => g_per_rec.resume_last_updated
6507     ,p_second_passport_exists      => g_per_rec.second_passport_exists
6508     ,p_sex                         => g_per_rec.sex
6509     ,p_student_status              => g_per_rec.student_status
6510     ,p_suffix                      => g_per_rec.suffix
6511     ,p_title                       => g_per_rec.title
6512     ,p_town_of_birth               => g_per_rec.town_of_birth
6513     ,p_uses_tobacco_flag           => g_per_rec.uses_tobacco_flag
6514     ,p_vendor_id                   => g_per_rec.vendor_id
6515     ,p_work_schedule               => g_per_rec.work_schedule
6516     ,p_work_telephone              => g_per_rec.work_telephone
6517     ,p_exp_check_send_to_address   => g_per_rec.expense_check_send_to_address
6518     ,p_hold_applicant_date_until   => g_per_rec.hold_applicant_date_until
6519     ,p_date_employee_data_verified => g_per_rec.date_employee_data_verified
6520     ,p_benefit_group_id            => g_per_rec.benefit_group_id
6521     ,p_coord_ben_med_pln_no        => g_per_rec.coord_ben_med_pln_no
6522     ,p_coord_ben_no_cvg_flag       => g_per_rec.coord_ben_no_cvg_flag
6523     ,p_original_date_of_hire       => g_per_rec.original_date_of_hire
6524      -- DF
6525     ,p_attribute_category          => g_per_rec.attribute_category
6526     ,p_attribute1                  => g_per_rec.attribute1
6527     ,p_attribute2                  => g_per_rec.attribute2
6528     ,p_attribute3                  => g_per_rec.attribute3
6529     ,p_attribute4                  => g_per_rec.attribute4
6530     ,p_attribute5                  => g_per_rec.attribute5
6531     ,p_attribute6                  => g_per_rec.attribute6
6532     ,p_attribute7                  => g_per_rec.attribute7
6533     ,p_attribute8                  => g_per_rec.attribute8
6534     ,p_attribute9                  => g_per_rec.attribute9
6535     ,p_attribute10                 => g_per_rec.attribute10
6536     ,p_attribute11                 => g_per_rec.attribute11
6537     ,p_attribute12                 => g_per_rec.attribute12
6538     ,p_attribute13                 => g_per_rec.attribute13
6539     ,p_attribute14                 => g_per_rec.attribute14
6540     ,p_attribute15                 => g_per_rec.attribute15
6541     ,p_attribute16                 => g_per_rec.attribute16
6542     ,p_attribute17                 => g_per_rec.attribute17
6543     ,p_attribute18                 => g_per_rec.attribute18
6544     ,p_attribute19                 => g_per_rec.attribute19
6545     ,p_attribute20                 => g_per_rec.attribute20
6546     ,p_attribute21                 => g_per_rec.attribute21
6547     ,p_attribute22                 => g_per_rec.attribute22
6548     ,p_attribute23                 => g_per_rec.attribute23
6549     ,p_attribute24                 => g_per_rec.attribute24
6550     ,p_attribute25                 => g_per_rec.attribute25
6551     ,p_attribute26                 => g_per_rec.attribute26
6552     ,p_attribute27                 => g_per_rec.attribute27
6553     ,p_attribute28                 => g_per_rec.attribute28
6554     ,p_attribute29                 => g_per_rec.attribute29
6555     ,p_attribute30                 => g_per_rec.attribute30
6556      -- DDF
6557     ,p_per_information_category    => g_per_rec.per_information_category
6558     ,p_per_information1            => g_per_rec.per_information1
6559     ,p_per_information2            => g_per_rec.per_information2
6560     ,p_per_information3            => g_per_rec.per_information3
6561     ,p_per_information4            => g_per_rec.per_information4
6562     ,p_per_information5            => g_per_rec.per_information5
6563     ,p_per_information6            => g_per_rec.per_information6
6564     ,p_per_information7            => g_per_rec.per_information7
6565     ,p_per_information8            => g_per_rec.per_information8
6566     ,p_per_information9            => g_per_rec.per_information9
6567     ,p_per_information10           => g_per_rec.per_information10
6568     ,p_per_information11           => g_per_rec.per_information11
6569     ,p_per_information12           => g_per_rec.per_information12
6570     ,p_per_information13           => g_per_rec.per_information13
6571     ,p_per_information14           => g_per_rec.per_information14
6572     ,p_per_information15           => g_per_rec.per_information15
6573     ,p_per_information16           => g_per_rec.per_information16
6574     ,p_per_information17           => g_per_rec.per_information17
6575     ,p_per_information18           => g_per_rec.per_information18
6576     ,p_per_information19           => g_per_rec.per_information19
6577     ,p_per_information20           => g_per_rec.per_information20
6578     ,p_per_information21           => g_per_rec.per_information21
6579     ,p_per_information22           => g_per_rec.per_information22
6580     ,p_per_information23           => g_per_rec.per_information23
6581     ,p_per_information24           => g_per_rec.per_information24
6582     ,p_per_information25           => g_per_rec.per_information25
6583     ,p_per_information26           => g_per_rec.per_information26
6584     ,p_per_information27           => g_per_rec.per_information27
6585     ,p_per_information28           => g_per_rec.per_information28
6586     ,p_per_information29           => g_per_rec.per_information29
6587     ,p_per_information30           => g_per_rec.per_information30
6588      -- Out Variables
6589     ,p_person_id                   => p_cwk_api_out.person_id
6590     ,p_assignment_id               => p_cwk_api_out.assignment_id
6591     ,p_per_object_version_number   => p_cwk_api_out.per_object_version_number
6592     ,p_asg_object_version_number   => p_cwk_api_out.asg_object_version_number
6593     ,p_per_effective_start_date    => p_cwk_api_out.per_effective_start_date
6594     ,p_per_effective_end_date      => p_cwk_api_out.per_effective_end_date
6595     ,p_full_name                   => p_cwk_api_out.full_name
6596     ,p_comment_id                  => p_cwk_api_out.per_comment_id
6597     ,p_pdp_object_version_number   => p_cwk_api_out.pdp_object_version_number
6598     ,p_assignment_sequence         => p_cwk_api_out.assignment_sequence
6599     ,p_assignment_number           => p_cwk_api_out.assignment_number
6600     ,p_name_combination_warning    => p_cwk_api_out.name_combination_warning
6601     );
6602     --
6603     -- Person record
6604     --
6605     g_per_rec.person_id             := p_cwk_api_out.person_id;
6606     g_per_rec.object_version_number := p_cwk_api_out.per_object_version_number;
6607     g_per_rec.effective_start_date  := p_cwk_api_out.per_effective_start_date;
6608     g_per_rec.effective_end_date    := p_cwk_api_out.per_effective_end_date;
6609     --
6610     -- Assignment record
6611     --
6612     g_asg_rec.person_id             := p_cwk_api_out.person_id;
6613     g_asg_rec.assignment_id         := p_cwk_api_out.assignment_id;
6614     g_asg_rec.object_version_number := p_cwk_api_out.asg_object_version_number;
6615 
6616     -- by DBANSAL , use the assignment number entered by user in spreadsheet
6617     g_asg_rec.assignment_number := NVL(g_asg_rec.assignment_number,
6618                                         p_cwk_api_out.assignment_number);
6619 
6620     g_asg_rec.assignment_sequence   := p_cwk_api_out.assignment_sequence;
6621     --
6622     -- Address record
6623     --
6624     g_add_rec.person_id             := p_cwk_api_out.person_id;
6625     g_add_rec.date_from             := g_per_rec.start_date;
6626     g_add_rec.date_to               := null;
6627 
6628   elsif p_action_mode = 'CONVERT_TO_CWK' then
6629 
6630         HR_Contingent_Worker_API.Convert_To_CWK
6631        (p_validate                      => p_validate
6632        ,p_effective_date                => g_per_rec.start_date
6633        ,p_person_id                     => g_per_rec.person_id
6634        --,p_projected_placement_end     => g_per_rec.
6635        ,p_person_type_id                => g_per_rec.person_type_id
6636        ,p_datetrack_update_mode         => l_datetrack_update_mode
6637         -- In/Out Variables
6638        ,p_object_version_number         => g_per_rec.object_version_number
6639        ,p_npw_number                    => g_per_rec.npw_number
6640         -- Out variables
6641        ,p_per_effective_start_date      => p_cwk_api_out.per_effective_start_date
6642        ,p_per_effective_end_date        => p_cwk_api_out.per_effective_end_date
6643        ,p_pdp_object_version_number     => p_cwk_api_out.pdp_object_version_number
6644        ,p_assignment_id                 => p_cwk_api_out.assignment_id
6645        ,p_asg_object_version_number     => p_cwk_api_out.asg_object_version_number
6646        ,p_assignment_sequence           => p_cwk_api_out.assignment_sequence
6647         );
6648        --
6649        -- Person record
6650        --
6651        g_per_rec.effective_start_date  := p_cwk_api_out.per_effective_start_date;
6652        g_per_rec.effective_end_date    := p_cwk_api_out.per_effective_end_date;
6653        --
6654        -- Assignment record
6655        --
6656        g_asg_rec.person_id             := g_per_rec.person_id;
6657        g_asg_rec.assignment_id         := p_cwk_api_out.assignment_id;
6658        g_asg_rec.object_version_number := p_cwk_api_out.asg_object_version_number;
6659        g_asg_rec.assignment_number     := p_cwk_api_out.assignment_number;
6660        g_asg_rec.assignment_sequence   := p_cwk_api_out.assignment_sequence;
6661        --
6662        -- Address record
6663        --
6664        g_add_rec.person_id             := g_per_rec.person_id;
6665        g_add_rec.date_from             := g_per_rec.start_date;
6666        g_add_rec.date_to               := null;
6667 
6668   elsif p_action_mode = 'APPLY_FOR_JOB' then
6669 
6670         HR_Contingent_Worker_API.Apply_For_Job
6671        (p_validate                      => p_validate
6672        ,p_effective_date                => g_per_rec.start_date
6673        ,p_person_id                     => g_per_rec.person_id
6674        ,p_person_type_id                => g_per_rec.person_type_id
6675        --,p_vacancy_id                    => g_per_rec.
6676         -- In/Out
6677        ,p_object_version_number         => g_per_rec.object_version_number
6678        ,p_applicant_number              => g_per_rec.applicant_number
6679         -- Out
6680        ,p_per_effective_start_date      => p_cwk_api_out.per_effective_start_date
6681        ,p_per_effective_end_date        => p_cwk_api_out.per_effective_end_date
6682        ,p_application_id                => l_application_id
6683        ,p_apl_object_version_number     => l_apl_object_version_number
6684        ,p_assignment_id                 => p_cwk_api_out.assignment_id
6685        ,p_asg_object_version_number     => p_cwk_api_out.asg_object_version_number
6686        ,p_assignment_sequence           => p_cwk_api_out.assignment_sequence
6687         );
6688        --
6689        -- Person record
6690        --
6691        g_per_rec.effective_start_date  := p_cwk_api_out.per_effective_start_date;
6692        g_per_rec.effective_end_date    := p_cwk_api_out.per_effective_end_date;
6693        --
6694        -- Assignment record
6695        --
6696        g_asg_rec.person_id             := g_per_rec.person_id;
6697        g_asg_rec.assignment_id         := p_cwk_api_out.assignment_id;
6698        g_asg_rec.object_version_number := p_cwk_api_out.asg_object_version_number;
6699        g_asg_rec.assignment_sequence   := p_cwk_api_out.assignment_sequence;
6700        --
6701        -- Address record
6702        --
6703        g_add_rec.person_id             := g_per_rec.person_id;
6704        g_add_rec.date_from             := g_per_rec.start_date;
6705        g_add_rec.date_to               := null;
6706   end if;
6707 
6708   if g_debug then
6709     hr_utility.set_location('..person_id                 : ' ||
6710                              p_cwk_api_out.person_id,20);
6711     hr_utility.set_location('..assignment_id             : ' ||
6712                              p_cwk_api_out.assignment_id,20);
6713     hr_utility.set_location('..per_object_version_number : ' ||
6714                              p_cwk_api_out.per_object_version_number,20);
6715     hr_utility.set_location('..asg_object_version_number : ' ||
6716                              p_cwk_api_out.asg_object_version_number,20);
6717     hr_utility.set_location('..per_effective_start_date  : ' ||
6718                              p_cwk_api_out.per_effective_start_date,20);
6719     hr_utility.set_location('..per_effective_end_date    : ' ||
6720                              p_cwk_api_out.per_effective_end_date,20);
6721     hr_utility.set_location('..full_name                 : ' ||
6722                              p_cwk_api_out.full_name,20);
6723     hr_utility.set_location('..per_comment_id            : ' ||
6724                              p_cwk_api_out.per_comment_id,20);
6725     hr_utility.set_location('..assignment_sequence       : ' ||
6726                              p_cwk_api_out.assignment_sequence,20);
6727     hr_utility.set_location('..assignment_number         : ' ||
6728                              p_cwk_api_out.assignment_number,20);
6729   end if;
6730 
6731   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
6732 
6733 exception
6734   when Others then
6735   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
6736   raise;
6737 
6738 end InsUpd_Contingent_Worker;
6739 -- =============================================================================
6740 -- ~ InsUpd_Contact_Person:
6741 -- =============================================================================
6742 procedure InsUpd_Contact_Person
6743          (p_validate            boolean  default false
6744          ,p_effective_date      date
6745          ,p_adjusted_svc_date   date     default null
6746          ,p_per_comments        varchar2 default null
6747          ,p_contact_api_out     out nocopy t_hrEmpApi) as
6748 
6749   l_proc_name         constant varchar2(150):= g_pkg ||'InsUpd_Contact_Person';
6750 
6751 begin
6752   hr_utility.set_location('Entering: ' || l_proc_name, 10);
6753 
6754   Hr_Contact_Api.Create_Person
6755   (p_validate                     => p_validate
6756   ,p_start_date                   => g_per_rec.start_date
6757   ,p_business_group_id            => g_per_rec.business_group_id
6758   ,p_last_name                    => g_per_rec.last_name
6759   ,p_sex                          => g_per_rec.sex
6760   ,p_person_type_id               => g_per_rec.person_type_id
6761   ,p_comments                     => p_per_comments
6762   ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
6763   ,p_date_of_birth                => g_per_rec.date_of_birth
6764   ,p_email_address                => g_per_rec.email_address
6765   ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
6766   ,p_first_name                   => g_per_rec.first_name
6767   ,p_known_as                     => g_per_rec.known_as
6768   ,p_marital_status               => g_per_rec.marital_status
6769   ,p_middle_names                 => g_per_rec.middle_names
6770   ,p_nationality                  => g_per_rec.nationality
6771   ,p_national_identifier          => g_per_rec.national_identifier
6772   ,p_previous_last_name           => g_per_rec.previous_last_name
6773   ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
6774   ,p_title                        => g_per_rec.title
6775   ,p_vendor_id                    => g_per_rec.vendor_id
6776   ,p_work_telephone               => g_per_rec.work_telephone
6777   ,p_correspondence_language      => g_per_rec.correspondence_language
6778   ,p_honors                       => g_per_rec.honors
6779   ,p_benefit_group_id             => g_per_rec.benefit_group_id
6780   ,p_on_military_service          => g_per_rec.on_military_service
6781   ,p_student_status               => g_per_rec.student_status
6782   ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
6783   ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
6784   ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
6785   ,p_suffix                       => g_per_rec.suffix
6786   ,p_town_of_birth                => g_per_rec.town_of_birth
6787   ,p_region_of_birth              => g_per_rec.region_of_birth
6788   ,p_country_of_birth             => g_per_rec.country_of_birth
6789   ,p_global_person_id             => g_per_rec.global_person_id
6790    -- DF
6791   ,p_attribute_category           => g_per_rec.attribute_category
6792   ,p_attribute1                   => g_per_rec.attribute1
6793   ,p_attribute2                   => g_per_rec.attribute2
6794   ,p_attribute3                   => g_per_rec.attribute3
6795   ,p_attribute4                   => g_per_rec.attribute4
6796   ,p_attribute5                   => g_per_rec.attribute5
6797   ,p_attribute6                   => g_per_rec.attribute6
6798   ,p_attribute7                   => g_per_rec.attribute7
6799   ,p_attribute8                   => g_per_rec.attribute8
6800   ,p_attribute9                   => g_per_rec.attribute9
6801   ,p_attribute10                  => g_per_rec.attribute10
6802   ,p_attribute11                  => g_per_rec.attribute11
6803   ,p_attribute12                  => g_per_rec.attribute12
6804   ,p_attribute13                  => g_per_rec.attribute13
6805   ,p_attribute14                  => g_per_rec.attribute14
6806   ,p_attribute15                  => g_per_rec.attribute15
6807   ,p_attribute16                  => g_per_rec.attribute16
6808   ,p_attribute17                  => g_per_rec.attribute17
6809   ,p_attribute18                  => g_per_rec.attribute18
6810   ,p_attribute19                  => g_per_rec.attribute19
6811   ,p_attribute20                  => g_per_rec.attribute20
6812   ,p_attribute21                  => g_per_rec.attribute21
6813   ,p_attribute22                  => g_per_rec.attribute22
6814   ,p_attribute23                  => g_per_rec.attribute23
6815   ,p_attribute24                  => g_per_rec.attribute24
6816   ,p_attribute25                  => g_per_rec.attribute25
6817   ,p_attribute26                  => g_per_rec.attribute26
6818   ,p_attribute27                  => g_per_rec.attribute27
6819   ,p_attribute28                  => g_per_rec.attribute28
6820   ,p_attribute29                  => g_per_rec.attribute29
6821   ,p_attribute30                  => g_per_rec.attribute30
6822    -- DDF
6823   ,p_per_information_category     => g_per_rec.per_information_category
6824   ,p_per_information1             => g_per_rec.per_information1
6825   ,p_per_information2             => g_per_rec.per_information2
6826   ,p_per_information3             => g_per_rec.per_information3
6827   ,p_per_information4             => g_per_rec.per_information4
6828   ,p_per_information5             => g_per_rec.per_information5
6829   ,p_per_information6             => g_per_rec.per_information6
6830   ,p_per_information7             => g_per_rec.per_information7
6831   ,p_per_information8             => g_per_rec.per_information8
6832   ,p_per_information9             => g_per_rec.per_information9
6833   ,p_per_information10            => g_per_rec.per_information10
6834   ,p_per_information11            => g_per_rec.per_information11
6835   ,p_per_information12            => g_per_rec.per_information12
6836   ,p_per_information13            => g_per_rec.per_information13
6837   ,p_per_information14            => g_per_rec.per_information14
6838   ,p_per_information15            => g_per_rec.per_information15
6839   ,p_per_information16            => g_per_rec.per_information16
6840   ,p_per_information17            => g_per_rec.per_information17
6841   ,p_per_information18            => g_per_rec.per_information18
6842   ,p_per_information19            => g_per_rec.per_information19
6843   ,p_per_information20            => g_per_rec.per_information20
6844   ,p_per_information21            => g_per_rec.per_information21
6845   ,p_per_information22            => g_per_rec.per_information22
6846   ,p_per_information23            => g_per_rec.per_information23
6847   ,p_per_information24            => g_per_rec.per_information24
6848   ,p_per_information25            => g_per_rec.per_information25
6849   ,p_per_information26            => g_per_rec.per_information26
6850   ,p_per_information27            => g_per_rec.per_information27
6851   ,p_per_information28            => g_per_rec.per_information28
6852   ,p_per_information29            => g_per_rec.per_information29
6853   ,p_per_information30            => g_per_rec.per_information30
6854   -- Out Variables
6855   ,p_person_id                    => p_contact_api_out.person_id
6856   ,p_object_version_number        => p_contact_api_out.per_object_version_number
6857   ,p_effective_start_date         => p_contact_api_out.per_effective_start_date
6858   ,p_effective_end_date           => p_contact_api_out.per_effective_end_date
6859   ,p_full_name                    => p_contact_api_out.full_name
6860   ,p_comment_id                   => p_contact_api_out.per_comment_id
6861   ,p_name_combination_warning     => p_contact_api_out.name_combination_warning
6862   ,p_orig_hire_warning            => p_contact_api_out.orig_hire_warning
6863    );
6864   --
6865   -- Person record
6866   --
6867   g_per_rec.person_id             := p_contact_api_out.person_id;
6868   g_per_rec.object_version_number := p_contact_api_out.per_object_version_number;
6869   g_per_rec.effective_start_date  := p_contact_api_out.per_effective_start_date;
6870   g_per_rec.effective_end_date    := p_contact_api_out.per_effective_end_date;
6871   --
6872   -- Address record
6873   --
6874   g_add_rec.person_id             := p_contact_api_out.person_id;
6875   g_add_rec.date_from             := g_per_rec.start_date;
6876   g_add_rec.date_to               := null;
6877 
6878   if g_debug then
6879     hr_utility.set_location('..person_id                 : ' ||
6880                              p_contact_api_out.person_id,20);
6881     hr_utility.set_location('..per_object_version_number : ' ||
6882                              p_contact_api_out.per_object_version_number,20);
6883     hr_utility.set_location('..per_effective_start_date  : ' ||
6884                              p_contact_api_out.per_effective_start_date,20);
6885     hr_utility.set_location('..per_effective_end_date    : ' ||
6886                              p_contact_api_out.per_effective_end_date,20);
6887     hr_utility.set_location('..full_name                 : ' ||
6888                              p_contact_api_out.full_name,20);
6889     hr_utility.set_location('..per_comment_id            : ' ||
6890                              p_contact_api_out.per_comment_id,20);
6891   end if;
6892 
6893   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
6894 
6895 exception
6896   when Others then
6897   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
6898   raise;
6899 
6900 end InsUpd_Contact_Person;
6901 -- =============================================================================
6902 -- ~ Upd_Batch_Employee_Asg:
6903 -- =============================================================================
6904 procedure Upd_Batch_Employee_Asg
6905          (p_batch_id              in number
6906          ,p_user_sequence         in out nocopy number
6907          ,p_link_value            in number
6908          ,p_assignment_user_key   in varchar2
6909          ,p_action_mode           in varchar2
6910          ,p_datetrack_update_mode in varchar2
6911           ) is
6912 
6913   l_proc_name constant varchar2(150):= g_pkg ||'Upd_Batch_Employee_Asg';
6914 
6915 begin
6916   hr_utility.set_location('Entering: ' || l_proc_name, 5);
6917 
6918       --$ Update Assignment only if User wants to i.e. he has chosen mandatory column
6919       -- 'Assign Organization' in the layout and entered a value
6920      if (g_asg_rec.organization_id is NULL) then
6921      Hr_Utility.set_location('Leaving: '||l_proc_name, 6);
6922      return;
6923      end if;
6924 
6925      --$ Upload supervisor id
6926      if g_asg_rec.supervisor_id is NOT NULL then
6927       hr_pump_utils.add_user_key
6928      (p_user_key_value =>  g_supervisor_user_key
6929      ,p_unique_key_id  =>  g_asg_rec.supervisor_id
6930       );
6931      else
6932      g_supervisor_user_key := null;
6933      end if;
6934 
6935     --$ while updating assignment pass assignment effective start date as obtained
6936    -- from spreadsheet by default and if it is null then use person start date as
6937    -- assignment effective start date
6938 
6939   Hrdpp_Update_Emp_Asg.Insert_Batch_Lines
6940   (p_batch_id                      => p_batch_id
6941   ,p_user_sequence                 => p_user_sequence
6942   ,p_link_value                    => p_link_value
6943   ,p_datetrack_update_mode         => p_datetrack_update_mode
6944   ,p_assignment_user_key           => p_assignment_user_key
6945   ,p_effective_date                => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
6946   ,p_change_reason                 => g_asg_rec.change_reason
6947   ,p_date_probation_end            => g_asg_rec.date_probation_end
6948   ,p_frequency                     => g_asg_rec.frequency
6949   ,p_internal_address_line         => g_asg_rec.internal_address_line
6950   ,p_manager_flag                  => g_asg_rec.manager_flag
6951   ,p_normal_hours                  => g_asg_rec.normal_hours
6952   ,p_perf_review_period            => g_asg_rec.perf_review_period
6953   ,p_perf_review_period_frequency  => g_asg_rec.perf_review_period_frequency
6954   ,p_probation_period              => g_asg_rec.probation_period
6955   ,p_probation_unit                => g_asg_rec.probation_unit
6956   ,p_sal_review_period             => g_asg_rec.sal_review_period
6957   ,p_sal_review_period_frequency   => g_asg_rec.sal_review_period_frequency
6958   ,p_source_type                   => g_asg_rec.source_type
6959   ,p_time_normal_finish            => g_asg_rec.time_normal_finish
6960   ,p_time_normal_start             => g_asg_rec.time_normal_start
6961   ,p_bargaining_unit_code          => g_asg_rec.bargaining_unit_code
6962   ,p_labour_union_member_flag      => g_asg_rec.labour_union_member_flag
6963   ,p_hourly_salaried_code          => g_asg_rec.hourly_salaried_code
6964   ,p_ass_attribute_category        => g_asg_rec.ass_attribute_category
6965   ,p_ass_attribute1                => g_asg_rec.ass_attribute1
6966   ,p_ass_attribute2                => g_asg_rec.ass_attribute2
6967   ,p_ass_attribute3                => g_asg_rec.ass_attribute3
6968   ,p_ass_attribute4                => g_asg_rec.ass_attribute4
6969   ,p_ass_attribute5                => g_asg_rec.ass_attribute5
6970   ,p_ass_attribute6                => g_asg_rec.ass_attribute6
6971   ,p_ass_attribute7                => g_asg_rec.ass_attribute7
6972   ,p_ass_attribute8                => g_asg_rec.ass_attribute8
6973   ,p_ass_attribute9                => g_asg_rec.ass_attribute9
6974   ,p_ass_attribute10               => g_asg_rec.ass_attribute10
6975   ,p_ass_attribute11               => g_asg_rec.ass_attribute11
6976   ,p_ass_attribute12               => g_asg_rec.ass_attribute12
6977   ,p_ass_attribute13               => g_asg_rec.ass_attribute13
6978   ,p_ass_attribute14               => g_asg_rec.ass_attribute14
6979   ,p_ass_attribute15               => g_asg_rec.ass_attribute15
6980   ,p_ass_attribute16               => g_asg_rec.ass_attribute16
6981   ,p_ass_attribute17               => g_asg_rec.ass_attribute17
6982   ,p_ass_attribute18               => g_asg_rec.ass_attribute18
6983   ,p_ass_attribute19               => g_asg_rec.ass_attribute19
6984   ,p_ass_attribute20               => g_asg_rec.ass_attribute20
6985   ,p_ass_attribute21               => g_asg_rec.ass_attribute21
6986   ,p_ass_attribute22               => g_asg_rec.ass_attribute22
6987   ,p_ass_attribute23               => g_asg_rec.ass_attribute23
6988   ,p_ass_attribute24               => g_asg_rec.ass_attribute24
6989   ,p_ass_attribute25               => g_asg_rec.ass_attribute25
6990   ,p_ass_attribute26               => g_asg_rec.ass_attribute26
6991   ,p_ass_attribute27               => g_asg_rec.ass_attribute27
6992   ,p_ass_attribute28               => g_asg_rec.ass_attribute28
6993   ,p_ass_attribute29               => g_asg_rec.ass_attribute29
6994   ,p_ass_attribute30               => g_asg_rec.ass_attribute30
6995   ,p_segment1                      => g_scl_rec.segment1
6996   ,p_segment2                      => g_scl_rec.segment2
6997   ,p_segment3                      => g_scl_rec.segment3
6998   ,p_segment4                      => g_scl_rec.segment4
6999   ,p_segment5                      => g_scl_rec.segment5
7000   ,p_segment6                      => g_scl_rec.segment6
7001   ,p_segment7                      => g_scl_rec.segment7
7002   ,p_segment8                      => g_scl_rec.segment8
7003   ,p_segment9                      => g_scl_rec.segment9
7004   ,P_SEGMENT10                     => g_scl_rec.segment10
7005   ,P_SEGMENT11                     => g_scl_rec.segment11
7006   ,P_SEGMENT12                     => g_scl_rec.segment12
7007   ,P_SEGMENT13                     => g_scl_rec.segment13
7008   ,P_SEGMENT14                     => g_scl_rec.segment14
7009   ,P_SEGMENT15                     => g_scl_rec.segment15
7010   ,P_SEGMENT16                     => g_scl_rec.segment16
7011   ,P_SEGMENT17                     => g_scl_rec.segment17
7012   ,P_SEGMENT18                     => g_scl_rec.segment18
7013   ,P_SEGMENT19                     => g_scl_rec.segment19
7014   ,P_SEGMENT20                     => g_scl_rec.segment20
7015   ,P_SEGMENT21                     => g_scl_rec.segment21
7016   ,P_SEGMENT22                     => g_scl_rec.segment22
7017   ,P_SEGMENT23                     => g_scl_rec.segment23
7018   ,P_SEGMENT24                     => g_scl_rec.segment24
7019   ,P_SEGMENT25                     => g_scl_rec.segment25
7020   ,P_SEGMENT26                     => g_scl_rec.segment26
7021   ,P_SEGMENT27                     => g_scl_rec.segment27
7022   ,P_SEGMENT28                     => g_scl_rec.segment28
7023   ,P_SEGMENT29                     => g_scl_rec.segment29
7024   ,P_SEGMENT30                     => g_scl_rec.segment30
7025   --$
7026   ,P_EMPLOYEE_CATEGORY             => g_asg_rec.employee_category
7027   ,P_ASSIGNMENT_NUMBER             => g_asg_rec.assignment_number
7028   ,P_COMMENTS                      => g_asg_comments
7029   ,P_SUPERVISOR_USER_KEY           => g_supervisor_user_key
7030 
7031   ,p_cagr_grade_def_id             => null
7032   ,p_con_seg_user_name             => null
7033   );
7034 
7035    p_user_sequence := p_user_sequence + 1;
7036 
7037    hr_utility.set_location('..Inserted into Hrdpp_Update_Emp_Asg', 10);
7038 
7039    Hrdpp_Update_Emp_Asg_Criteria.Insert_Batch_Lines
7040   (p_batch_id                => p_batch_id
7041   ,p_user_sequence           => p_user_sequence
7042   ,p_link_value              => p_link_value
7043   ,p_datetrack_update_mode   => 'CORRECTION'
7044   ,p_assignment_user_key     => p_assignment_user_key
7045   ,p_effective_date          => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
7046   ,p_segment1                => g_grp_rec.segment1
7047   ,p_segment2                => g_grp_rec.segment2
7048   ,p_segment3                => g_grp_rec.segment3
7049   ,p_segment4                => g_grp_rec.segment4
7050   ,p_segment5                => g_grp_rec.segment5
7051   ,p_segment6                => g_grp_rec.segment6
7052   ,p_segment7                => g_grp_rec.segment7
7053   ,p_segment8                => g_grp_rec.segment8
7054   ,p_segment9                => g_grp_rec.segment9
7055   ,p_segment10               => g_grp_rec.segment10
7056   ,p_segment11               => g_grp_rec.segment11
7057   ,p_segment12               => g_grp_rec.segment12
7058   ,p_segment13               => g_grp_rec.segment13
7059   ,p_segment14               => g_grp_rec.segment14
7060   ,p_segment15               => g_grp_rec.segment15
7061   ,p_segment16               => g_grp_rec.segment16
7062   ,p_segment17               => g_grp_rec.segment17
7063   ,p_segment18               => g_grp_rec.segment18
7064   ,p_segment19               => g_grp_rec.segment19
7065   ,p_segment20               => g_grp_rec.segment20
7066   ,p_segment21               => g_grp_rec.segment21
7067   ,p_segment22               => g_grp_rec.segment22
7068   ,p_segment23               => g_grp_rec.segment23
7069   ,p_segment24               => g_grp_rec.segment24
7070   ,p_segment25               => g_grp_rec.segment25
7071   ,p_segment26               => g_grp_rec.segment26
7072   ,p_segment27               => g_grp_rec.segment27
7073   ,p_segment28               => g_grp_rec.segment28
7074   ,p_segment29               => g_grp_rec.segment29
7075   ,p_segment30               => g_grp_rec.segment30
7076   ,p_concat_segments         => g_grp_rec.group_name
7077   ,p_special_ceiling_step_id => g_asg_rec.special_ceiling_step_id
7078   ,p_people_group_id         => g_asg_rec.people_group_id
7079   ,p_grade_name              => g_wstr_names.grade_name
7080   ,p_position_name           => g_wstr_names.position_name
7081   ,p_job_name                => g_wstr_names.job_name
7082   ,p_payroll_name            => g_wstr_names.payroll_name
7083   ,p_location_code           => g_wstr_names.location_code
7084   ,p_organization_name       => g_wstr_names.organization_name
7085   ,p_pay_basis_name          => g_wstr_names.pay_basis_name
7086   --$
7087   ,P_EMPLOYMENT_CATEGORY     => g_asg_rec.assignment_category
7088   ,p_language_code           => userenv('LANG')
7089   ,p_con_seg_user_name       => null
7090    );
7091   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
7092 
7093 end Upd_Batch_Employee_Asg;
7094 -- =============================================================================
7095 -- Update_Batch_Assignment:
7096 -- =============================================================================
7097 procedure Update_Batch_Assignment
7098          (p_effective_date        in date
7099          ,p_business_group_id     in number
7100          ,p_person_id             in number
7101          ,p_batch_id              in number
7102          ,p_user_sequence         in out nocopy number
7103          ,p_link_value            in number
7104          ,p_assignment_user_key   in varchar2
7105          ,p_action_mode           in varchar2
7106          ) as
7107 
7108   cursor csr_asg (c_assignment_number in varchar2
7109                  ,c_person_id         in number
7110                  ,c_business_group_id in number
7111                  ,c_effective_date    in date
7112                  ) is
7113   select *
7114     from per_all_assignments_f paf
7115    where paf.person_id = c_person_id
7116      and paf.assignment_number = c_assignment_number
7117      and paf.business_group_id = c_business_group_id
7118      and c_effective_date between paf.effective_start_date
7119                               and paf.effective_end_date;
7120 
7121   cursor csr_asg_id (c_assignment_id in number
7122                  ,c_person_id         in number
7123                  ,c_business_group_id in number
7124                  ,c_effective_date    in date
7125                  ) is
7126   select *
7127     from per_all_assignments_f paf
7128    where paf.person_id = c_person_id
7129      and paf.assignment_id = c_assignment_id
7130      and paf.business_group_id = c_business_group_id
7131      and c_effective_date between paf.effective_start_date
7132                               and paf.effective_end_date;
7133 
7134   l_asg_rec                csr_asg%rowtype;
7135   l_AsgUpdCrit_Api         t_AsgUpdCrit_Api;
7136   l_proc_name constant     varchar2(150) := g_pkg||'Update_Batch_Assignment';
7137   l_datetrack_update_mode  varchar2(150);
7138   l_dt_correction          boolean;
7139   l_dt_update              boolean;
7140   l_dt_upd_override        boolean;
7141   l_upd_chg_ins            boolean;
7142   --$
7143   e_sec_asg                exception;
7144   l_error_mesg              varchar2(2000);
7145   l_secondary              boolean;
7146 begin
7147   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
7148 
7149   if g_asg_rec.organization_id is null or
7150     --$ Commented the following condition
7151      -- g_asg_rec.assignment_status_type_id is null or
7152      g_asg_rec.assignment_number is null then
7153      Hr_Utility.set_location('Leaving: '||l_proc_name, 6);
7154      return;
7155   end if;
7156 
7157   if g_asg_rec.assignment_number is null AND g_migration_flag = 'N' then
7158           hr_utility.set_location('Inside else ', 7);
7159           hr_utility.set_location('The assignment id is : '||g_asg_rec.assignment_id, 8);
7160   	      open csr_asg_id (c_assignment_id => g_asg_rec.assignment_id
7161               ,c_person_id         => p_person_id
7162               ,c_business_group_id => p_business_group_id
7163               ,c_effective_date    => p_effective_date
7164               );
7165          fetch csr_asg_id into l_asg_rec;
7166          if csr_asg_id%notfound then
7167          close csr_asg_id;
7168          l_secondary := true;
7169          else
7170          close csr_asg_id;
7171          l_secondary := false;
7172          end if;
7173   else
7174   	  open csr_asg (c_assignment_number => g_asg_rec.assignment_number
7175                ,c_person_id         => p_person_id
7176                ,c_business_group_id => p_business_group_id
7177                ,c_effective_date    => p_effective_date
7178                );
7179   	  fetch csr_asg into l_asg_rec;
7180       if csr_asg%notfound then
7181           close csr_asg;
7182           l_secondary := true;
7183       else
7184           close csr_asg;
7185           l_secondary := false;
7186       end if;
7187   end if;
7188 
7189  /* if g_migration_flag = 'Y' then
7190       open csr_asg (c_assignment_number => g_asg_rec.assignment_number
7191                ,c_person_id         => p_person_id
7192                ,c_business_group_id => p_business_group_id
7193                ,c_effective_date    => p_effective_date
7194                );
7195       fetch csr_asg into l_asg_rec;
7196       if csr_asg%notfound then
7197          close csr_asg;
7198          l_secondary := true;
7199       else
7200          close csr_asg;
7201          l_secondary := false;
7202       end if;
7203   else
7204       open csr_asg_id (c_assignment_id => g_asg_rec.assignment_id
7205                ,c_person_id         => p_person_id
7206                ,c_business_group_id => p_business_group_id
7207                ,c_effective_date    => p_effective_date
7208                );
7209       fetch csr_asg_id into l_asg_rec;
7210       if csr_asg_id%notfound then
7211          close csr_asg_id;
7212          l_secondary := true;
7213       else
7214          close csr_asg_id;
7215          l_secondary := false;
7216       end if;
7217   end if ;*/
7218   if l_secondary then
7219     Hr_Utility.set_location('Leaving: '||l_proc_name, 7);
7220     --$
7221     l_error_mesg := 'Use direct API mode to create secondary assignments';
7222         raise e_sec_asg;
7223     return;
7224   else
7225     g_asg_rec.person_id := l_asg_rec.person_id;
7226     g_asg_rec.business_group_id := l_asg_rec.business_group_id;
7227     g_asg_rec.assignment_id := l_asg_rec.assignment_id;
7228     --g_asg_rec.assignment_status_type_id := l_asg_rec.assignment_status_type_id;
7229 
7230     Dt_Api.Find_DT_Upd_Modes
7231     (p_effective_date        => p_effective_date
7232     ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
7233     ,p_base_key_column       => 'ASSIGNMENT_ID'
7234     ,p_base_key_value        => g_asg_rec.assignment_id
7235     ,p_correction            => l_dt_correction
7236     ,p_update                => l_dt_update
7237     ,p_update_override       => l_dt_upd_override
7238     ,p_update_change_insert  => l_upd_chg_ins
7239      );
7240     if l_dt_update then
7241        l_datetrack_update_mode := 'UPDATE';
7242     elsif l_dt_upd_override or
7243           l_upd_chg_ins then
7244                --Else USE Correction Mode
7245         l_datetrack_update_mode := 'CORRECTION';
7246        hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 8);
7247     else
7248        l_datetrack_update_mode := 'CORRECTION';
7249     end if;
7250   end if;
7251 
7252   if l_asg_rec.assignment_type ='E' then
7253      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7254      hr_pump_utils.add_user_key
7255      (p_user_key_value => p_assignment_user_key
7256      ,p_unique_key_id  => l_asg_rec.assignment_id
7257       );
7258 
7259      Upd_Batch_Employee_Asg
7260      (p_batch_id              => p_batch_id
7261      ,p_user_sequence         => p_user_sequence
7262      ,p_link_value            => p_link_value
7263      ,p_assignment_user_key   => p_assignment_user_key
7264      ,p_action_mode           => p_action_mode
7265      ,p_datetrack_update_mode => l_datetrack_update_mode
7266       );
7267      else
7268        raise e_upl_not_allowed;
7269      end if;
7270   elsif l_asg_rec.assignment_type ='C' then
7271      null;
7272   elsif l_asg_rec.assignment_type ='A' then
7273      null;
7274   end if;
7275 
7276   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
7277 
7278   --$
7279   exception
7280   when e_sec_asg then
7281     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7282     hr_utility.set_message_token('GENERIC_TOKEN',l_error_mesg);
7283     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
7284     hr_utility.raise_error;
7285 end Update_Batch_Assignment;
7286 
7287 -- =============================================================================
7288 -- DataPump_API_Call: p_data_pump_batch_line_id is used as link_value_id in the
7289 -- procedure as in future we may have to have it as batch_line_ids concatenated
7290 -- string.
7291 -- =============================================================================
7292 procedure DataPump_API_Call
7293          (p_data_pump_batch_line_id in varchar2
7294          ,p_batch_id                in number
7295          ,p_dup_party_id            in number
7296          ,p_dup_person_id           in number
7297          ,p_contact_name            in varchar
7298          ,p_dp_mode                 in varchar
7299          ,p_adjusted_svc_date       in date
7300 --$update batch entry
7301          ,p_batch_link              in number
7302          ) as
7303   --
7304   -- Cursor gets the link_value for the record. It is the value 1
7305   -- added to the maximum value of Link_Value for that batch_id
7306   --
7307   cursor csr_get_link_value (c_batch_id number) is
7308   select Max(link_value) + 1
7309     from hr_pump_batch_lines
7310    where batch_id = c_batch_id;
7311 
7312   l_proc_name  constant     varchar2(150):= g_pkg ||'DataPump_API_Call';
7313   l_person_user_key         varchar2(240);
7314   l_assignment_user_key     varchar2(240);
7315   l_application_user_key    varchar2(240);
7316   l_address_user_key        varchar2(240);
7317   l_contact_key             varchar2(240);
7318   l_xtra_info_key           varchar2(240);
7319   l_temp                    varchar2(240);
7320   l_datetrack_update_mode   varchar2(50);
7321 
7322   l_hire_Into_Employee      boolean;
7323   l_Apply_ForJob            boolean;
7324   l_Convert_To_CWK          boolean;
7325   l_Per_Exists_InHR         boolean;
7326   l_hire_Applicant          boolean;
7327   l_Convert_To_Applicant    boolean;
7328 
7329   l_Input_PerType           varchar2(90);
7330   l_action_mode             varchar2(90);
7331   l_cur_rec                 per_all_people_f%rowtype;
7332 
7333   l_user_person_type        per_person_types.user_person_type%type;
7334   l_user_sequence           number(10);
7335   l_link_value              number;
7336   l_error_mesg              varchar2(2000);
7337   e_hire_applicant          exception;
7338   e_apply_for_job           exception;
7339   e_cwk                     exception;
7340 begin
7341   hr_utility.set_location('Entering: ' || l_proc_name, 5);
7342 
7343   l_user_sequence := 1;
7344   --
7345   -- Creating User Keys for Person, Address, Assignment and Contact
7346   --
7347   l_temp := To_Char(Sysdate,'J')||
7348             to_char(systimestamp, 'HH24MISSFF3')||--To_Char(Sysdate,'HH24MISSD')||
7349             DBMS_Utility.get_Hash_Value(g_per_rec.last_name||
7350                                         g_per_rec.sex||
7351                                         g_per_rec.first_name,0,1000);
7352 
7353 --hr_utility.trace('p_batch_id: '||p_batch_id);
7354 
7355   l_person_user_key     := 'HROSS~PER~'||l_temp;
7356   l_address_user_key    := 'HROSS~ADD~'||l_temp;
7357   l_assignment_user_key := 'HROSS~ASG~'||l_temp;
7358   l_application_user_key:= 'HROSS~APL~'||l_temp;
7359   l_contact_key         := 'HROSS~CNT~'||l_temp;
7360   l_xtra_info_key       := 'HROSS~XTR~'||l_temp;
7361   --$ To upload supervisor id use global var
7362   g_supervisor_user_key := 'HROSS~SUP~'||l_temp;
7363 
7364   if g_debug then
7365     hr_utility.set_location(' l_person_user_key: ' || l_person_user_key, 10);
7366     hr_utility.set_location(' l_address_user_key: ' || l_address_user_key, 10);
7367     hr_utility.set_location(' l_assignment_user_key: ' || l_assignment_user_key, 10);
7368     hr_utility.set_location(' l_contact_key: ' || l_contact_key, 10);
7369     hr_utility.set_location(' l_xtra_info_key: ' || l_xtra_info_key, 10);
7370   end if;
7371   --
7372   -- Get the User Person Type for the id passed
7373   --
7374   open  csr_per_type(g_per_rec.person_type_id
7375                     ,g_per_rec.business_group_id);
7376   fetch csr_per_type into l_user_person_type;
7377   close csr_per_type;
7378   --
7379   -- Get the Link value for this record
7380   --
7381   open  csr_get_link_value (p_batch_id);
7382   fetch csr_get_link_value into l_link_value;
7383   close csr_get_link_value;
7384   -- If first record is being entered then link_value returned from cursor
7385   -- will be null, hence we set it to 1
7386   if l_link_value is null then
7387      l_link_value := 1;
7388   end if;
7389 
7390 --$ Update Batch Entry in case Corrections are to be made for a record
7391   if p_batch_link is not null then
7392  --Delete old records in batch lines for this batch id and link value
7393  --There  is a parent-child relationship between tables hr_pump_batch_line_user_keys and hr_pump_batch_lines
7394  --w.r.t. batch_line_id
7395  --So, first remove data from hr_pump_batch_line_user_keys and then from hr_pump_batch_lines
7396 
7397  delete from hr_pump_batch_line_user_keys where batch_line_id in (
7398   select batch_line_id from hr_pump_batch_lines where batch_id = p_batch_id
7399     and link_value = p_batch_link );
7400 
7401  delete from hr_pump_batch_lines where batch_id = p_batch_id and
7402          link_value = p_batch_link;
7403      --Now, use same link value to insert the corrected record and hence
7404      --new batch lines
7405      l_link_value := p_batch_link;
7406   end if;
7407 
7408   if g_debug then
7409      hr_utility.set_location(' l_user_person_type: '|| l_user_person_type, 15);
7410      hr_utility.set_location(' l_link_value: '|| l_link_value, 15);
7411   end if;
7412 
7413   --$ Get the value of "Benefit Group Name" from ID if not null
7414   if g_per_rec.benefit_group_id is not null then
7415      open csr_get_benefit_name (g_per_rec.benefit_group_id,
7416                                 g_business_group_id);
7417      fetch csr_get_benefit_name into g_benefit_grp_name;
7418      close csr_get_benefit_name;
7419   else
7420      g_benefit_grp_name := null;
7421   end if;
7422 
7423   --
7424   -- Get the names of Work Structures based on the ids based.
7425   --
7426   Get_WrkStrs_Names;
7427   --
7428   -- If person id is passed check the creating person type with the person
7429   -- type of the person present in HRMS, to select the appropiate action.
7430   --
7431   Chk_Person_InHR
7432   (p_dup_person_id        => p_dup_person_id
7433   ,p_dup_party_id         => p_dup_party_id
7434   ,p_effective_date       => g_per_rec.start_date
7435   ,p_business_group_id    => g_business_group_id
7436   -- Out
7437   ,p_Input_PerType        => l_Input_PerType
7438   ,p_hire_Into_Employee   => l_hire_Into_Employee
7439   ,p_hire_Applicant       => l_hire_Applicant
7440   ,p_Convert_To_Applicant => l_Convert_To_Applicant
7441   ,p_Apply_For_Job        => l_Apply_ForJob
7442   ,p_Convert_To_CWK       => l_Convert_To_CWK
7443   ,p_Per_Exists_InHR      => l_Per_Exists_InHR
7444   );
7445   --
7446     --hr_utility.trace(' After Chk_Person_InHR call');
7447     --hr_utility.trace('$$_PSG l_Input_PerType ='||l_Input_PerType);
7448 
7449   Get_DataTrack_Mode
7450   (p_datetrack_update_mode => l_datetrack_update_mode
7451     );
7452   --
7453   if g_debug then
7454     hr_utility.set_location(' p_batch_id     : ' || p_batch_id, 20);
7455     hr_utility.set_location(' l_user_sequence: ' || l_user_sequence, 20);
7456     hr_utility.set_location(' l_link_value   : ' || l_link_value, 20);
7457     hr_utility.set_location(' l_datetrack_update_mode: ' || l_datetrack_update_mode, 20);
7458   end if;
7459   --
7460   -- Update existing person
7461   --
7462   if l_Input_PerType = 'UPD_PERSON' then
7463      hr_pump_utils.add_user_key
7464      (p_user_key_value => l_person_user_key
7465      ,p_unique_key_id  => g_per_rec.person_id
7466       );
7467      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7468      Upd_Batch_Person
7469      (p_batch_id                => p_batch_id
7470      ,p_user_sequence           => l_user_sequence
7471      ,p_link_value              => l_link_value
7472      ,p_person_user_key         => l_person_user_key
7473      ,p_user_person_type        => l_user_person_type
7474      ,p_datetrack_update_mode   => l_datetrack_update_mode
7475      ,p_adjusted_svc_date       =>  p_adjusted_svc_date   --Added by pkagrawa
7476       );
7477      else
7478      raise e_upl_not_allowed;
7479      end if;
7480      l_user_sequence := l_user_sequence + 1;
7481 
7482 
7483      --
7484      -- Insert/Update Primary Address
7485      --
7486      InsUpd_Batch_Address
7487      (p_batch_id             => p_batch_id
7488      ,p_user_sequence        => l_user_sequence
7489      ,p_link_value           => l_link_value
7490      ,p_person_user_key      => l_person_user_key
7491      ,p_address_user_key     => l_address_user_key
7492      );
7493      --
7494      -- Update the Person Assignment(EMP, APL or CWK Asg)
7495      --
7496      l_user_sequence := l_user_sequence + 1;
7497 
7498    --$ while updating assignment pass assignment effective start date as obtained
7499    -- from spreadsheet by default and if it is null then use person start date as
7500    -- assignment effective start date
7501 
7502      Update_Batch_Assignment
7503      (p_effective_date        => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
7504      ,p_business_group_id     => g_per_rec.business_group_id
7505      ,p_person_id             => g_per_rec.person_id
7506      ,p_batch_id              => p_batch_id
7507      ,p_user_sequence         => l_user_sequence
7508      ,p_link_value            => l_link_value
7509      ,p_assignment_user_key   => l_assignment_user_key
7510      ,p_action_mode           => l_action_mode
7511       );
7512   end if;
7513   --
7514   -- Creating an Employee
7515   --
7516   if l_Input_PerType = 'EMP' then
7517      if l_hire_Into_Employee then
7518         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7519         l_action_mode := 'HIRE_INTO_JOB';
7520         else
7521         raise e_upl_not_allowed;
7522         end if;
7523      elsif l_hire_Applicant then
7524         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7525         l_action_mode := 'HIRE_APPLICANT';
7526         else
7527         raise e_upl_not_allowed;
7528         end if;
7529      else
7530         if (g_crt_upd = 'C') then
7531         l_action_mode := 'CREATE_EMPLOYEE';
7532         else
7533         raise e_crt_per_not_allowed;
7534         end if;
7535      end if;
7536      hr_utility.set_location(l_proc_name, 25);
7537      --
7538 
7539   --hr_utility.trace(' l_action_mode ='||l_action_mode);
7540 
7541      if l_action_mode in ('CREATE_EMPLOYEE',
7542                           'HIRE_INTO_JOB') then
7543         InsUpd_Batch_Employee
7544         (p_batch_id              => p_batch_id
7545         ,p_user_sequence         => l_user_sequence
7546         ,p_link_value            => l_link_value
7547         ,p_assignment_user_key   => l_assignment_user_key
7548         ,p_person_user_key       => l_person_user_key
7549         ,p_user_person_type      => l_user_person_type
7550         ,p_action_mode           => l_action_mode
7551         ,p_datetrack_update_mode => l_datetrack_update_mode
7552         ,p_cur_rec               => l_cur_rec
7553         ,p_adjusted_svc_date       =>  p_adjusted_svc_date   --Added by pkagrawa
7554          );
7555      elsif l_action_mode = 'HIRE_APPLICANT' then
7556         l_error_mesg := 'Use direct API mode call to hire an applicant';
7557         raise e_hire_applicant;
7558      end if;
7559      --
7560      -- Insert/Update Person Primary Address
7561      --
7562      hr_utility.set_location(l_proc_name, 30);
7563      l_user_sequence := l_user_sequence + 1;
7564      --
7565      -- Insert/Update Primary Address
7566      --
7567      InsUpd_Batch_Address
7568      (p_batch_id             => p_batch_id
7569      ,p_user_sequence        => l_user_sequence
7570      ,p_link_value           => l_link_value
7571      ,p_person_user_key      => l_person_user_key
7572      ,p_address_user_key     => l_address_user_key
7573       );
7574      --
7575      -- Update the Employee Assignment
7576      --
7577      hr_utility.set_location(l_proc_name, 35);
7578      l_datetrack_update_mode := 'CORRECTION';
7579      l_user_sequence := l_user_sequence + 1;
7580 
7581      if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7582      Upd_Batch_Employee_Asg
7583      (p_batch_id              => p_batch_id
7584      ,p_user_sequence         => l_user_sequence
7585      ,p_link_value            => l_link_value
7586      ,p_assignment_user_key   => l_assignment_user_key
7587      ,p_action_mode           => l_action_mode
7588      ,p_datetrack_update_mode => l_datetrack_update_mode
7589       );
7590      else
7591        raise e_upl_not_allowed;
7592      end if;
7593   end if;
7594   --
7595   -- Creating an Applicant for a Job
7596   --
7597   --hr_utility.trace(' l_Input_PerType ='||l_Input_PerType);
7598 
7599   if l_Input_PerType = 'APL' then
7600      if l_Convert_To_Applicant or
7601         l_Apply_ForJob         then
7602         l_action_mode := 'APPLY_FOR_JOB';
7603         l_error_mesg := 'Use direct API mode to convert an existing person
7604                 into an Applicant.';
7605         raise e_apply_for_job;
7606      else
7607       if (g_crt_upd = 'C') then
7608        l_action_mode := 'CREATE_APPLICANT';
7609       else
7610         raise e_crt_per_not_allowed;
7611       end if;
7612      end if;
7613      --
7614      -- Create/Convert the person into an applicant
7615      --
7616      InsUpd_Batch_Applicant
7617      (p_batch_id                => p_batch_id
7618      ,p_user_sequence           => l_user_sequence
7619      ,p_link_value              => l_link_value
7620      ,p_assignment_user_key     => l_assignment_user_key
7621      ,p_person_user_key         => l_person_user_key
7622      ,p_user_person_type        => l_user_person_type
7623      ,p_action_mode             => l_action_mode
7624      ,p_datetrack_update_mode   => l_datetrack_update_mode
7625      ,p_vacancy_user_key        => null
7626      ,p_application_user_key    => l_application_user_key
7627       );
7628      --
7629      -- Insert/Update Person Primary Address
7630      --
7631      hr_utility.set_location(l_proc_name, 30);
7632      l_user_sequence := l_user_sequence + 1;
7633 
7634      InsUpd_Batch_Address
7635      (p_batch_id         => p_batch_id
7636      ,p_user_sequence    => l_user_sequence
7637      ,p_link_value       => l_link_value
7638      ,p_person_user_key  => l_person_user_key
7639      ,p_address_user_key => l_address_user_key
7640      );
7641      --
7642      -- Update the Applicant assignment
7643      --
7644   end if;
7645   --
7646   -- Create the contact person only if the person does exists
7647   --
7648   if l_Input_PerType = 'OTHER' then
7649      if not l_Per_Exists_InHR then
7650        if (g_crt_upd = 'C') then
7651        InsUpd_Batch_ContactPerson
7652        (p_batch_id                => p_batch_id
7653        ,p_data_pump_batch_line_id => p_data_pump_batch_line_id
7654        ,p_user_sequence           => l_user_sequence
7655        ,p_link_value              => l_link_value
7656        ,p_person_user_key         => l_person_user_key
7657        ,p_user_person_type        => l_user_person_type
7658         );
7659        else
7660        raise e_crt_per_not_allowed;
7661        end if;
7662      else
7663        if (g_crt_upd = 'C' or g_crt_upd = 'U') then
7664        hr_pump_utils.add_user_key
7665        (p_user_key_value => l_person_user_key
7666        ,p_unique_key_id  => g_per_rec.person_id
7667         );
7668        Upd_Batch_Person
7669        (p_batch_id                => p_batch_id
7670        ,p_user_sequence           => l_user_sequence
7671        ,p_link_value              => l_link_value
7672        ,p_person_user_key         => l_person_user_key
7673        ,p_user_person_type        => l_user_person_type
7674        ,p_datetrack_update_mode   => l_datetrack_update_mode
7675         );
7676        else
7677        raise e_upl_not_allowed;
7678        end if;
7679      end if;
7680 
7681      hr_utility.set_location(l_proc_name, 30);
7682      l_user_sequence := l_user_sequence + 1;
7683      --
7684      -- Insert/Update Primary Address
7685      --
7686      InsUpd_Batch_Address
7687      (p_batch_id             => p_batch_id
7688      ,p_user_sequence        => l_user_sequence
7689      ,p_link_value           => l_link_value
7690      ,p_person_user_key      => l_person_user_key
7691      ,p_address_user_key     => l_address_user_key
7692      );
7693   end if;
7694   --
7695   -- Creating a Contingent Worker
7696   --
7697   if l_Input_PerType = 'CWK' then
7698      if l_Convert_To_CWK then
7699        l_action_mode := 'CONVERT_TO_CWK';
7700      else
7701        l_action_mode := 'CREATE_CWK';
7702      end if;
7703      l_error_mesg := 'Use Direct API mode to create Contingent worker or '||
7704                      'to convert an existing person into Contingent worker';
7705      raise e_cwk;
7706      --
7707      -- Create/Convert the person into an Contigent Worker
7708      --
7709 
7710      --
7711      -- Update/Insert Address
7712      --
7713 
7714      --
7715      -- Update the Contingent Worker assignment
7716      --
7717   end if;
7718 
7719   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
7720 
7721 exception
7722   when e_hire_applicant then
7723     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7724     hr_utility.set_message_token('GENERIC_TOKEN',l_error_mesg);
7725     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
7726     hr_utility.raise_error;
7727   when e_apply_for_job then
7728     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7729     hr_utility.set_message_token('GENERIC_TOKEN',l_error_mesg);
7730     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
7731     hr_utility.raise_error;
7732   when e_cwk then
7733     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7734     hr_utility.set_message_token('GENERIC_TOKEN',l_error_mesg);
7735     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
7736     hr_utility.raise_error;
7737   when Others then
7738     hr_utility.set_location('Leaving: ' || l_proc_name, 90);
7739     raise;
7740 
7741 end DataPump_API_Call;
7742 
7743 -- =============================================================================
7744 -- ~ HR_DataPumpErr:
7745 -- =============================================================================
7746 procedure HR_DataPumpErr
7747           (p_data_pump_batch_line_id in varchar2
7748           ,p_batch_id                in number
7749           ,p_contact_name            in varchar
7750 --          ,p_dp_mode                 IN Varchar
7751           ,p_adjusted_svc_date       in date
7752           ) as
7753 
7754   -- Cursor gets the mode in which data was entered intially in
7755   -- DP interface tables
7756   cursor csr_get_dp_mode (c_batch_id   in number
7757                          ,c_link_value in number) is
7758   select 'CREATE'
7759     from hr_api_modules
7760    where module_name    = 'CREATE_EMPLOYEE'
7761      and module_package = 'HR_EMPLOYEE_API'
7762      and api_module_id in (select api_module_id
7763                              from hr_pump_batch_lines
7764                             where batch_id   = c_batch_id
7765                               and link_value = c_link_value);
7766 
7767   -- Cursor to get all the api_ids which have LINE_STATUS in status 'E' or 'U'
7768   cursor csr_get_api_names (c_batch_id   in number
7769                            ,c_link_value in number) is
7770   select module_name
7771     from hr_pump_batch_lines hpbl
7772         ,hr_api_modules      ham
7773    where batch_id    = c_batch_id
7774      and link_value  = c_link_value
7775      and line_status in ('U', 'E')
7776      and hpbl.api_module_id = ham.api_module_id;
7777 
7778   -- Cursor to get previous data from hrdpv_hire_into_job
7779   cursor csr_get_hire_job_data (c_batch_id   in number
7780                                ,c_link_value in number) is
7781   select *
7782     from hrdpv_hire_into_job
7783    where batch_id   = c_batch_id
7784      and link_value = c_link_value;
7785 
7786   l_dp_hire_job_rec      hrdpv_hire_into_job%rowtype;
7787 
7788   -- Cursor to get previous data from hrdpv_create_employee
7789   cursor csr_get_create_emp_data (c_batch_id   in number
7790                                  ,c_link_value in number) is
7791   select *
7792     from hrdpv_create_employee
7793    where batch_id   = c_batch_id
7794      and link_value = c_link_value;
7795 
7796   l_dp_crt_emp_rec       hrdpv_create_employee%rowtype;
7797 
7798   -- Cursor to get previous data from hrdpv_update_person
7799   cursor csr_get_update_per_data (c_batch_id   in number
7800                                  ,c_link_value in number) is
7801   select *
7802     from hrdpv_update_person
7803    where batch_id   = c_batch_id
7804      and link_value = c_link_value;
7805 
7806   l_dp_upd_per_rec       hrdpv_update_person%rowtype;
7807 
7808   -- Cursor to get previous data from hrdpv_update_person_address
7809   cursor csr_get_update_add_data (c_batch_id   in number
7810                                  ,c_link_value in number) is
7811   select *
7812     from hrdpv_update_person_address
7813    where batch_id   = c_batch_id
7814      and link_value = c_link_value;
7815 
7816   l_dp_upd_add_rec       hrdpv_update_person_address%rowtype;
7817 
7818   -- Cursor to get previous data from hrdpv_create_person_address
7819   cursor csr_get_create_add_data (c_batch_id   in number
7820                                  ,c_link_value in number) is
7821   select *
7822     from hrdpv_create_person_address
7823    where batch_id   = c_batch_id
7824      and link_value = c_link_value;
7825 
7826   l_dp_crt_add_rec       hrdpv_create_person_address%rowtype;
7827 
7828   -- Cursor to get previous data from hrdpv_update_emp_asg
7829   cursor csr_get_upd_asg_data (c_batch_id   in number
7830                               ,c_link_value in number) is
7831   select *
7832     from hrdpv_update_emp_asg
7833    where batch_id   = c_batch_id
7834      and link_value = c_link_value;
7835 
7836   l_dp_upd_asg_rec       hrdpv_update_emp_asg%rowtype;
7837 
7838   -- Cursor to get previous data from hrdpv_update_emp_asg_criteria
7839   cursor csr_get_upd_asg_crt_data (c_batch_id   in number
7840                                   ,c_link_value in number) is
7841   select *
7842     from hrdpv_update_emp_asg_criteria
7843    where batch_id   = c_batch_id
7844      and link_value = c_link_value;
7845 
7846   l_dp_upd_asg_crt_rec   hrdpv_update_emp_asg_criteria%rowtype;
7847 
7848   -- Cursor to get previous data from hrdpv_create_contact
7849   cursor csr_get_create_cnt_data (c_batch_id   in number
7850                                  ,c_link_value in number) is
7851   select *
7852     from hrdpv_create_contact
7853    where batch_id   = c_batch_id
7854      and link_value = c_link_value;
7855 
7856   l_dp_crt_cnt_rec       hrdpv_create_contact%rowtype;
7857 
7858   -- Cursor to get previous data from hrdpv_update_contact_relations
7859   cursor csr_get_update_cnt_data (c_batch_id   in number
7860                                  ,c_link_value in number) is
7861   select *
7862     from hrdpv_update_contact_relations
7863    where batch_id   = c_batch_id
7864      and link_value = c_link_value;
7865 
7866   l_dp_upd_cnt_rec      hrdpv_update_contact_relations%rowtype;
7867 
7868   l_proc_name  constant    varchar2(150):= g_pkg ||'HR_DataPumpErr';
7869 
7870   l_dp_mode                  varchar2(40);
7871   l_if_end_dated             varchar2(20);
7872   l_api_name                 hr_api_modules.module_name%type;
7873   l_user_person_type         per_person_types.user_person_type%type;
7874   l_pay_basis_name           per_pay_bases.name%type;
7875   l_organization_name        hr_all_organization_units.name%type;
7876   l_location_code            hr_locations_all.location_code%type;
7877   l_payroll_name             pay_payrolls_f.payroll_name%type;
7878   l_job_name                 per_jobs.name%type;
7879   l_position_name            per_positions.name%type;
7880   l_grade_name               per_grades.name%type;
7881 
7882   l_pradd_ovlapval_override  boolean;
7883 
7884 begin
7885   hr_utility.set_location('Entering: ' || l_proc_name, 10);
7886 
7887   -- Check if operation being corrected was insert or update because of
7888   -- duplicate person id based on the API_MODULE_ID in hr_pump_batch_lines
7889   -- and then set dp_mode flag respectively
7890 
7891   open csr_get_dp_mode (c_batch_id   => p_batch_id
7892                        ,c_link_value => p_data_pump_batch_line_id
7893                        );
7894   fetch csr_get_dp_mode into l_dp_mode;
7895   close csr_get_dp_mode;
7896 
7897   if l_dp_mode = null then
7898      l_dp_mode := 'UPDATE';
7899   end if;
7900 
7901   -- Cursor to get the User Person Type
7902   open  csr_per_type(g_per_rec.person_type_id
7903                     ,g_per_rec.business_group_id);
7904   fetch csr_per_type into l_user_person_type;
7905   close csr_per_type;
7906 
7907   -- If User hasn't entered the Employee Number, then get Employee Number
7908   -- for entered duplicate person id
7909   if g_per_rec.employee_number = null then
7910      open  csr_get_employee_num(c_person_id => g_per_rec.person_id);
7911      fetch csr_get_employee_num into g_per_rec.employee_number;
7912      close csr_get_employee_num;
7913   end if;
7914 
7915   -- Call a cursor to get all the API_MODULE_IDs for the respective batch_id
7916   -- where LINE_STATUS is either in 'E' (error) or in 'U' (unprocessed) mode
7917 
7918   open csr_get_api_names (c_batch_id   => p_batch_id
7919                          ,c_link_value => p_data_pump_batch_line_id
7920                          );
7921 
7922   -- For all the API_MODULE_IDs hence obtained run the cursor and call
7923   -- corresponding HR Data Pump Insert_Batch_Lines APIs. Before calling the
7924   -- Insert_Batch_Lines call the cursor to get the previous values in DP
7925   -- Interface Tables
7926   --
7927   -- NOTE : We will be calling the same "INSERT_BATCH_LINES" for updation
7928   --        as internally "INSERT_BATCH_LINES" deletes the previous entry
7929   --        for corresponding Batch_line_Id and makes a fresh entry.
7930   --        Hence, in the cursor we will temporarily store some of the data
7931   --        which we will require in newly created entry in HR_PUMP_BATCH_LINES
7932 
7933 
7934   loop
7935 
7936     fetch csr_get_api_names into l_api_name;
7937     exit when csr_get_api_names%notfound;
7938 
7939 
7940     -- Call if API_ID is 'Hire_Into_Job'
7941     if l_api_name = 'HIRE_INTO_JOB' then
7942 
7943        -- Call a cursor to get the current data in DP Interface Tables
7944        open  csr_get_hire_job_data (c_batch_id   => p_batch_id
7945                                    ,c_link_value => p_data_pump_batch_line_id);
7946        fetch csr_get_hire_job_data into l_dp_hire_job_rec;
7947        close csr_get_hire_job_data;
7948 
7949        -- Call Insert_Batch_lines
7950        Hrdpp_Hire_Into_Job.insert_batch_lines
7951        (p_batch_id                => p_batch_id
7952        ,p_data_pump_batch_line_id => l_dp_hire_job_rec.batch_line_id
7953        ,p_user_sequence           => l_dp_hire_job_rec.user_sequence
7954        ,p_link_value              => p_data_pump_batch_line_id
7955        ,p_effective_date          => g_per_rec.start_date
7956        ,p_object_version_number   => l_dp_hire_job_rec.p_object_version_number
7957        ,p_datetrack_update_mode   => l_dp_hire_job_rec.p_datetrack_update_mode
7958        ,p_employee_number         => g_per_rec.employee_number
7959        ,p_national_identifier     => g_per_rec.national_identifier
7960        ,p_per_information7        => null
7961        ,p_person_user_key         => l_dp_hire_job_rec.p_person_user_key
7962        ,p_user_person_type        => l_user_person_type
7963        ,p_assignment_user_key     => l_dp_hire_job_rec.p_assignment_user_key
7964        ,p_language_code           => Userenv('LANG')
7965        );
7966        /*
7967        InsUpd_Batch_Employee
7968        (p_batch_id                => p_batch_id
7969        ,p_data_pump_batch_line_id => l_dp_hire_job_rec.batch_line_id
7970        ,p_user_sequence           => l_dp_hire_job_rec.user_sequence
7971        ,p_link_value              => p_data_pump_batch_line_id
7972        ,p_assignment_user_key     => l_dp_hire_job_rec.p_assignment_user_key
7973        ,p_person_user_key         => l_dp_hire_job_rec.p_person_user_key
7974        ,p_user_person_type        => l_user_person_type
7975        ,p_action_mode             => 'HIRE_INTO_JOB'
7976        ,p_datetrack_update_mode   => l_datetrack_update_mode
7977        ,p_cur_rec                 => l_cur_rec
7978         );
7979         */
7980     end if;
7981 
7982     -- Call if API_ID is 'Create_Employee'
7983     if l_api_name = 'CREATE_EMPLOYEE' then
7984 
7985        open  csr_get_create_emp_data
7986               (c_batch_id   => p_batch_id
7987               ,c_link_value => p_data_pump_batch_line_id
7988                );
7989        fetch csr_get_create_emp_data into l_dp_crt_emp_rec;
7990        close csr_get_create_emp_data;
7991 
7992        Hrdpp_Create_Employee.Insert_Batch_Lines
7993        (p_batch_id                     => p_batch_id
7994        --l_dp_batch_line_id_emp
7995        ,p_data_pump_batch_line_id      => l_dp_crt_emp_rec.batch_line_id
7996        ,p_user_sequence                => l_dp_crt_emp_rec.user_sequence
7997        ,p_link_value                   => p_data_pump_batch_line_id
7998        ,p_hire_date                    => g_per_rec.start_date
7999        ,p_last_name                    => g_per_rec.last_name
8000        ,p_sex                          => g_per_rec.sex
8001        ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
8002        ,p_date_of_birth                => g_per_rec.date_of_birth
8003        ,p_email_address                => g_per_rec.email_address
8004        ,p_employee_number              => g_per_rec.employee_number
8005        ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
8006        ,p_first_name                   => g_per_rec.first_name
8007        ,p_known_as                     => g_per_rec.known_as
8008        ,p_marital_status               => g_per_rec.marital_status
8009        ,p_middle_names                 => g_per_rec.middle_names
8010        ,p_nationality                  => g_per_rec.nationality
8011        ,p_national_identifier          => g_per_rec.national_identifier
8012        ,p_previous_last_name           => g_per_rec.previous_last_name
8013        ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
8014        ,p_title                        => g_per_rec.title
8015        ,p_attribute_category           => g_per_rec.attribute_category
8016        ,p_attribute1                   => g_per_rec.attribute1
8017        ,p_attribute2                   => g_per_rec.attribute2
8018        ,p_attribute3                   => g_per_rec.attribute3
8019        ,p_attribute4                   => g_per_rec.attribute4
8020        ,p_attribute5                   => g_per_rec.attribute5
8021        ,p_attribute6                   => g_per_rec.attribute6
8022        ,p_attribute7                   => g_per_rec.attribute7
8023        ,p_attribute8                   => g_per_rec.attribute8
8024        ,p_attribute9                   => g_per_rec.attribute9
8025        ,p_attribute10                  => g_per_rec.attribute10
8026        ,p_attribute11                  => g_per_rec.attribute11
8027        ,p_attribute12                  => g_per_rec.attribute12
8028        ,p_attribute13                  => g_per_rec.attribute13
8029        ,p_attribute14                  => g_per_rec.attribute14
8030        ,p_attribute15                  => g_per_rec.attribute15
8031        ,p_attribute16                  => g_per_rec.attribute16
8032        ,p_attribute17                  => g_per_rec.attribute17
8033        ,p_attribute18                  => g_per_rec.attribute18
8034        ,p_attribute19                  => g_per_rec.attribute19
8035        ,p_attribute20                  => g_per_rec.attribute20
8036        ,p_attribute21                  => g_per_rec.attribute21
8037        ,p_attribute22                  => g_per_rec.attribute22
8038        ,p_attribute23                  => g_per_rec.attribute23
8039        ,p_attribute24                  => g_per_rec.attribute24
8040        ,p_attribute25                  => g_per_rec.attribute25
8041        ,p_attribute26                  => g_per_rec.attribute26
8042        ,p_attribute27                  => g_per_rec.attribute27
8043        ,p_attribute28                  => g_per_rec.attribute28
8044        ,p_attribute29                  => g_per_rec.attribute29
8045        ,p_attribute30                  => g_per_rec.attribute30
8046        ,p_per_information_category     => g_per_rec.per_information_category
8047        ,p_per_information1             => g_per_rec.per_information1
8048        ,p_per_information2             => g_per_rec.per_information2
8049        ,p_per_information3             => g_per_rec.per_information3
8050        ,p_per_information4             => g_per_rec.per_information4
8051        ,p_per_information5             => g_per_rec.per_information5
8052        ,p_per_information6             => g_per_rec.per_information6
8053        ,p_per_information7             => g_per_rec.per_information7
8054        ,p_per_information8             => g_per_rec.per_information8
8055        ,p_per_information9             => g_per_rec.per_information9
8056        ,p_per_information10            => g_per_rec.per_information10
8057        ,p_per_information11            => g_per_rec.per_information11
8058        ,p_per_information12            => g_per_rec.per_information12
8059        ,p_per_information13            => g_per_rec.per_information13
8060        ,p_per_information14            => g_per_rec.per_information14
8061        ,p_per_information15            => g_per_rec.per_information15
8062        ,p_per_information16            => g_per_rec.per_information16
8063        ,p_per_information17            => g_per_rec.per_information17
8064        ,p_per_information18            => g_per_rec.per_information18
8065        ,p_per_information19            => g_per_rec.per_information19
8066        ,p_per_information20            => g_per_rec.per_information20
8067        ,p_per_information21            => g_per_rec.per_information21
8068        ,p_per_information22            => g_per_rec.per_information22
8069        ,p_per_information23            => g_per_rec.per_information23
8070        ,p_per_information24            => g_per_rec.per_information24
8071        ,p_per_information25            => g_per_rec.per_information25
8072        ,p_per_information26            => g_per_rec.per_information26
8073        ,p_per_information27            => g_per_rec.per_information27
8074        ,p_per_information28            => g_per_rec.per_information28
8075        ,p_per_information29            => g_per_rec.per_information29
8076        ,p_per_information30            => g_per_rec.per_information30
8077        ,p_date_of_death                => g_per_rec.date_of_death
8078        ,p_background_check_status      => g_per_rec.background_check_status
8079        ,p_background_date_check        => g_per_rec.background_date_check
8080        ,p_blood_type                   => g_per_rec.blood_type
8081        ,p_fast_path_employee           => g_per_rec.fast_path_employee
8082        ,p_fte_capacity                 => g_per_rec.fte_capacity
8083        ,p_honors                       => g_per_rec.honors
8084        ,p_internal_location            => g_per_rec.internal_location
8085        ,p_last_medical_test_by         => g_per_rec.last_medical_test_by
8086        ,p_last_medical_test_date       => g_per_rec.last_medical_test_date
8087        ,p_mailstop                     => g_per_rec.mailstop
8088        ,p_office_number                => g_per_rec.office_number
8089        ,p_on_military_service          => g_per_rec.on_military_service
8090        ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
8091        ,p_projected_start_date         => g_per_rec.projected_start_date
8092        ,p_resume_exists                => g_per_rec.resume_exists
8093        ,p_resume_last_updated          => g_per_rec.resume_last_updated
8094        ,p_second_passport_exists       => g_per_rec.second_passport_exists
8095        ,p_student_status               => g_per_rec.student_status
8096        ,p_work_schedule                => g_per_rec.work_schedule
8097        ,p_suffix                       => g_per_rec.suffix
8098        ,p_receipt_of_death_cert_date   => g_per_rec.receipt_of_death_cert_date
8099        ,p_coord_ben_med_pln_no         => g_per_rec.coord_ben_med_pln_no
8100        ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
8101        ,p_coord_ben_med_ext_er         => g_per_rec.coord_ben_med_ext_er
8102        ,p_coord_ben_med_pl_name        => g_per_rec.coord_ben_med_pl_name
8103        ,p_coord_ben_med_insr_crr_name  => g_per_rec.coord_ben_med_insr_crr_name
8104        ,p_coord_ben_med_insr_crr_ident => g_per_rec.coord_ben_med_insr_crr_ident
8105        ,p_coord_ben_med_cvg_strt_dt    => g_per_rec.coord_ben_med_cvg_strt_dt
8106        ,p_coord_ben_med_cvg_end_dt     => g_per_rec.coord_ben_med_cvg_end_dt
8107        ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
8108        ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
8109        ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
8110        ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
8111        ,p_town_of_birth                => g_per_rec.town_of_birth
8112        ,p_region_of_birth              => g_per_rec.region_of_birth
8113        ,p_country_of_birth             => g_per_rec.country_of_birth
8114        ,p_global_person_id             => g_per_rec.global_person_id
8115        ,p_party_id                     => g_per_rec.party_id
8116        ,p_correspondence_language      => g_per_rec.correspondence_language
8117        ,p_benefit_group                => g_per_rec.benefit_group_id
8118        ,p_person_user_key              => l_dp_crt_emp_rec.p_person_user_key
8119        ,p_assignment_user_key          => l_dp_crt_emp_rec.p_assignment_user_key
8120        ,p_user_person_type             => l_user_person_type
8121        ,p_language_code                => Userenv('lang')
8122        ,p_vendor_name                  => null
8123        );
8124     end if;
8125 
8126     -- Call if API_ID is 'Update_Person'
8127     if l_api_name = 'UPDATE_PERSON' then
8128 
8129        open  csr_get_update_per_data(c_batch_id   => p_batch_id
8130                                     ,c_link_value => p_data_pump_batch_line_id
8131                                     );
8132        fetch csr_get_update_per_data into l_dp_upd_per_rec;
8133        close csr_get_update_per_data;
8134 
8135      Hrdpp_Update_Person.insert_batch_lines
8136      (p_batch_id                     => p_batch_id
8137      ,p_data_pump_batch_line_id      => l_dp_upd_per_rec.batch_line_id
8138      ,p_user_sequence                => l_dp_upd_per_rec.user_sequence
8139      ,p_link_value                   => p_data_pump_batch_line_id
8140      ,p_effective_date               => g_per_rec.start_date
8141      ,p_datetrack_update_mode        => l_dp_upd_per_rec.p_datetrack_update_mode
8142      ,p_party_id                     => g_per_rec.party_id
8143      ,p_employee_number              => g_per_rec.employee_number
8144      ,p_last_name                    => g_per_rec.last_name
8145      ,p_first_name                   => g_per_rec.first_name
8146      ,p_date_of_birth                => g_per_rec.date_of_birth
8147      ,p_marital_status               => g_per_rec.marital_status
8148      ,p_middle_names                 => g_per_rec.middle_names
8149      ,p_sex                          => g_per_rec.sex
8150      ,p_title                        => g_per_rec.title
8151      ,p_nationality                  => g_per_rec.nationality
8152      ,p_previous_last_name           => g_per_rec.previous_last_name
8153      ,p_known_as                     => g_per_rec.known_as
8154      ,p_email_address                => g_per_rec.email_address
8155      ,p_registered_disabled_flag     => g_per_rec.registered_disabled_flag
8156      ,p_date_employee_data_verified  => g_per_rec.date_employee_data_verified
8157      ,p_expense_check_send_to_addres => g_per_rec.expense_check_send_to_address
8158       -- Person DDF
8159      ,p_per_information_category     => g_per_rec.per_information_category
8160      ,p_per_information1             => g_per_rec.per_information1
8161      ,p_per_information2             => g_per_rec.per_information2
8162      ,p_per_information3             => g_per_rec.per_information3
8163      ,p_per_information4             => g_per_rec.per_information4
8164      ,p_per_information5             => g_per_rec.per_information5
8165      ,p_per_information6             => g_per_rec.per_information6
8166      ,p_per_information7             => g_per_rec.per_information7
8167      ,p_per_information8             => g_per_rec.per_information8
8168      ,p_per_information9             => g_per_rec.per_information9
8169      ,p_per_information10            => g_per_rec.per_information10
8170      ,p_per_information11            => g_per_rec.per_information11
8171      ,p_per_information12            => g_per_rec.per_information12
8172      ,p_per_information13            => g_per_rec.per_information13
8173      ,p_per_information14            => g_per_rec.per_information14
8174      ,p_per_information15            => g_per_rec.per_information15
8175      ,p_per_information16            => g_per_rec.per_information16
8176      ,p_per_information17            => g_per_rec.per_information17
8177      ,p_per_information18            => g_per_rec.per_information18
8178      ,p_per_information19            => g_per_rec.per_information19
8179      ,p_per_information20            => g_per_rec.per_information20
8180      ,p_per_information21            => g_per_rec.per_information21
8181      ,p_per_information22            => g_per_rec.per_information22
8182      ,p_per_information23            => g_per_rec.per_information23
8183      ,p_per_information24            => g_per_rec.per_information24
8184      ,p_per_information25            => g_per_rec.per_information25
8185      ,p_per_information26            => g_per_rec.per_information26
8186      ,p_per_information27            => g_per_rec.per_information27
8187      ,p_per_information28            => g_per_rec.per_information28
8188      ,p_per_information29            => g_per_rec.per_information29
8189      ,p_per_information30            => g_per_rec.per_information30
8190       -- Person DF
8191      ,p_attribute_category           => g_per_rec.attribute_category
8192      ,p_attribute1                   => g_per_rec.attribute1
8193      ,p_attribute2                   => g_per_rec.attribute2
8194      ,p_attribute3                   => g_per_rec.attribute3
8195      ,p_attribute4                   => g_per_rec.attribute4
8196      ,p_attribute5                   => g_per_rec.attribute5
8197      ,p_attribute6                   => g_per_rec.attribute6
8198      ,p_attribute7                   => g_per_rec.attribute7
8199      ,p_attribute8                   => g_per_rec.attribute8
8200      ,p_attribute9                   => g_per_rec.attribute9
8201      ,p_attribute10                  => g_per_rec.attribute10
8202      ,p_attribute11                  => g_per_rec.attribute11
8203      ,p_attribute12                  => g_per_rec.attribute12
8204      ,p_attribute13                  => g_per_rec.attribute13
8205      ,p_attribute14                  => g_per_rec.attribute14
8206      ,p_attribute15                  => g_per_rec.attribute15
8207      ,p_attribute16                  => g_per_rec.attribute16
8208      ,p_attribute17                  => g_per_rec.attribute17
8209      ,p_attribute18                  => g_per_rec.attribute18
8210      ,p_attribute19                  => g_per_rec.attribute19
8211      ,p_attribute20                  => g_per_rec.attribute20
8212      ,p_attribute21                  => g_per_rec.attribute21
8213      ,p_attribute22                  => g_per_rec.attribute22
8214      ,p_attribute23                  => g_per_rec.attribute23
8215      ,p_attribute24                  => g_per_rec.attribute24
8216      ,p_attribute25                  => g_per_rec.attribute25
8217      ,p_attribute26                  => g_per_rec.attribute26
8218      ,p_attribute27                  => g_per_rec.attribute27
8219      ,p_attribute28                  => g_per_rec.attribute28
8220      ,p_attribute29                  => g_per_rec.attribute29
8221      ,p_attribute30                  => g_per_rec.attribute30
8222      ,p_date_of_death                => g_per_rec.date_of_death
8223      ,p_background_check_status      => g_per_rec.background_check_status
8224      ,p_background_date_check        => g_per_rec.background_date_check
8225      ,p_blood_type                   => g_per_rec.blood_type
8226      ,p_correspondence_language      => g_per_rec.correspondence_language
8227      ,p_fte_capacity                 => g_per_rec.fte_capacity
8228      ,p_hold_applicant_date_until    => g_per_rec.hold_applicant_date_until
8229      ,p_honors                       => g_per_rec.honors
8230      ,p_internal_location            => g_per_rec.internal_location
8231      ,p_last_medical_test_by         => g_per_rec.last_medical_test_by
8232      ,p_last_medical_test_date       => g_per_rec.last_medical_test_date
8233      ,p_mailstop                     => g_per_rec.mailstop
8234      ,p_office_number                => g_per_rec.office_number
8235      ,p_on_military_service          => g_per_rec.on_military_service
8236      ,p_pre_name_adjunct             => g_per_rec.pre_name_adjunct
8237      ,p_projected_start_date         => g_per_rec.projected_start_date
8238      ,p_rehire_authorizor            => g_per_rec.rehire_authorizor
8239      ,p_rehire_recommendation        => g_per_rec.rehire_recommendation
8240      ,p_resume_exists                => g_per_rec.resume_exists
8241      ,p_resume_last_updated          => g_per_rec.resume_last_updated
8242      ,p_second_passport_exists       => g_per_rec.second_passport_exists
8243      ,p_student_status               => g_per_rec.student_status
8244      ,p_work_schedule                => g_per_rec.work_schedule
8245      ,p_rehire_reason                => g_per_rec.rehire_reason
8246      ,p_suffix                       => g_per_rec.suffix
8247      ,p_benefit_group                => g_per_rec.benefit_group_id
8248      ,p_receipt_of_death_cert_date   => g_per_rec.receipt_of_death_cert_date
8249      ,p_coord_ben_med_pln_no         => g_per_rec.coord_ben_med_pln_no
8250      ,p_coord_ben_no_cvg_flag        => g_per_rec.coord_ben_no_cvg_flag
8251      ,p_coord_ben_med_ext_er         => g_per_rec.coord_ben_med_ext_er
8252      ,p_coord_ben_med_pl_name        => g_per_rec.coord_ben_med_pl_name
8253      ,p_coord_ben_med_insr_crr_name  => g_per_rec.coord_ben_med_insr_crr_name
8254      ,p_coord_ben_med_insr_crr_ident => g_per_rec.coord_ben_med_insr_crr_ident
8255      ,p_coord_ben_med_cvg_strt_dt    => g_per_rec.coord_ben_med_cvg_strt_dt
8256      ,p_coord_ben_med_cvg_end_dt     => g_per_rec.coord_ben_med_cvg_end_dt
8257      ,p_uses_tobacco_flag            => g_per_rec.uses_tobacco_flag
8258      ,p_dpdnt_adoption_date          => g_per_rec.dpdnt_adoption_date
8259      ,p_dpdnt_vlntry_svce_flag       => g_per_rec.dpdnt_vlntry_svce_flag
8260      ,p_original_date_of_hire        => g_per_rec.original_date_of_hire
8261      ,p_adjusted_svc_date            => p_adjusted_svc_date
8262      ,p_town_of_birth                => g_per_rec.town_of_birth
8263      ,p_region_of_birth              => g_per_rec.region_of_birth
8264      ,p_country_of_birth             => g_per_rec.country_of_birth
8265      ,p_global_person_id             => g_per_rec.global_person_id
8266      ,p_person_user_key              => l_dp_upd_per_rec.p_person_user_key
8267      ,p_user_person_type             => l_dp_upd_per_rec.p_user_person_type
8268      ,p_language_code                => Userenv('lang')
8269      ,p_vendor_name                  => null
8270      );
8271 
8272     end if;
8273 
8274     -- Call if API_ID is 'Update_Address'
8275     if l_api_name = 'UPDATE_PERSON_ADDRESS' then
8276        open  csr_get_update_add_data(c_batch_id   => p_batch_id
8277                                     ,c_link_value => p_data_pump_batch_line_id
8278                                     );
8279        fetch csr_get_update_add_data into l_dp_upd_add_rec;
8280        close csr_get_update_add_data;
8281 
8282 -- Code has been commented as the Logic for Address has changed, hence we no
8283 -- longer require the below logic, will be removed later
8284 
8285 --       -- Check if while updating address we end dated the address and then
8286 --       -- created a new address or simply updated the address. To find that
8287 --       -- out, we will check if for the said batch_id and link_value
8288 --       -- we have both Update and Create Address. If that is the case then
8289 --       -- that implies that address was end dated and then new one was created
8290 --       -- else it was simply updated.
8291 --       -- Incase address was updated to end date then, we will use
8292 --       -- "l_dp_upd_add_rec" else we will use "g_add_rec"
8293 
8294 --       OPEN  csr_chk_add_end_dated (c_batch_id   => p_batch_id
8295 --                                   ,c_link_value => p_data_pump_batch_line_id
8296 --                                   );
8297 --       FETCH csr_chk_add_end_dated INTO l_if_end_dated;
8298 --       CLOSE csr_chk_add_end_dated;
8299 
8300 --       IF l_if_end_dated = 'END DATED' THEN
8301 
8302 --          -- Don't do anything since in that case only date_to field was
8303 --          -- updated, which can't be wrong. Rest of the data was previous
8304 --          -- address data which can't be wrong and anyways user is not allowed
8305 --          -- to update that.
8306 --          NULL;
8307 
8308 --       ELSE
8309 
8310           Hrdpp_Update_Person_Address.Insert_Batch_Lines
8311           (p_batch_id                => p_batch_id
8312            --l_dp_batch_line_id_up_add
8313           ,p_data_pump_batch_line_id => l_dp_upd_add_rec.batch_line_id
8314           ,p_user_sequence           => l_dp_upd_add_rec.user_sequence
8315           ,p_link_value              => p_data_pump_batch_line_id
8316           ,p_effective_date          => g_per_rec.start_date
8317           ,p_validate_county         => false
8318           ,p_primary_flag            => g_add_rec.primary_flag
8319           ,p_date_from               => g_add_rec.date_from
8320           ,p_date_to                 => g_add_rec.date_to
8321           ,p_address_type            => g_add_rec.address_type
8322           --$
8323           ,p_comments                => g_add_rec.comments
8324           ,p_address_line1           => g_add_rec.address_line1
8325           ,p_address_line2           => g_add_rec.address_line2
8326           ,p_address_line3           => g_add_rec.address_line3
8327           ,p_town_or_city            => g_add_rec.town_or_city
8328           ,p_region_1                => g_add_rec.region_1
8329           ,p_region_2                => g_add_rec.region_2
8330           ,p_region_3                => g_add_rec.region_3
8331           ,p_postal_code             => g_add_rec.postal_code
8332           ,p_telephone_number_1      => g_add_rec.telephone_number_1
8333           ,p_telephone_number_2      => g_add_rec.telephone_number_2
8334           ,p_telephone_number_3      => g_add_rec.telephone_number_3
8335           ,p_addr_attribute_category => g_add_rec.addr_attribute_category
8336           ,p_addr_attribute1         => g_add_rec.addr_attribute1
8337           ,p_addr_attribute2         => g_add_rec.addr_attribute2
8338           ,p_addr_attribute3         => g_add_rec.addr_attribute3
8339           ,p_addr_attribute4         => g_add_rec.addr_attribute4
8340           ,p_addr_attribute5         => g_add_rec.addr_attribute5
8341           ,p_addr_attribute6         => g_add_rec.addr_attribute6
8342           ,p_addr_attribute7         => g_add_rec.addr_attribute7
8343           ,p_addr_attribute8         => g_add_rec.addr_attribute8
8344           ,p_addr_attribute9         => g_add_rec.addr_attribute9
8345           ,p_addr_attribute10        => g_add_rec.addr_attribute10
8346           ,p_addr_attribute11        => g_add_rec.addr_attribute11
8347           ,p_addr_attribute12        => g_add_rec.addr_attribute12
8348           ,p_addr_attribute13        => g_add_rec.addr_attribute13
8349           ,p_addr_attribute14        => g_add_rec.addr_attribute14
8350           ,p_addr_attribute15        => g_add_rec.addr_attribute15
8351           ,p_addr_attribute16        => g_add_rec.addr_attribute16
8352           ,p_addr_attribute17        => g_add_rec.addr_attribute17
8353           ,p_addr_attribute18        => g_add_rec.addr_attribute18
8354           ,p_addr_attribute19        => g_add_rec.addr_attribute19
8355           ,p_addr_attribute20        => g_add_rec.addr_attribute20
8356           ,p_add_information13       => g_add_rec.add_information13
8357           ,p_add_information14       => g_add_rec.add_information14
8358           ,p_add_information15       => g_add_rec.add_information15
8359           ,p_add_information16       => g_add_rec.add_information16
8360           ,p_add_information17       => g_add_rec.add_information17
8361           ,p_add_information18       => g_add_rec.add_information18
8362           ,p_add_information19       => g_add_rec.add_information19
8363           ,p_add_information20       => g_add_rec.add_information20
8364           ,p_party_id                => g_add_rec.party_id
8365           ,p_address_user_key        => l_dp_upd_add_rec.p_address_user_key
8366           ,p_country                 => g_add_rec.country
8367           );
8368 --       END IF;
8369     end if;
8370 
8371     -- Call if API_ID is 'Create_Address'
8372     if l_api_name = 'CREATE_PERSON_ADDRESS' then
8373 
8374        open  csr_get_create_add_data(c_batch_id   => p_batch_id
8375                                     ,c_link_value => p_data_pump_batch_line_id
8376                                     );
8377        fetch csr_get_create_add_data into l_dp_crt_add_rec;
8378        close csr_get_create_add_data;
8379 
8380        -- Convert String value of p_pradd_ovlapval_override to Boolean
8381        if l_dp_crt_add_rec.p_pradd_ovlapval_override = 'FALSE' then
8382           l_pradd_ovlapval_override := false;
8383        else
8384           l_pradd_ovlapval_override := false;
8385        end if;
8386 
8387        Hrdpp_Create_Person_Address.Insert_Batch_Lines
8388        (p_batch_id                       => p_batch_id
8389        --l_dp_batch_line_id_cr_add
8390        ,p_data_pump_batch_line_id        => l_dp_crt_add_rec.batch_line_id
8391        ,p_user_sequence                  => l_dp_crt_add_rec.user_sequence
8392        ,p_link_value                     => p_data_pump_batch_line_id
8393        ,p_effective_date                 => g_per_rec.start_date
8394        ,p_pradd_ovlapval_override        => l_pradd_ovlapval_override
8395        ,p_validate_county                => false
8396        ,p_primary_flag                   => g_add_rec.primary_flag
8397        ,p_style                          => g_add_rec.style
8398        ,p_date_from                      => g_add_rec.date_from
8399        ,p_date_to                        => g_add_rec.date_to
8400        ,p_address_type                   => g_add_rec.address_type
8401        --$
8402        ,p_comments                       => g_add_rec.comments
8403        ,p_address_line1                  => g_add_rec.address_line1
8404        ,p_address_line2                  => g_add_rec.address_line2
8405        ,p_address_line3                  => g_add_rec.address_line3
8406        ,p_town_or_city                   => g_add_rec.town_or_city
8407        ,p_region_1                       => g_add_rec.region_1
8408        ,p_region_2                       => g_add_rec.region_2
8409        ,p_region_3                       => g_add_rec.region_3
8410        ,p_postal_code                    => g_add_rec.postal_code
8411        ,p_telephone_number_1             => g_add_rec.telephone_number_1
8412        ,p_telephone_number_2             => g_add_rec.telephone_number_2
8413        ,p_telephone_number_3             => g_add_rec.telephone_number_3
8414        ,p_addr_attribute_category        => g_add_rec.addr_attribute_category
8415        ,p_addr_attribute1                => g_add_rec.addr_attribute1
8416        ,p_addr_attribute2                => g_add_rec.addr_attribute2
8417        ,p_addr_attribute3                => g_add_rec.addr_attribute3
8418        ,p_addr_attribute4                => g_add_rec.addr_attribute4
8419        ,p_addr_attribute5                => g_add_rec.addr_attribute5
8420        ,p_addr_attribute6                => g_add_rec.addr_attribute6
8421        ,p_addr_attribute7                => g_add_rec.addr_attribute7
8422        ,p_addr_attribute8                => g_add_rec.addr_attribute8
8423        ,p_addr_attribute9                => g_add_rec.addr_attribute9
8424        ,p_addr_attribute10               => g_add_rec.addr_attribute10
8425        ,p_addr_attribute11               => g_add_rec.addr_attribute11
8426        ,p_addr_attribute12               => g_add_rec.addr_attribute12
8427        ,p_addr_attribute13               => g_add_rec.addr_attribute13
8428        ,p_addr_attribute14               => g_add_rec.addr_attribute14
8429        ,p_addr_attribute15               => g_add_rec.addr_attribute15
8430        ,p_addr_attribute16               => g_add_rec.addr_attribute16
8431        ,p_addr_attribute17               => g_add_rec.addr_attribute17
8432        ,p_addr_attribute18               => g_add_rec.addr_attribute18
8433        ,p_addr_attribute19               => g_add_rec.addr_attribute19
8434        ,p_addr_attribute20               => g_add_rec.addr_attribute20
8435        ,p_add_information13              => g_add_rec.add_information13
8436        ,p_add_information14              => g_add_rec.add_information14
8437        ,p_add_information15              => g_add_rec.add_information15
8438        ,p_add_information16              => g_add_rec.add_information16
8439        ,p_add_information17              => g_add_rec.add_information17
8440        ,p_add_information18              => g_add_rec.add_information18
8441        ,p_add_information19              => g_add_rec.add_information19
8442        ,p_add_information20              => g_add_rec.add_information20
8443        ,p_party_id                       => g_add_rec.party_id
8444        ,p_address_user_key               => l_dp_crt_add_rec.p_address_user_key
8445        ,p_person_user_key                => l_dp_crt_add_rec.p_person_user_key
8446        ,p_country                        => g_add_rec.country
8447        );
8448 
8449     end if;
8450 
8451     -- Call if API_ID is 'Update_Emp_Asg'
8452     if l_api_name = 'UPDATE_EMP_ASG' then
8453 
8454        open  csr_get_upd_asg_data(c_batch_id   => p_batch_id
8455                                  ,c_link_value => p_data_pump_batch_line_id
8456                                  );
8457        fetch csr_get_upd_asg_data into l_dp_upd_asg_rec;
8458        close csr_get_upd_asg_data;
8459 
8460        Hrdpp_Update_Emp_Asg.Insert_Batch_Lines
8461        (p_batch_id                      => p_batch_id
8462        -- l_dp_batch_line_id_asg
8463        ,p_data_pump_batch_line_id       => l_dp_upd_asg_rec.batch_line_id
8464        ,p_user_sequence                 => l_dp_upd_asg_rec.user_sequence
8465        ,p_link_value                    => p_data_pump_batch_line_id
8466        ,p_effective_date                => g_per_rec.start_date
8467        ,p_datetrack_update_mode         => l_dp_upd_asg_rec.p_datetrack_update_mode
8468        ,p_change_reason                 => g_asg_rec.change_reason
8469        ,p_date_probation_end            => g_asg_rec.date_probation_end
8470        ,p_frequency                     => g_asg_rec.frequency
8471        ,p_internal_address_line         => g_asg_rec.internal_address_line
8472        ,p_manager_flag                  => g_asg_rec.manager_flag
8473        ,p_normal_hours                  => g_asg_rec.normal_hours
8474        ,p_perf_review_period            => g_asg_rec.perf_review_period
8475        ,p_perf_review_period_frequency  => g_asg_rec.perf_review_period_frequency
8476        ,p_probation_period              => g_asg_rec.probation_period
8477        ,p_probation_unit                => g_asg_rec.probation_unit
8478        ,p_sal_review_period             => g_asg_rec.sal_review_period
8479        ,p_sal_review_period_frequency   => g_asg_rec.sal_review_period_frequency
8480        ,p_source_type                   => g_asg_rec.source_type
8481        ,p_time_normal_finish            => g_asg_rec.time_normal_finish
8482        ,p_time_normal_start             => g_asg_rec.time_normal_start
8483        ,p_bargaining_unit_code          => g_asg_rec.bargaining_unit_code
8484        ,p_labour_union_member_flag      => g_asg_rec.labour_union_member_flag
8485        ,p_hourly_salaried_code          => g_asg_rec.hourly_salaried_code
8486        ,p_ass_attribute_category        => g_asg_rec.ass_attribute_category
8487        ,p_ass_attribute1                => g_asg_rec.ass_attribute1
8488        ,p_ass_attribute2                => g_asg_rec.ass_attribute2
8489        ,p_ass_attribute3                => g_asg_rec.ass_attribute3
8490        ,p_ass_attribute4                => g_asg_rec.ass_attribute4
8491        ,p_ass_attribute5                => g_asg_rec.ass_attribute5
8492        ,p_ass_attribute6                => g_asg_rec.ass_attribute6
8493        ,p_ass_attribute7                => g_asg_rec.ass_attribute7
8494        ,p_ass_attribute8                => g_asg_rec.ass_attribute8
8495        ,p_ass_attribute9                => g_asg_rec.ass_attribute9
8496        ,p_ass_attribute10               => g_asg_rec.ass_attribute10
8497        ,p_ass_attribute11               => g_asg_rec.ass_attribute11
8498        ,p_ass_attribute12               => g_asg_rec.ass_attribute12
8499        ,p_ass_attribute13               => g_asg_rec.ass_attribute13
8500        ,p_ass_attribute14               => g_asg_rec.ass_attribute14
8501        ,p_ass_attribute15               => g_asg_rec.ass_attribute15
8502        ,p_ass_attribute16               => g_asg_rec.ass_attribute16
8503        ,p_ass_attribute17               => g_asg_rec.ass_attribute17
8504        ,p_ass_attribute18               => g_asg_rec.ass_attribute18
8505        ,p_ass_attribute19               => g_asg_rec.ass_attribute19
8506        ,p_ass_attribute20               => g_asg_rec.ass_attribute20
8507        ,p_ass_attribute21               => g_asg_rec.ass_attribute21
8508        ,p_ass_attribute22               => g_asg_rec.ass_attribute22
8509        ,p_ass_attribute23               => g_asg_rec.ass_attribute23
8510        ,p_ass_attribute24               => g_asg_rec.ass_attribute24
8511        ,p_ass_attribute25               => g_asg_rec.ass_attribute25
8512        ,p_ass_attribute26               => g_asg_rec.ass_attribute26
8513        ,p_ass_attribute27               => g_asg_rec.ass_attribute27
8514        ,p_ass_attribute28               => g_asg_rec.ass_attribute28
8515        ,p_ass_attribute29               => g_asg_rec.ass_attribute29
8516        ,p_ass_attribute30               => g_asg_rec.ass_attribute30
8517        ,p_segment1                      => g_scl_rec.segment1
8518        ,p_segment2                      => g_scl_rec.segment2
8519        ,p_segment3                      => g_scl_rec.segment3
8520        ,p_segment4                      => g_scl_rec.segment4
8521        ,p_segment5                      => g_scl_rec.segment5
8522        ,p_segment6                      => g_scl_rec.segment6
8523        ,p_segment7                      => g_scl_rec.segment7
8524        ,p_segment8                      => g_scl_rec.segment8
8525        ,p_segment9                      => g_scl_rec.segment9
8526        ,p_cagr_grade_def_id             => null
8527        ,p_assignment_user_key           => l_dp_upd_asg_rec.p_assignment_user_key
8528        ,p_con_seg_user_name             => null
8529        );
8530 
8531     end if;
8532 
8533     -- Call if API_ID is 'Update_Emp_Asg_Criteria'
8534     if l_api_name = 'UPDATE_EMP_ASG_CRITERIA' then
8535 
8536        Get_WrkStrs_Names;
8537       -- Cursor to get the exisiting Data Pump Interface Table Va;ues for
8538       -- Update Emp Asg Criteria
8539       open  csr_get_upd_asg_crt_data(c_batch_id   => p_batch_id
8540                                     ,c_link_value => p_data_pump_batch_line_id
8541                                     );
8542       fetch csr_get_upd_asg_crt_data into l_dp_upd_asg_crt_rec;
8543       close csr_get_upd_asg_crt_data;
8544 
8545       Hrdpp_Update_Emp_Asg_Criteria.Insert_Batch_Lines
8546       (p_batch_id                => p_batch_id
8547       --l_dp_batch_line_id_asg_cri
8548       ,p_data_pump_batch_line_id => l_dp_upd_asg_crt_rec.batch_line_id
8549       ,p_user_sequence           => l_dp_upd_asg_crt_rec.user_sequence
8550       ,p_link_value              => p_data_pump_batch_line_id
8551       ,p_effective_date          => g_per_rec.start_date
8552       ,p_datetrack_update_mode   => l_dp_upd_asg_crt_rec.p_datetrack_update_mode
8553       ,p_segment1                => g_grp_rec.segment1
8554       ,p_segment2                => g_grp_rec.segment2
8555       ,p_segment3                => g_grp_rec.segment3
8556       ,p_segment4                => g_grp_rec.segment4
8557       ,p_segment5                => g_grp_rec.segment5
8558       ,p_segment6                => g_grp_rec.segment6
8559       ,p_segment7                => g_grp_rec.segment7
8560       ,p_segment8                => g_grp_rec.segment8
8561       ,p_segment9                => g_grp_rec.segment9
8562       ,p_segment10               => g_grp_rec.segment10
8563       ,p_segment11               => g_grp_rec.segment11
8564       ,p_segment12               => g_grp_rec.segment12
8565       ,p_segment13               => g_grp_rec.segment13
8566       ,p_segment14               => g_grp_rec.segment14
8567       ,p_segment15               => g_grp_rec.segment15
8568       ,p_segment16               => g_grp_rec.segment16
8569       ,p_segment17               => g_grp_rec.segment17
8570       ,p_segment18               => g_grp_rec.segment18
8571       ,p_segment19               => g_grp_rec.segment19
8572       ,p_segment20               => g_grp_rec.segment20
8573       ,p_segment21               => g_grp_rec.segment21
8574       ,p_segment22               => g_grp_rec.segment22
8575       ,p_segment23               => g_grp_rec.segment23
8576       ,p_segment24               => g_grp_rec.segment24
8577       ,p_segment25               => g_grp_rec.segment25
8578       ,p_segment26               => g_grp_rec.segment26
8579       ,p_segment27               => g_grp_rec.segment27
8580       ,p_segment28               => g_grp_rec.segment28
8581       ,p_segment29               => g_grp_rec.segment29
8582       ,p_segment30               => g_grp_rec.segment30
8583       ,p_special_ceiling_step_id => null
8584       ,p_people_group_id         => null
8585       ,p_assignment_user_key     => l_dp_upd_asg_crt_rec.p_assignment_user_key
8586       ,p_grade_name              => g_wstr_names.grade_name
8587       ,p_position_name           => g_wstr_names.position_name
8588       ,p_job_name                => g_wstr_names.job_name
8589       ,p_payroll_name            => g_wstr_names.payroll_name
8590       ,p_location_code           => g_wstr_names.location_code
8591       ,p_organization_name       => g_wstr_names.organization_name
8592       ,p_pay_basis_name          => g_wstr_names.pay_basis_name
8593       ,p_language_code           => Userenv('LANG')
8594       ,p_con_seg_user_name       => null
8595       );
8596 
8597     end if;
8598 
8599     -- Call if API_ID is 'Create_Contact'
8600     if l_api_name = 'CREATE_CONTACT' then
8601 
8602        open  csr_get_create_cnt_data(c_batch_id   => p_batch_id
8603                                     ,c_link_value => p_data_pump_batch_line_id
8604                                     );
8605        fetch csr_get_create_cnt_data into l_dp_crt_cnt_rec;
8606        close csr_get_create_cnt_data;
8607 
8608        Hrdpp_Create_Contact.insert_batch_lines
8609        (p_batch_id                => p_batch_id
8610        ,p_data_pump_batch_line_id => l_dp_crt_cnt_rec.batch_line_id
8611        ,p_user_sequence           => l_dp_crt_cnt_rec.user_sequence
8612        ,p_link_value              => p_data_pump_batch_line_id
8613        ,p_start_date              => g_per_rec.start_date
8614        ,p_contact_type            => g_cnt_rec.contact_type
8615        ,p_primary_contact_flag    => g_cnt_rec.primary_contact_flag
8616        ,p_personal_flag           => g_cnt_rec.personal_flag
8617        ,p_last_name               => p_contact_name
8618        ,p_per_person_user_key     => l_dp_crt_cnt_rec.p_per_person_user_key
8619        ,p_person_user_key         => l_dp_crt_cnt_rec.p_person_user_key
8620        ,p_language_code           => userenv('LANG')
8621        );
8622 
8623     end if;
8624 
8625     -- Call if API_ID is 'Update_Contact'
8626     if l_api_name = 'UPDATE_CONTACT_RELATIONSHIP' then
8627 
8628        open  csr_get_update_cnt_data(c_batch_id   => p_batch_id
8629                                      ,c_link_value => p_data_pump_batch_line_id
8630                                      );
8631        fetch csr_get_update_cnt_data into l_dp_upd_cnt_rec;
8632        close csr_get_update_cnt_data;
8633 
8634        Hrdpp_Update_Contact_Relations.insert_batch_lines
8635        (p_batch_id                => p_batch_id
8636        ,p_data_pump_batch_line_id => l_dp_upd_cnt_rec.batch_line_id
8637        ,p_user_sequence           => l_dp_crt_cnt_rec.user_sequence
8638        ,p_link_value              => p_data_pump_batch_line_id
8639        ,p_effective_date          => g_per_rec.start_date
8640        ,p_contact_type            => g_cnt_rec.contact_type
8641        ,p_primary_contact_flag    => g_cnt_rec.primary_contact_flag
8642        ,p_personal_flag           => g_cnt_rec.personal_flag
8643        ,p_object_version_number   => l_dp_upd_cnt_rec.p_object_version_number
8644        ,p_contact_user_key        => l_dp_upd_cnt_rec.p_contact_user_key
8645        ,p_contactee_user_key      => l_dp_upd_cnt_rec.p_contactee_user_key
8646        );
8647 
8648     end if;
8649 
8650   end loop;
8651 
8652   close csr_get_api_names;
8653 
8654   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
8655 
8656 exception
8657   when Others then
8658     if csr_get_api_names%isopen then
8659       close csr_get_api_names;
8660     end if;
8661   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
8662   raise;
8663 
8664 end HR_DataPumpErr;
8665 
8666 -- =============================================================================
8667 -- ~ Create_Person_Contact:
8668 -- =============================================================================
8669 /*
8670 procedure Create_Person_Contact
8671          (p_effective_date   in date
8672          ,p_contact_name     in varchar2
8673          ,p_legislation_code in varchar2
8674          ,p_crt_cntct_out    out NOCOPY t_CreateContact_Api
8675           ) as
8676 
8677   l_proc_name  constant    varchar2(150):= g_pkg ||'Create_Person_Contact';
8678 
8679 begin
8680   hr_utility.set_location('Entering: ' || l_proc_name, 10);
8681 
8682    Hr_Contact_Rel_Api.create_contact
8683    (p_start_date                => p_effective_date
8684    ,p_business_group_id         => g_cnt_rec.business_group_id
8685    ,p_person_id                 => g_cnt_rec.person_id
8686    ,p_contact_type              => g_cnt_rec.contact_type
8687    ,p_last_name                 => p_contact_name
8688    ,p_primary_contact_flag      => g_cnt_rec.primary_contact_flag
8689    ,p_personal_flag             => g_cnt_rec.personal_flag
8690    ,p_per_information_category  => p_legislation_code
8691    ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
8692    ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
8693    ,p_per_person_id             => p_crt_cntct_out.per_person_id
8694    ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
8695    ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
8696    ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
8697    ,p_full_name                 => p_crt_cntct_out.full_name
8698    ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
8699    ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
8700    ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
8701    );
8702 
8703   hr_utility.set_location('Leaving: ' || l_proc_name, 20);
8704 
8705 end Create_Person_Contact;
8706 */
8707 -- =============================================================================
8708 -- ~ Update_Person_Contact:
8709 -- =============================================================================
8710 procedure Update_Person_Contact
8711          (p_effective_date   in date
8712          ,p_contact_name     in varchar2
8713          ,p_legislation_code in varchar2
8714          ,p_crt_cntct_out    out NOCOPY t_CreateContact_Api
8715          ) as
8716 
8717   l_cont_object_version_num  number;
8718   l_proc_name  constant      varchar2(150):= g_pkg ||'Update_Person_Contact';
8719 begin
8720   hr_utility.set_location('Entering: ' || l_proc_name, 10);
8721 
8722   open  csr_ck_cont_xsts(c_person_id         => g_per_rec.person_id
8723                         ,c_business_group_id => g_add_rec.business_group_id
8724                         ,c_effective_date    => g_per_rec.start_date);
8725   fetch csr_ck_cont_xsts into l_cont_object_version_num;
8726 
8727   -- Update the Contact only if Contact exists else create Contact
8728   if csr_ck_cont_xsts%found then
8729 
8730      -- Right now we are only creating the contact as decision to if we should
8731      -- actually be updating the Contact or every time be creating a new
8732      -- contact, irrespective of the fact if it is already existing duplicate
8733      -- person, hasn't been made
8734      Hr_Contact_Rel_Api.create_contact
8735      (p_start_date                => p_effective_date
8736      ,p_business_group_id         => g_cnt_rec.business_group_id
8737      ,p_person_id                 => g_cnt_rec.person_id
8738      ,p_contact_type              => g_cnt_rec.contact_type
8739      ,p_last_name                 => p_contact_name
8740      ,p_primary_contact_flag      => g_cnt_rec.primary_contact_flag
8741      ,p_personal_flag             => g_cnt_rec.personal_flag
8742      ,p_per_information_category  => p_legislation_code
8743      ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
8744      ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
8745      ,p_per_person_id             => p_crt_cntct_out.per_person_id
8746      ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
8747      ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
8748      ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
8749      ,p_full_name                 => p_crt_cntct_out.full_name
8750      ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
8751      ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
8752      ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
8753      );
8754 
8755   else
8756 
8757      Hr_Contact_Rel_Api.create_contact
8758      (p_start_date                => p_effective_date
8759      ,p_business_group_id         => g_cnt_rec.business_group_id
8760      ,p_person_id                 => g_cnt_rec.person_id
8761      ,p_contact_type              => g_cnt_rec.contact_type
8762      ,p_last_name                 => p_contact_name
8763      ,p_primary_contact_flag      => g_cnt_rec.primary_contact_flag
8764      ,p_personal_flag             => g_cnt_rec.personal_flag
8765      ,p_per_information_category  => p_legislation_code
8766      ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
8767      ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
8768      ,p_per_person_id             => p_crt_cntct_out.per_person_id
8769      ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
8770      ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
8771      ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
8772      ,p_full_name                 => p_crt_cntct_out.full_name
8773      ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
8774      ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
8775      ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
8776      );
8777 
8778   end if;
8779 
8780   hr_utility.set_location('Leaving: ' || l_proc_name, 20);
8781 
8782 end Update_Person_Contact;
8783 
8784 -- =============================================================================
8785 -- ~ Create_DataPump_BatchHeader:
8786 -- =============================================================================
8787 procedure Create_DataPump_BatchHeader
8788          (p_reference            in varchar2
8789          ,p_business_group_id    in number
8790          ,p_batch_process_name   in out nocopy varchar2
8791          ,p_batch_process_id     out nocopy number) as
8792   --
8793   -- Cursor to get the business group name
8794   --
8795   cursor csr_get_bg_name (c_bg_grp_id in number) is
8796   select pbg.name
8797     from per_business_groups pbg
8798    where pbg.business_group_id = c_bg_grp_id;
8799 
8800   l_bg_name             per_business_groups.name%type;
8801   l_proc_name  constant varchar2(170):= g_pkg ||'Create_DataPump_BatchHeader';
8802   l_reference           varchar2(80);
8803 
8804 begin
8805    hr_utility.set_location('Entering: ' || l_proc_name, 10);
8806    select hr_pump_batch_headers_s.nextval
8807      into p_batch_process_id
8808      from dual;
8809    --
8810    -- If batch name is null i.e. user did'nt enter a name, so create one.
8811    --
8812    if p_batch_process_name is null then
8813       p_batch_process_name := 'RIW Web-ADI Batch: ' || p_batch_process_id;
8814    else
8815       p_batch_process_name := p_batch_process_name || p_batch_process_id;
8816    end if;
8817    --
8818    -- Assign a default reference
8819    --
8820    if trim(p_reference) is null then
8821       l_reference := 'PQP_RIW_PERASGADD';
8822    else
8823       l_reference := p_reference;
8824    end if;
8825    --
8826    -- Get the business group name
8827    --
8828    if p_business_group_id is null then
8829       open csr_get_bg_name(Fnd_Profile.Value('PER_BUSINESS_GROUP_ID'));
8830      fetch csr_get_bg_name into l_bg_name;
8831      close csr_get_bg_name;
8832    else
8833       open csr_get_bg_name(p_business_group_id);
8834      fetch csr_get_bg_name into l_bg_name;
8835      close csr_get_bg_name;
8836    end if;
8837    --
8838    -- Create a row into Data Pump batch header table
8839    --
8840    insert into hr_pump_batch_headers
8841    (batch_id
8842    ,batch_name
8843    ,batch_status
8844    ,business_group_name
8845    ,reference)
8846    values
8847    (p_batch_process_id
8848    ,p_batch_process_name
8849    ,'U'
8850    ,l_bg_name
8851    --,nvl(l_bg_name,'PQPD115 Business Group') -- remove the NVL()
8852    ,l_reference);
8853 
8854    hr_utility.set_location('Leaving: ' || l_proc_name, 80);
8855 
8856 end Create_DataPump_BatchHeader;
8857 -- =============================================================================
8858 -- Update_Assignment:
8859 -- =============================================================================
8860 procedure Update_Assignment
8861          (p_effective_date    in date
8862          ,p_business_group_id in number
8863          ,p_person_id         in number
8864          ) as
8865 
8866   --Added by DBANSAL to get the person type
8867    cursor csr_type (c_person_type_id in number) is
8868   select *
8869     from per_person_types
8870    where person_type_id = c_person_type_id
8871      and business_group_id = p_business_group_id;
8872 
8873   --$ Cursor to get APL assg details (no assg number)
8874    cursor csr_apl_asg (c_effective_date in date
8875                  ,c_person_id         in number
8876                  ,c_business_group_id in number)is
8877   select *
8878     from per_all_assignments_f paf
8879    where paf.person_id = c_person_id
8880      and paf.business_group_id = c_business_group_id
8881      and c_effective_date between paf.effective_start_date
8882                               and paf.effective_end_date;
8883 
8884 
8885   cursor csr_asg (c_assignment_id in varchar2
8886                  ,c_person_id         in number
8887                  ,c_business_group_id in number
8888                  ,c_effective_date    in date
8889                  ) is
8890   select *
8891     from per_all_assignments_f paf
8892    where paf.person_id = c_person_id
8893      and paf.assignment_id = c_assignment_id
8894      and paf.business_group_id = c_business_group_id
8895      and c_effective_date between paf.effective_start_date
8896                               and paf.effective_end_date;
8897 
8898   cursor csr_asg_num (c_assignment_number in varchar2
8899                  ,c_person_id         in number
8900                  ,c_business_group_id in number
8901                  ,c_effective_date    in date
8902                  ) is
8903   select *
8904     from per_all_assignments_f paf
8905    where paf.person_id = c_person_id
8906      and paf.assignment_number = c_assignment_number
8907      and paf.business_group_id = c_business_group_id
8908      and c_effective_date between paf.effective_start_date
8909                               and paf.effective_end_date;
8910 
8911   l_asg_rec  csr_asg%rowtype;
8912   l_AsgUpdCrit_Api t_AsgUpdCrit_Api;
8913   l_proc_name    constant varchar2(150) := g_pkg||'Update_Assignment';
8914 
8915   -- Added by dbansal
8916   l_hrEmpApi_out          t_hrEmpApi;
8917   l_UpdEmpAsg_out          t_Upd_Emp_Asg_Api;
8918   l_asg_rec1               per_all_assignments_f%rowtype;
8919  l_grp_rec                pay_people_groups%rowtype;
8920   l_scl_rec                hr_soft_coding_keyflex%rowtype;
8921   l_pty_rec     csr_type%rowtype;
8922   l_apl_asg_rec             per_all_assignments_f%rowtype;
8923   l_appl_override_warning         boolean;
8924   l_concat_segments        varchar2(2000);
8925   l_secondary              boolean;
8926 begin
8927   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
8928 
8929   --$ check already made before making call to this procedure from
8930   --the procedure Direct_API_Call. Also as for "APPLICANT" assignment_number
8931   -- will always be null hence should not be included in the check condition.
8932   -- Hence,commenting it out
8933   /*
8934   if g_asg_rec.organization_id is null or
8935      g_asg_rec.assignment_status_type_id is null or
8936      g_asg_rec.assignment_number is null then
8937      Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
8938      return;
8939   end if;
8940   */
8941 
8942   if g_asg_rec.assignment_number is null then
8943       if g_migration_flag = 'Y' then
8944           hr_utility.set_location('Inside else ', 7);
8945           hr_utility.set_location('The assignment id is : '||g_asg_rec.assignment_id, 8);
8946   	      open csr_apl_asg (c_person_id         => p_person_id
8947               ,c_business_group_id => p_business_group_id
8948               ,c_effective_date    => p_effective_date
8949               );
8950          fetch csr_apl_asg into l_asg_rec;
8951          if csr_apl_asg%notfound then
8952          close csr_apl_asg;
8953          l_secondary := true;
8954          else
8955          close csr_apl_asg;
8956          l_secondary := false;
8957          end if;
8958       else
8959           hr_utility.set_location('Inside else ', 7);
8960           hr_utility.set_location('The assignment id is : '||g_asg_rec.assignment_id, 8);
8961   	      open csr_asg (c_assignment_id => g_asg_rec.assignment_id
8962               ,c_person_id         => p_person_id
8963               ,c_business_group_id => p_business_group_id
8964               ,c_effective_date    => p_effective_date
8965               );
8966          fetch csr_asg into l_asg_rec;
8967          if csr_asg%notfound then
8968          close csr_asg;
8969          l_secondary := true;
8970          else
8971          close csr_asg;
8972          l_secondary := false;
8973          end if;
8974       end if;
8975   else
8976   	  open csr_asg_num (c_assignment_number => g_asg_rec.assignment_number
8977                ,c_person_id         => p_person_id
8978                ,c_business_group_id => p_business_group_id
8979                ,c_effective_date    => p_effective_date
8980                );
8981   	  fetch csr_asg_num into l_asg_rec;
8982       if csr_asg_num%notfound then
8983           close csr_asg_num;
8984           l_secondary := true;
8985       else
8986           close csr_asg_num;
8987           l_secondary := false;
8988       end if;
8989   end if;
8990 
8991  /* if g_migration_flag = 'Y' OR (g_migration_flag = 'N' AND g_asg_rec.assignment_id is null) then
8992   	open csr_asg_num (c_assignment_number => g_asg_rec.assignment_number
8993                ,c_person_id         => p_person_id
8994                ,c_business_group_id => p_business_group_id
8995                ,c_effective_date    => p_effective_date
8996                );
8997   	fetch csr_asg_num into l_asg_rec;
8998     if csr_asg_num%notfound then
8999         close csr_asg_num;
9000         l_secondary := true;
9001     else
9002         close csr_asg_num;
9003         l_secondary := false;
9004     end if;
9005   else
9006     hr_utility.set_location('Inside else ', 7);
9007     hr_utility.set_location('The assignment id is : '||g_asg_rec.assignment_id, 8);
9008   	open csr_asg (c_assignment_id => g_asg_rec.assignment_id
9009                ,c_person_id         => p_person_id
9010                ,c_business_group_id => p_business_group_id
9011                ,c_effective_date    => p_effective_date
9012                );
9013   fetch csr_asg into l_asg_rec;
9014     if csr_asg%notfound then
9015         close csr_asg;
9016         l_secondary := true;
9017     else
9018         close csr_asg;
9019         l_secondary := false;
9020     end if;
9021   end if;*/
9022 
9023 
9024 
9025         /*hr_utility.trace('CURSOR : select * from per_all_assignments_f paf
9026    where paf.person_id =' ||p_person_id || 'and paf.assignment_number = ' ||
9027     g_asg_rec.assignment_number || 'and paf.business_group_id = ' || p_business_group_id
9028     || 'and ' || sysdate|| ' between paf.effective_start_date
9029                               and paf.effective_end_date' );*/
9030 
9031 
9032   if  l_secondary then
9033 
9034    -- If the assignment (assignment number specified) is not there
9035    -- for that person then create a secondary assignment in case of emp and cwk
9036    g_sec_asg_flag := 1; -- set secondary assignment flag to 1
9037    l_asg_rec1 := Get_AsgRecord_Values(g_interface_code);
9038    l_grp_rec := Get_GrpRecord_Values(g_interface_code);
9039    l_scl_rec := Get_ScflxRecord_Values(g_interface_code);
9040 
9041    open csr_type(g_per_rec.person_type_id);
9042    fetch csr_type into l_pty_rec;
9043    close csr_type;
9044 
9045    if l_pty_rec.system_person_type = 'EMP' then
9046     if (g_crt_upd = 'C') then -- Should have Create privileges to create sec assignment
9047 	Hr_Assignment_Api.create_secondary_emp_asg
9048 	(p_validate                     => false -- in     boolean  default false
9049 	,p_effective_date               => p_effective_date -- in     date
9050 	,p_person_id                    => p_person_id --  in     number
9051 	,p_organization_id              => g_asg_rec.organization_id   --  in     number
9052 	,p_assignment_number            => g_asg_rec.assignment_number     --   in out nocopy varchar2
9053 	,p_grade_id                     => l_asg_rec1.grade_id
9054 	,p_position_id                  => l_asg_rec1.position_id
9055 	,p_job_id                       => l_asg_rec1.job_id
9056 	--      ,p_assignment_status_type_id    in     number   default null
9057 	,p_payroll_id                   => l_asg_rec1.payroll_id
9058 	,p_location_id                  => l_asg_rec1.location_id
9059 	,p_supervisor_id                => l_asg_rec1.supervisor_id      -- in     number   default null
9060 	,p_pay_basis_id                 => l_asg_rec1.pay_basis_id     --  in     number   default null
9061 	,p_change_reason                => l_asg_rec1.change_reason        --  in     varchar2 default null
9062 	,p_comments                     => g_asg_comments
9063 	,p_date_probation_end           => l_asg_rec1.date_probation_end    --   in     date     default null
9064 	,p_default_code_comb_id         => l_asg_rec1.default_code_comb_id   --   in     number   default null
9065 	,p_employment_category          => l_asg_rec1.employment_category --       in     varchar2 default null
9066 	,p_frequency                    => l_asg_rec1.frequency --       in     varchar2 default null
9067 	,p_internal_address_line        => l_asg_rec1.internal_address_line
9068 	,p_manager_flag                 => l_asg_rec1.manager_flag
9069 	,p_normal_hours                 => l_asg_rec1.normal_hours
9070 	,p_perf_review_period           => l_asg_rec1.perf_review_period
9071 	,p_perf_review_period_frequency => l_asg_rec1.perf_review_period_frequency
9072 	,p_probation_period             => l_asg_rec1.probation_period
9073 	,p_probation_unit               => l_asg_rec1.probation_unit
9074 	,p_sal_review_period            => l_asg_rec1.sal_review_period
9075 	,p_sal_review_period_frequency  => l_asg_rec1.sal_review_period_frequency
9076 	,p_set_of_books_id              => l_asg_rec1.set_of_books_id
9077 	,p_source_type                  => l_asg_rec1.source_type
9078 	,p_time_normal_finish           => l_asg_rec1.time_normal_finish
9079 	,p_time_normal_start            => l_asg_rec1.time_normal_start
9080 	,p_bargaining_unit_code         => l_asg_rec1.bargaining_unit_code
9081 	,p_labour_union_member_flag     => l_asg_rec1.labour_union_member_flag
9082 	,p_hourly_salaried_code         => l_asg_rec1.hourly_salaried_code
9083 	,p_title                        => l_asg_rec1.title
9084 	-- Assignment DF
9085 	,p_ass_attribute_category       => l_asg_rec1.ass_attribute_category
9086 	,p_ass_attribute1               => l_asg_rec1.ass_attribute1
9087 	,p_ass_attribute2               => l_asg_rec1.ass_attribute2
9088 	,p_ass_attribute3               => l_asg_rec1.ass_attribute3
9089 	,p_ass_attribute4               => l_asg_rec1.ass_attribute4
9090 	,p_ass_attribute5               => l_asg_rec1.ass_attribute5
9091 	,p_ass_attribute6               => l_asg_rec1.ass_attribute6
9092 	,p_ass_attribute7               => l_asg_rec1.ass_attribute7
9093 	,p_ass_attribute8               => l_asg_rec1.ass_attribute8
9094 	,p_ass_attribute9               => l_asg_rec1.ass_attribute9
9095 	,p_ass_attribute10              => l_asg_rec1.ass_attribute10
9096 	,p_ass_attribute11              => l_asg_rec1.ass_attribute11
9097 	,p_ass_attribute12              => l_asg_rec1.ass_attribute12
9098 	,p_ass_attribute13              => l_asg_rec1.ass_attribute13
9099 	,p_ass_attribute14              => l_asg_rec1.ass_attribute14
9100 	,p_ass_attribute15              => l_asg_rec1.ass_attribute15
9101 	,p_ass_attribute16              => l_asg_rec1.ass_attribute16
9102 	,p_ass_attribute17              => l_asg_rec1.ass_attribute17
9103 	,p_ass_attribute18              => l_asg_rec1.ass_attribute18
9104 	,p_ass_attribute19              => l_asg_rec1.ass_attribute19
9105 	,p_ass_attribute20              => l_asg_rec1.ass_attribute20
9106 	,p_ass_attribute21              => l_asg_rec1.ass_attribute21
9107 	,p_ass_attribute22              => l_asg_rec1.ass_attribute22
9108 	,p_ass_attribute23              => l_asg_rec1.ass_attribute23
9109 	,p_ass_attribute24              => l_asg_rec1.ass_attribute24
9110 	,p_ass_attribute25              => l_asg_rec1.ass_attribute25
9111 	,p_ass_attribute26              => l_asg_rec1.ass_attribute26
9112 	,p_ass_attribute27              => l_asg_rec1.ass_attribute27
9113 	,p_ass_attribute28              => l_asg_rec1.ass_attribute28
9114 	,p_ass_attribute29              => l_asg_rec1.ass_attribute29
9115 	,p_ass_attribute30              => l_asg_rec1.ass_attribute30
9116 	-- Hr Soft Coding KeyFlex segments
9117 	,p_scl_segment1                  => l_scl_rec.segment1
9118 	,p_scl_segment2                  => l_scl_rec.segment2
9119 	,p_scl_segment3                  => l_scl_rec.segment3
9120 	,p_scl_segment4                  => l_scl_rec.segment4
9121 	,p_scl_segment5                  => l_scl_rec.segment5
9122 	,p_scl_segment6                  => l_scl_rec.segment6
9123 	,p_scl_segment7                  => l_scl_rec.segment7
9124 	,p_scl_segment8                  => l_scl_rec.segment8
9125 	,p_scl_segment9                  => l_scl_rec.segment9
9126 	,p_scl_segment10                 => l_scl_rec.segment10
9127 	,p_scl_segment11                 => l_scl_rec.segment11
9128 	,p_scl_segment12                 => l_scl_rec.segment12
9129 	,p_scl_segment13                 => l_scl_rec.segment13
9130 	,p_scl_segment14                 => l_scl_rec.segment14
9131 	,p_scl_segment15                 => l_scl_rec.segment15
9132 	,p_scl_segment16                 => l_scl_rec.segment16
9133 	,p_scl_segment17                 => l_scl_rec.segment17
9134 	,p_scl_segment18                 => l_scl_rec.segment18
9135 	,p_scl_segment19                 => l_scl_rec.segment19
9136 	,p_scl_segment20                 => l_scl_rec.segment20
9137 	,p_scl_segment21                 => l_scl_rec.segment21
9138 	,p_scl_segment22                 => l_scl_rec.segment22
9139 	,p_scl_segment23                 => l_scl_rec.segment23
9140 	,p_scl_segment24                 => l_scl_rec.segment24
9141 	,p_scl_segment25                 => l_scl_rec.segment25
9142 	,p_scl_segment26                 => l_scl_rec.segment26
9143 	,p_scl_segment27                 => l_scl_rec.segment27
9144 	,p_scl_segment28                 => l_scl_rec.segment28
9145 	,p_scl_segment29                 => l_scl_rec.segment29
9146 	,p_scl_segment30                 => l_scl_rec.segment30
9147 	--         ,p_scl_concat_segments         => l_scl_rec.concatenated_segments    --  in     varchar2 default null
9148 	-- People Group Flex
9149 	,p_pgp_segment1                  => l_grp_rec.segment1
9150 	,p_pgp_segment2                  => l_grp_rec.segment2
9151 	,p_pgp_segment3                  => l_grp_rec.segment3
9152 	,p_pgp_segment4                  => l_grp_rec.segment4
9153 	,p_pgp_segment5                  => l_grp_rec.segment5
9154 	,p_pgp_segment6                  => l_grp_rec.segment6
9155 	,p_pgp_segment7                  => l_grp_rec.segment7
9156 	,p_pgp_segment8                  => l_grp_rec.segment8
9157 	,p_pgp_segment9                  => l_grp_rec.segment9
9158 	,p_pgp_segment10                 => l_grp_rec.segment10
9159 	,p_pgp_segment11                 => l_grp_rec.segment11
9160 	,p_pgp_segment12                 => l_grp_rec.segment12
9161 	,p_pgp_segment13                 => l_grp_rec.segment13
9162 	,p_pgp_segment14                 => l_grp_rec.segment14
9163 	,p_pgp_segment15                 => l_grp_rec.segment15
9164 	,p_pgp_segment16                 => l_grp_rec.segment16
9165 	,p_pgp_segment17                 => l_grp_rec.segment17
9166 	,p_pgp_segment18                 => l_grp_rec.segment18
9167 	,p_pgp_segment19                 => l_grp_rec.segment19
9168 	,p_pgp_segment20                 => l_grp_rec.segment20
9169 	,p_pgp_segment21                 => l_grp_rec.segment21
9170 	,p_pgp_segment22                 => l_grp_rec.segment22
9171 	,p_pgp_segment23                 => l_grp_rec.segment23
9172 	,p_pgp_segment24                 => l_grp_rec.segment24
9173 	,p_pgp_segment25                 => l_grp_rec.segment25
9174 	,p_pgp_segment26                 => l_grp_rec.segment26
9175 	,p_pgp_segment27                 => l_grp_rec.segment27
9176 	,p_pgp_segment28                 => l_grp_rec.segment28
9177 	,p_pgp_segment29                 => l_grp_rec.segment29
9178 	,p_pgp_segment30                 => l_grp_rec.segment30
9179 	,p_pgp_concat_segments           => l_grp_rec.group_name
9180 
9181 	,p_employee_category             => l_asg_rec1.employee_category
9182 	-- Out Vars
9183 	,p_special_ceiling_step_id       => l_AsgUpdCrit_Api.special_ceiling_step_id
9184 	,p_group_name                    => l_AsgUpdCrit_Api.group_name
9185 	,p_concatenated_segments         => l_scl_rec.concatenated_segments
9186 	,p_cagr_grade_def_id             => l_asg_rec.cagr_grade_def_id
9187 	,p_cagr_concatenated_segments    => l_UpdEmpAsg_out.cagr_concatenated_segments
9188 	,p_assignment_id                 => g_asg_rec.assignment_id
9189 	,p_soft_coding_keyflex_id        => l_AsgUpdCrit_Api.soft_coding_keyflex_id
9190 	,p_people_group_id               => l_AsgUpdCrit_Api.people_group_id
9191 	,p_object_version_number         => l_hrEmpApi_out.asg_object_version_number
9192 	,p_effective_start_date          => l_AsgUpdCrit_Api.asg_effective_start_date
9193 	,p_effective_end_date            => l_AsgUpdCrit_Api.asg_effective_end_date
9194 	,p_assignment_sequence           => l_hrEmpApi_out.assignment_sequence
9195 	,p_comment_id                    => l_UpdEmpAsg_out.comment_id
9196 	,p_other_manager_warning         => l_UpdEmpAsg_out.other_manager_warning
9197 	,p_hourly_salaried_warning       => l_UpdEmpAsg_out.hourly_salaried_warning
9198 	,p_gsp_post_process_warning      => l_UpdEmpAsg_out.gsp_post_process_warning);
9199 	return;
9200     else
9201        raise e_crt_asg_not_allowed;
9202     end if;
9203 
9204    elsif l_pty_rec.system_person_type = 'CWK' then
9205     if (g_crt_upd = 'C') then -- Should have Create privileges to create sec assignment
9206 	Hr_Assignment_Api.create_secondary_cwk_asg
9207 	(p_validate                      => false
9208 	,p_effective_date                => p_effective_date
9209 	,p_business_group_id             => g_business_group_id
9210 	,p_person_id                     => p_person_id
9211 	,p_organization_id               => g_asg_rec.organization_id
9212 	,p_assignment_number             => g_asg_rec.assignment_number
9213 
9214 	,p_assignment_category           => l_asg_rec1.employment_category
9215 	-- ,p_assignment_status_type_id    in     number
9216 	,p_change_reason                 => l_asg_rec1.change_reason
9217 	,p_comments                      => g_asg_comments
9218 	,p_default_code_comb_id          => l_asg_rec1.default_code_comb_id
9219 	--  ,p_establishment_id             in     number
9220 	,p_frequency                     => l_asg_rec1.frequency
9221 	,p_internal_address_line         => l_asg_rec1.internal_address_line
9222 	,p_job_id                        => l_asg_rec1.job_id
9223 	,p_labour_union_member_flag      => l_asg_rec1.labour_union_member_flag
9224 	,p_location_id                   => l_asg_rec1.location_id
9225 	,p_manager_flag                  => l_asg_rec1.manager_flag
9226 	,p_normal_hours                  => l_asg_rec1.normal_hours
9227 	,p_position_id                   => l_asg_rec1.position_id
9228 	,p_grade_id                      => l_asg_rec1.grade_id
9229 	-- ,p_project_title                in     varchar2
9230 	,p_set_of_books_id               => l_asg_rec1.set_of_books_id
9231 	,p_source_type                   => l_asg_rec1.source_type
9232 	,p_supervisor_id                 => l_asg_rec1.supervisor_id
9233 	,p_time_normal_finish            => l_asg_rec1.time_normal_finish
9234 	,p_time_normal_start             => l_asg_rec1.time_normal_start
9235 	,p_title                         => l_asg_rec1.title
9236 	,p_attribute_category            => l_asg_rec1.ass_attribute_category
9237 	,p_attribute1                    => l_asg_rec1.ass_attribute1
9238 	,p_attribute2                    => l_asg_rec1.ass_attribute2
9239 	,p_attribute3                    => l_asg_rec1.ass_attribute3
9240 	,p_attribute4                    => l_asg_rec1.ass_attribute4
9241 	,p_attribute5                    => l_asg_rec1.ass_attribute5
9242 	,p_attribute6                    => l_asg_rec1.ass_attribute6
9243 	,p_attribute7                    => l_asg_rec1.ass_attribute7
9244 	,p_attribute8                    => l_asg_rec1.ass_attribute8
9245 	,p_attribute9                    => l_asg_rec1.ass_attribute9
9246 	,p_attribute10                   => l_asg_rec1.ass_attribute10
9247 	,p_attribute11                   => l_asg_rec1.ass_attribute11
9248 	,p_attribute12                   => l_asg_rec1.ass_attribute12
9249 	,p_attribute13                   => l_asg_rec1.ass_attribute13
9250 	,p_attribute14                   => l_asg_rec1.ass_attribute14
9251 	,p_attribute15                   => l_asg_rec1.ass_attribute15
9252 	,p_attribute16                   => l_asg_rec1.ass_attribute16
9253 	,p_attribute17                   => l_asg_rec1.ass_attribute17
9254 	,p_attribute18                   => l_asg_rec1.ass_attribute18
9255 	,p_attribute19                   => l_asg_rec1.ass_attribute19
9256 	,p_attribute20                   => l_asg_rec1.ass_attribute20
9257 	,p_attribute21                   => l_asg_rec1.ass_attribute21
9258 	,p_attribute22                   => l_asg_rec1.ass_attribute22
9259 	,p_attribute23                   => l_asg_rec1.ass_attribute23
9260 	,p_attribute24                   => l_asg_rec1.ass_attribute24
9261 	,p_attribute25                   => l_asg_rec1.ass_attribute25
9262 	,p_attribute26                   => l_asg_rec1.ass_attribute26
9263 	,p_attribute27                   => l_asg_rec1.ass_attribute27
9264 	,p_attribute28                   => l_asg_rec1.ass_attribute28
9265 	,p_attribute29                   => l_asg_rec1.ass_attribute29
9266 	,p_attribute30                   => l_asg_rec1.ass_attribute30
9267 	-- People Group Flex
9268 	,p_pgp_segment1                  => l_grp_rec.segment1
9269 	,p_pgp_segment2                  => l_grp_rec.segment2
9270 	,p_pgp_segment3                  => l_grp_rec.segment3
9271 	,p_pgp_segment4                  => l_grp_rec.segment4
9272 	,p_pgp_segment5                  => l_grp_rec.segment5
9273 	,p_pgp_segment6                  => l_grp_rec.segment6
9274 	,p_pgp_segment7                  => l_grp_rec.segment7
9275 	,p_pgp_segment8                  => l_grp_rec.segment8
9276 	,p_pgp_segment9                  => l_grp_rec.segment9
9277 	,p_pgp_segment10                 => l_grp_rec.segment10
9278 	,p_pgp_segment11                 => l_grp_rec.segment11
9279 	,p_pgp_segment12                 => l_grp_rec.segment12
9280 	,p_pgp_segment13                 => l_grp_rec.segment13
9281 	,p_pgp_segment14                 => l_grp_rec.segment14
9282 	,p_pgp_segment15                 => l_grp_rec.segment15
9283 	,p_pgp_segment16                 => l_grp_rec.segment16
9284 	,p_pgp_segment17                 => l_grp_rec.segment17
9285 	,p_pgp_segment18                 => l_grp_rec.segment18
9286 	,p_pgp_segment19                 => l_grp_rec.segment19
9287 	,p_pgp_segment20                 => l_grp_rec.segment20
9288 	,p_pgp_segment21                 => l_grp_rec.segment21
9289 	,p_pgp_segment22                 => l_grp_rec.segment22
9290 	,p_pgp_segment23                 => l_grp_rec.segment23
9291 	,p_pgp_segment24                 => l_grp_rec.segment24
9292 	,p_pgp_segment25                 => l_grp_rec.segment25
9293 	,p_pgp_segment26                 => l_grp_rec.segment26
9294 	,p_pgp_segment27                 => l_grp_rec.segment27
9295 	,p_pgp_segment28                 => l_grp_rec.segment28
9296 	,p_pgp_segment29                 => l_grp_rec.segment29
9297 	,p_pgp_segment30                 => l_grp_rec.segment30
9298 	,p_pgp_concat_segments           => l_grp_rec.group_name
9299 	-- Hr Soft Coding KeyFlex segments
9300 	,p_scl_segment1                  => l_scl_rec.segment1
9301 	,p_scl_segment2                  => l_scl_rec.segment2
9302 	,p_scl_segment3                  => l_scl_rec.segment3
9303 	,p_scl_segment4                  => l_scl_rec.segment4
9304 	,p_scl_segment5                  => l_scl_rec.segment5
9305 	,p_scl_segment6                  => l_scl_rec.segment6
9306 	,p_scl_segment7                  => l_scl_rec.segment7
9307 	,p_scl_segment8                  => l_scl_rec.segment8
9308 	,p_scl_segment9                  => l_scl_rec.segment9
9309 	,p_scl_segment10                 => l_scl_rec.segment10
9310 	,p_scl_segment11                 => l_scl_rec.segment11
9311 	,p_scl_segment12                 => l_scl_rec.segment12
9312 	,p_scl_segment13                 => l_scl_rec.segment13
9313 	,p_scl_segment14                 => l_scl_rec.segment14
9314 	,p_scl_segment15                 => l_scl_rec.segment15
9315 	,p_scl_segment16                 => l_scl_rec.segment16
9316 	,p_scl_segment17                 => l_scl_rec.segment17
9317 	,p_scl_segment18                 => l_scl_rec.segment18
9318 	,p_scl_segment19                 => l_scl_rec.segment19
9319 	,p_scl_segment20                 => l_scl_rec.segment20
9320 	,p_scl_segment21                 => l_scl_rec.segment21
9321 	,p_scl_segment22                 => l_scl_rec.segment22
9322 	,p_scl_segment23                 => l_scl_rec.segment23
9323 	,p_scl_segment24                 => l_scl_rec.segment24
9324 	,p_scl_segment25                 => l_scl_rec.segment25
9325 	,p_scl_segment26                 => l_scl_rec.segment26
9326 	,p_scl_segment27                 => l_scl_rec.segment27
9327 	,p_scl_segment28                 => l_scl_rec.segment28
9328 	,p_scl_segment29                 => l_scl_rec.segment29
9329 	,p_scl_segment30                 => l_scl_rec.segment30
9330 	,p_scl_concat_segments           => l_scl_rec.concatenated_segments
9331 
9332 	--  ,p_supervisor_assignment_id     in     number
9333 
9334 	,p_assignment_id                 => g_asg_rec.assignment_id
9335 	,p_object_version_number         => l_hrEmpApi_out.asg_object_version_number
9336 	,p_effective_start_date          => l_AsgUpdCrit_Api.asg_effective_start_date
9337 	,p_effective_end_date            => l_AsgUpdCrit_Api.asg_effective_end_date
9338 	,p_assignment_sequence           => l_hrEmpApi_out.assignment_sequence
9339 	,p_comment_id                    => l_UpdEmpAsg_out.comment_id
9340 	,p_people_group_id               => l_AsgUpdCrit_Api.people_group_id
9341 	,p_people_group_name             => l_AsgUpdCrit_Api.group_name
9342 	,p_other_manager_warning         => l_UpdEmpAsg_out.other_manager_warning
9343 	,p_hourly_salaried_warning       => l_UpdEmpAsg_out.hourly_salaried_warning
9344 	,p_soft_coding_keyflex_id        => l_AsgUpdCrit_Api.soft_coding_keyflex_id);
9345 	return;
9346     else
9347        raise e_crt_asg_not_allowed;
9348     end if;
9349     elsif l_pty_rec.system_person_type = 'APL' then
9350 
9351      if(g_crt_upd = 'C') then
9352     hr_utility.set_location('Creating secondary assignment', 11);
9353     hr_assignment_api.create_secondary_apl_asg
9354   (p_validate                     =>     false
9355   ,p_effective_date               =>     p_effective_date
9356   ,p_person_id                    =>     p_person_id
9357   ,p_organization_id              =>     l_asg_rec1.organization_id
9358   ,p_recruiter_id                 =>     l_asg_rec1.recruiter_id
9359   ,p_grade_id                     =>     l_asg_rec1.grade_id
9360   ,p_position_id                  =>     l_asg_rec1.position_id
9361   ,p_job_id                       =>     l_asg_rec1.job_id
9362   ,p_assignment_status_type_id    =>     l_asg_rec1.assignment_status_type_id
9363   ,p_payroll_id                   =>     l_asg_rec1.payroll_id
9364   ,p_location_id                  =>     l_asg_rec1.location_id
9365   ,p_person_referred_by_id        =>     l_asg_rec1.person_referred_by_id
9366   ,p_supervisor_id                =>     l_asg_rec1.supervisor_id
9367   ,p_special_ceiling_step_id      =>     l_asg_rec1.special_ceiling_step_id
9368   ,p_recruitment_activity_id      =>     l_asg_rec1.recruitment_activity_id
9369   ,p_source_organization_id       =>     l_asg_rec1.source_organization_id
9370   ,p_vacancy_id                   =>     l_asg_rec1.vacancy_id
9371   ,p_pay_basis_id                 =>     l_asg_rec1.pay_basis_id
9372   ,p_change_reason                =>     l_asg_rec1.change_reason
9373   ,p_comments                     =>     g_asg_comments
9374   ,p_date_probation_end           =>     l_asg_rec1.date_probation_end
9375   ,p_default_code_comb_id         =>     l_asg_rec1.default_code_comb_id
9376   ,p_employment_category          =>     l_asg_rec1.employment_category
9377   ,p_frequency                    =>     l_asg_rec1.frequency
9378   ,p_internal_address_line        =>     l_asg_rec1.internal_address_line
9379   ,p_manager_flag                 =>     l_asg_rec1.manager_flag
9380   ,p_normal_hours                 =>     l_asg_rec1.normal_hours
9381   ,p_perf_review_period           =>     l_asg_rec1.perf_review_period
9382   ,p_perf_review_period_frequency =>     l_asg_rec1.perf_review_period_frequency
9383   ,p_probation_period             =>     l_asg_rec1.probation_period
9384   ,p_probation_unit               =>     l_asg_rec1.probation_unit
9385   ,p_sal_review_period            =>     l_asg_rec1.sal_review_period
9386   ,p_sal_review_period_frequency  =>     l_asg_rec1.sal_review_period_frequency
9387   ,p_set_of_books_id              =>     l_asg_rec1.set_of_books_id
9388   ,p_source_type                  =>     l_asg_rec1.source_type
9389   ,p_time_normal_finish           =>     l_asg_rec1.time_normal_finish
9390   ,p_time_normal_start            =>     l_asg_rec1.time_normal_start
9391   ,p_bargaining_unit_code         =>     l_asg_rec1.bargaining_unit_code
9392   ,p_ass_attribute_category       => l_asg_rec1.ass_attribute_category
9393   ,p_ass_attribute1               => l_asg_rec1.ass_attribute1
9394   ,p_ass_attribute2               => l_asg_rec1.ass_attribute2
9395   ,p_ass_attribute3               => l_asg_rec1.ass_attribute3
9396   ,p_ass_attribute4               => l_asg_rec1.ass_attribute4
9397   ,p_ass_attribute5               => l_asg_rec1.ass_attribute5
9398   ,p_ass_attribute6               => l_asg_rec1.ass_attribute6
9399   ,p_ass_attribute7               => l_asg_rec1.ass_attribute7
9400   ,p_ass_attribute8               => l_asg_rec1.ass_attribute8
9401   ,p_ass_attribute9               => l_asg_rec1.ass_attribute9
9402   ,p_ass_attribute10              => l_asg_rec1.ass_attribute10
9403   ,p_ass_attribute11              => l_asg_rec1.ass_attribute11
9404   ,p_ass_attribute12              => l_asg_rec1.ass_attribute12
9405   ,p_ass_attribute13              => l_asg_rec1.ass_attribute13
9406   ,p_ass_attribute14              => l_asg_rec1.ass_attribute14
9407   ,p_ass_attribute15              => l_asg_rec1.ass_attribute15
9408   ,p_ass_attribute16              => l_asg_rec1.ass_attribute16
9409   ,p_ass_attribute17              => l_asg_rec1.ass_attribute17
9410   ,p_ass_attribute18              => l_asg_rec1.ass_attribute18
9411   ,p_ass_attribute19              => l_asg_rec1.ass_attribute19
9412   ,p_ass_attribute20              => l_asg_rec1.ass_attribute20
9413   ,p_ass_attribute21              => l_asg_rec1.ass_attribute21
9414   ,p_ass_attribute22              => l_asg_rec1.ass_attribute22
9415   ,p_ass_attribute23              => l_asg_rec1.ass_attribute23
9416   ,p_ass_attribute24              => l_asg_rec1.ass_attribute24
9417   ,p_ass_attribute25              => l_asg_rec1.ass_attribute25
9418   ,p_ass_attribute26              => l_asg_rec1.ass_attribute26
9419   ,p_ass_attribute27              => l_asg_rec1.ass_attribute27
9420   ,p_ass_attribute28              => l_asg_rec1.ass_attribute28
9421   ,p_ass_attribute29              => l_asg_rec1.ass_attribute29
9422   ,p_ass_attribute30              => l_asg_rec1.ass_attribute30
9423   ,p_title                        => l_asg_rec1.title
9424   ,p_scl_segment1                 => l_scl_rec.segment1
9425   ,p_scl_segment2                 => l_scl_rec.segment2
9426   ,p_scl_segment3                 => l_scl_rec.segment3
9427   ,p_scl_segment4                 => l_scl_rec.segment4
9428   ,p_scl_segment5                 => l_scl_rec.segment5
9429   ,p_scl_segment6                 => l_scl_rec.segment6
9430   ,p_scl_segment7                 => l_scl_rec.segment7
9431   ,p_scl_segment8                 => l_scl_rec.segment8
9432   ,p_scl_segment9                 => l_scl_rec.segment9
9433   ,p_scl_segment10                => l_scl_rec.segment10
9434   ,p_scl_segment11                => l_scl_rec.segment11
9435   ,p_scl_segment12                => l_scl_rec.segment12
9436   ,p_scl_segment13                => l_scl_rec.segment13
9437   ,p_scl_segment14                => l_scl_rec.segment14
9438   ,p_scl_segment15                => l_scl_rec.segment15
9439   ,p_scl_segment16                => l_scl_rec.segment16
9440   ,p_scl_segment17                => l_scl_rec.segment17
9441   ,p_scl_segment18                => l_scl_rec.segment18
9442   ,p_scl_segment19                => l_scl_rec.segment19
9443   ,p_scl_segment20                => l_scl_rec.segment20
9444   ,p_scl_segment21                => l_scl_rec.segment21
9445   ,p_scl_segment22                => l_scl_rec.segment22
9446   ,p_scl_segment23                => l_scl_rec.segment23
9447   ,p_scl_segment24                => l_scl_rec.segment24
9448   ,p_scl_segment25                => l_scl_rec.segment25
9449   ,p_scl_segment26                => l_scl_rec.segment26
9450   ,p_scl_segment27                => l_scl_rec.segment27
9451   ,p_scl_segment28                => l_scl_rec.segment28
9452   ,p_scl_segment29                => l_scl_rec.segment29
9453   ,p_scl_segment30                => l_scl_rec.segment30
9454   ,p_scl_concat_segments          => l_scl_rec.concatenated_segments
9455   ,p_concatenated_segments        => l_concat_segments
9456   ,p_pgp_segment1                 => l_grp_rec.segment1
9457   ,p_pgp_segment2                 => l_grp_rec.segment2
9458   ,p_pgp_segment3                 => l_grp_rec.segment3
9459   ,p_pgp_segment4                 => l_grp_rec.segment4
9460   ,p_pgp_segment5                 => l_grp_rec.segment5
9461   ,p_pgp_segment6                 => l_grp_rec.segment6
9462   ,p_pgp_segment7                 => l_grp_rec.segment7
9463   ,p_pgp_segment8                 => l_grp_rec.segment8
9464   ,p_pgp_segment9                 => l_grp_rec.segment9
9465   ,p_pgp_segment10                => l_grp_rec.segment10
9466   ,p_pgp_segment11                => l_grp_rec.segment11
9467   ,p_pgp_segment12                => l_grp_rec.segment12
9468   ,p_pgp_segment13                => l_grp_rec.segment13
9469   ,p_pgp_segment14                => l_grp_rec.segment14
9470   ,p_pgp_segment15                => l_grp_rec.segment15
9471   ,p_pgp_segment16                => l_grp_rec.segment16
9472   ,p_pgp_segment17                => l_grp_rec.segment17
9473   ,p_pgp_segment18                => l_grp_rec.segment18
9474   ,p_pgp_segment19                => l_grp_rec.segment19
9475   ,p_pgp_segment20                => l_grp_rec.segment20
9476   ,p_pgp_segment21                => l_grp_rec.segment21
9477   ,p_pgp_segment22                => l_grp_rec.segment22
9478   ,p_pgp_segment23                => l_grp_rec.segment23
9479   ,p_pgp_segment24                => l_grp_rec.segment24
9480   ,p_pgp_segment25                => l_grp_rec.segment25
9481   ,p_pgp_segment26                => l_grp_rec.segment26
9482   ,p_pgp_segment27                => l_grp_rec.segment27
9483   ,p_pgp_segment28                => l_grp_rec.segment28
9484   ,p_pgp_segment29                => l_grp_rec.segment29
9485   ,p_pgp_segment30                => l_grp_rec.segment30
9486   ,p_concat_segments              => l_grp_rec.group_name
9487   ,p_cagr_id_flex_num             =>     null
9488   ,p_cag_segment1                 =>     null
9489   ,p_cag_segment2                 =>     null
9490   ,p_cag_segment3                 =>     null
9491   ,p_cag_segment4                 =>     null
9492   ,p_cag_segment5                 =>     null
9493   ,p_cag_segment6                 =>     null
9494   ,p_cag_segment7                 =>     null
9495   ,p_cag_segment8                 =>     null
9496   ,p_cag_segment9                 =>     null
9497   ,p_cag_segment10                =>     null
9498   ,p_cag_segment11                =>     null
9499   ,p_cag_segment12                =>     null
9500   ,p_cag_segment13                =>     null
9501   ,p_cag_segment14                =>     null
9502   ,p_cag_segment15                =>     null
9503   ,p_cag_segment16                =>     null
9504   ,p_cag_segment17                =>     null
9505   ,p_cag_segment18                =>     null
9506   ,p_cag_segment19                =>     null
9507   ,p_cag_segment20                =>     null
9508   ,p_contract_id                  =>     l_asg_rec1.contract_id
9509   ,p_establishment_id             =>     l_asg_rec1.establishment_id
9510   ,p_collective_agreement_id      =>     l_asg_rec1.collective_agreement_id
9511   ,p_notice_period		            =>    l_asg_rec1.notice_period
9512   ,p_notice_period_uom		        =>     l_asg_rec1.notice_period_uom
9513   ,p_employee_category		        =>     l_asg_rec1.employee_category
9514   ,p_work_at_home		              =>	   l_asg_rec1.work_at_home
9515   ,p_job_post_source_name         =>     l_asg_rec1.job_post_source_name
9516   ,p_applicant_rank               =>     l_asg_rec1.applicant_rank
9517   ,p_posting_content_id           =>     l_asg_rec1.posting_content_id
9518   ,p_grade_ladder_pgm_id          =>     l_asg_rec1.grade_ladder_pgm_id
9519   ,p_supervisor_assignment_id     =>     l_asg_rec1.supervisor_assignment_id
9520 	,p_cagr_grade_def_id            => l_asg_rec.cagr_grade_def_id
9521 	,p_cagr_concatenated_segments   => l_UpdEmpAsg_out.cagr_concatenated_segments
9522 	,p_group_name                   => l_AsgUpdCrit_Api.group_name
9523   ,p_assignment_id                => g_asg_rec.assignment_id
9524 	,p_people_group_id              => l_AsgUpdCrit_Api.people_group_id
9525 	,p_soft_coding_keyflex_id       => l_AsgUpdCrit_Api.soft_coding_keyflex_id
9526 	,p_comment_id                   => l_UpdEmpAsg_out.comment_id
9527   ,p_object_version_number        => l_hrEmpApi_out.asg_object_version_number
9528 	,p_effective_start_date         => l_AsgUpdCrit_Api.asg_effective_start_date
9529 	,p_effective_end_date            => l_AsgUpdCrit_Api.asg_effective_end_date
9530 	,p_assignment_sequence           => l_hrEmpApi_out.assignment_sequence
9531   ,p_appl_override_warning         => l_appl_override_warning);
9532    return;
9533      else
9534           raise e_crt_asg_not_allowed;
9535      end if;
9536 
9537     end if;
9538 
9539   else
9540 	g_asg_rec.person_id := l_asg_rec.person_id;
9541 	g_asg_rec.business_group_id := l_asg_rec.business_group_id;
9542 	g_asg_rec.assignment_id := l_asg_rec.assignment_id;
9543 	--g_asg_rec.assignment_status_type_id := l_asg_rec.assignment_status_type_id;
9544   end if;
9545 
9546 
9547   --hr_utility.trace('BEFORE ENTERING Update_Employee_Asg with assntype as E' );
9548 
9549  if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9550    if l_asg_rec.assignment_type ='E' then
9551      Update_Employee_Asg
9552      (p_effective_date => p_effective_date
9553      ,p_asg_crit_out   => l_AsgUpdCrit_Api
9554      );
9555 
9556    --hr_utility.trace('AFTER Update_Employee_Asg with assntype as E' );
9557 
9558    elsif l_asg_rec.assignment_type ='C' then
9559      Upd_Contingent_Asg
9560     (p_effective_date => p_effective_date
9561     ,p_asg_crit_out   => l_AsgUpdCrit_Api
9562      );
9563    elsif l_asg_rec.assignment_type ='A' then
9564      Upd_Applicant_Asg
9565     (p_effective_date => p_effective_date
9566     ,p_asg_crit_out   => l_AsgUpdCrit_Api
9567      );
9568    end if;
9569  else
9570    raise e_upl_not_allowed;
9571  end if;
9572 
9573  Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
9574 
9575 end Update_Assignment;
9576 -- =============================================================================
9577 -- Direct_API_Call:
9578 -- =============================================================================
9579 procedure Direct_API_Call
9580          (p_dup_person_id       in number
9581          ,p_dup_party_id        in number
9582          ,p_appl_asg_id         in number
9583          ,p_effective_date      in date
9584          ,p_business_group_id   in number
9585          ,p_adjusted_svc_date   in date default null  -- Added by pkagrawa
9586          ) is
9587   l_hrEmpApi_out          t_hrEmpApi;
9588   l_asg_crit_out          t_AsgUpdCrit_Api;
9589   l_UpdEmp_Api            t_UpdEmp_Api;
9590   l_HrApp_Api             t_HrApp_Api;
9591   l_AsgUpdCrit_Api        t_AsgUpdCrit_Api;
9592 
9593   l_hire_Into_Employee    boolean;
9594   l_Apply_ForJob          boolean;
9595   l_Convert_To_CWK        boolean;
9596   l_Per_Exists_InHR       boolean;
9597   l_hire_Applicant        boolean;
9598   l_Convert_To_Applicant  boolean;
9599 
9600   l_Input_PerType         varchar2(90);
9601   l_action_mode           varchar2(90);
9602   l_proc_name    constant varchar2(150) := g_pkg||'Direct_API_Call';
9603 
9604 begin
9605   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
9606   --
9607   -- If person id is passed check the creating person type with the person
9608   -- type of the person present in HRMS, to select the appropiate action.
9609   --
9610     --hr_utility.trace('Inside Direct_API_Call');
9611 
9612   Chk_Person_InHR
9613   (p_dup_person_id        => p_dup_person_id
9614   ,p_dup_party_id         => p_dup_party_id
9615   ,p_effective_date       => p_effective_date
9616   ,p_business_group_id    => p_business_group_id
9617   -- Out
9618   ,p_Input_PerType        => l_Input_PerType
9619   ,p_hire_Into_Employee   => l_hire_Into_Employee
9620   ,p_hire_Applicant       => l_hire_Applicant
9621   ,p_Convert_To_Applicant => l_Convert_To_Applicant
9622   ,p_Apply_For_Job        => l_Apply_ForJob
9623   ,p_Convert_To_CWK       => l_Convert_To_CWK
9624   ,p_Per_Exists_InHR      => l_Per_Exists_InHR
9625   );
9626   --
9627   -- Creating an Employee
9628   --
9629 
9630       --hr_utility.trace(' l_Input_PerType='||l_Input_PerType);
9631 
9632   if l_Input_PerType = 'EMP' then
9633 
9634            --hr_utility.trace(' Inside PerType=EMP');
9635 
9636      if l_hire_Into_Employee then
9637         if (g_crt_upd = 'C') then
9638         l_action_mode := 'HIRE_PERSON_INTOEMP';
9639         else
9640         raise e_crt_per_not_allowed;
9641         end if;
9642      elsif l_hire_Applicant then
9643         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9644         l_action_mode := 'HIRE_APPLICANT';
9645         else
9646         raise e_upl_not_allowed;
9647         end if;
9648      else
9649         if (g_crt_upd = 'C') then
9650         l_action_mode := 'CREATE_EMPLOYEE';
9651         else
9652         raise e_crt_per_not_allowed;
9653         end if;
9654      end if;
9655      --
9656     --hr_utility.trace(' l_action_mode='||l_action_mode);
9657 
9658      if l_action_mode in ('CREATE_EMPLOYEE',
9659                           'HIRE_PERSON_INTOEMP') then
9660         InsUpd_Employee
9661         (p_validate       => false
9662         ,p_action_mode    => l_action_mode
9663         ,p_effective_date => p_effective_date
9664         --Added by Dbansal
9665         ,p_per_comments  => g_per_comments
9666         ,p_emp_api_out    => l_hrEmpApi_out
9667         ,p_adjusted_svc_date => p_adjusted_svc_date -- Added by pkagrawa
9668          );
9669      elsif l_action_mode = 'HIRE_APPLICANT' then
9670         Hire_Applicant_IntoEmp
9671         (p_validate            => false
9672         ,p_hire_date           => p_effective_date
9673         ,p_person_id           => p_dup_person_id
9674         ,p_assignment_id       => p_appl_asg_id
9675 --        ,p_adjusted_svc_date   => null  --Commented by pkagrawa
9676         ,p_adjusted_svc_date   => p_adjusted_svc_date -- Added by pkagrawa
9677         ,p_updper_api_out      => l_UpdEmp_Api
9678         ,p_HireAppapi_out      => l_HrApp_Api
9679         );
9680      end if;
9681      --
9682      -- Insert/Update Person Primary Address
9683      --
9684      InsUpd_Address
9685      (p_effective_date           => g_per_rec.start_date
9686      ,p_HR_address_id            => g_add_rec.address_id
9687      ,p_HR_object_version_number => g_add_rec.object_version_number
9688       );
9689      --
9690      -- Update the Employee Assignment
9691      --
9692      --$ Update Assignment only if User wants to i.e. he has entered mandatory column
9693       -- 'Assign Organization'
9694 
9695      --$ while updating assignment pass assignment effective start date as obtained
9696      -- from spreadsheet by default and if it is null then use person start date as
9697      -- assignment effective start date
9698      if (g_asg_rec.organization_id is NOT NULL) then
9699         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9700          Update_Employee_Asg
9701         (p_effective_date =>  nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
9702         ,p_asg_crit_out   => l_asg_crit_out
9703          );
9704         else
9705         raise e_upl_not_allowed;
9706         end if;
9707   end if;
9708 
9709   end if;
9710   --
9711   -- Creating a Contingent Worker
9712   --
9713   if l_Input_PerType = 'CWK' then
9714 
9715            --hr_utility.trace(' Inside PerType=CWK');
9716 
9717      if l_Convert_To_CWK then
9718         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9719         l_action_mode := 'CONVERT_TO_CWK';
9720         else
9721         raise e_upl_not_allowed;
9722         end if;
9723      else
9724         if (g_crt_upd = 'C') then
9725         l_action_mode := 'CREATE_CWK';
9726         else
9727         raise e_crt_per_not_allowed;
9728         end if;
9729      end if;
9730      --
9731      -- Create/Convert the person into an Contigent Worker
9732      --
9733      InsUpd_Contingent_Worker
9734      (p_validate              => false
9735      ,p_action_mode           => l_action_mode
9736      ,p_datetrack_update_mode => Null
9737      ,p_effective_date        => p_effective_date
9738      ,p_adjusted_svc_date     => null
9739      ,p_per_comments          => g_per_comments -- null --Changed by Dbansal
9740      ,p_cwk_api_out           => l_hrEmpApi_out
9741       );
9742      --
9743      -- Update/Insert Address
9744      --
9745      InsUpd_Address
9746      (p_effective_date           => g_per_rec.start_date
9747      ,p_HR_address_id            => g_add_rec.address_id
9748      ,p_HR_object_version_number => g_add_rec.object_version_number
9749       );
9750      --
9751      -- Update the Contingent Worker assignment
9752      --
9753       --$ Update Assignment only if User wants to i.e. he has entered mandatory column
9754       -- 'Assign Organization'
9755       --$ while updating assignment pass assignment effective start date as obtained
9756       -- from spreadsheet by default and if it is null then use person start date as
9757       -- assignment effective start date
9758      if (g_asg_rec.organization_id is NOT NULL) then
9759        if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9760        Upd_Contingent_Asg
9761        (p_effective_date => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
9762        ,p_asg_crit_out   => l_asg_crit_out
9763         );
9764        else
9765        raise e_upl_not_allowed;
9766        end if;
9767       end if;
9768   end if;
9769   --
9770   -- Creating an Applicant for a Job
9771   --
9772 
9773 
9774   if l_Input_PerType = 'APL' then
9775 
9776           --hr_utility.trace(' Inside PerType=APL');
9777 
9778      if l_Convert_To_Applicant or
9779         l_Apply_ForJob         then
9780        if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9781        l_action_mode := 'APPLY_FOR_JOB';
9782        else
9783        raise e_upl_not_allowed;
9784        end if;
9785      else
9786        if (g_crt_upd = 'C') then
9787        l_action_mode := 'CREATE_APPLICANT';
9788        else
9789        raise e_crt_per_not_allowed;
9790        end if;
9791      end if;
9792      --
9793      -- Create/Convert the person into an applicant
9794      --
9795      InsUpd_Applicant
9796     (p_validate          => false
9797     ,p_action_mode       => l_action_mode
9798     ,p_effective_date    => p_effective_date
9799     ,p_adjusted_svc_date => null
9800     ,p_per_comments      => g_per_comments -- null --Changed by Dbansal
9801     ,p_assignment_id     => p_appl_asg_id
9802     ,p_appl_api_out      => l_hrEmpApi_out
9803      );
9804      --
9805      -- Update/Insert Address
9806      --
9807      InsUpd_Address
9808     (p_effective_date           => g_per_rec.start_date
9809     ,p_HR_address_id            => g_add_rec.address_id
9810     ,p_HR_object_version_number => g_add_rec.object_version_number
9811      );
9812      --
9813      -- Update the Applicant assignment
9814      --
9815       --$ Update Assignment only if User wants to i.e. he has entered mandatory column
9816       -- 'Assign Organization'
9817       --$ while updating assignment pass assignment effective start date as obtained
9818       -- from spreadsheet by default and if it is null then use person start date as
9819       -- assignment effective start date
9820 
9821      if (g_asg_rec.organization_id is NOT NULL) then
9822        if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9823        Upd_Applicant_Asg
9824        (p_effective_date => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date)
9825        ,p_asg_crit_out   => l_AsgUpdCrit_Api
9826         );
9827        else
9828        raise e_upl_not_allowed;
9829        end if;
9830      end if;
9831      --
9832   end if;
9833   --
9834   -- Create the contact person only if the person does exists
9835   --
9836 
9837   if l_Input_PerType = 'OTHER' then
9838 
9839         --hr_utility.trace('Inside PerType=OTHER');
9840 
9841      if not l_Per_Exists_InHR then
9842         if (g_crt_upd = 'C') then
9843         InsUpd_Contact_Person
9844         (p_validate            => false
9845         ,p_effective_date      => p_effective_date
9846         ,p_adjusted_svc_date   => null
9847         ,p_per_comments        =>  null
9848         ,p_contact_api_out     => l_hrEmpApi_out
9849          );
9850        else
9851        raise e_crt_per_not_allowed;
9852        end if;
9853      else
9854         if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9855         Upd_Person_Details
9856         (p_validate            => false
9857         ,p_effective_date      => p_effective_date
9858         ,p_person_id           => g_per_rec.person_id
9859         ,p_adjusted_svc_date   => null
9860         ,p_updper_api_out      => l_UpdEmp_Api
9861          );
9862          else
9863          raise e_upl_not_allowed;
9864          end if;
9865      end if;
9866 
9867      g_add_rec.person_id := g_per_rec.person_id;
9868      g_add_rec.party_id := g_add_rec.party_id;
9869      g_add_rec.business_group_id := p_business_group_id;
9870 
9871      InsUpd_Address
9872      (p_effective_date           => g_per_rec.start_date
9873      ,p_HR_address_id            => g_add_rec.address_id
9874      ,p_HR_object_version_number => g_add_rec.object_version_number
9875       );
9876   end if;
9877   --
9878   -- If the person already exists with the same person type then
9879   -- just update the person details.
9880   --
9881 
9882   if l_Input_PerType = 'UPD_PERSON' then
9883 
9884     --hr_utility.trace(' Inside PerType=UPD_PERSON');
9885     if (g_crt_upd = 'C' or g_crt_upd = 'U') then
9886      Upd_Person_Details
9887      (p_validate            => false
9888      ,p_effective_date      => p_effective_date
9889      ,p_person_id           => g_per_rec.person_id
9890 --    ,p_adjusted_svc_date   => null  --Commented by pkagrawa
9891      ,p_adjusted_svc_date   => p_adjusted_svc_date -- Added by pkagrawa
9892      ,p_updper_api_out      => l_UpdEmp_Api
9893       );
9894     else
9895       raise e_upl_not_allowed;
9896     end if;
9897 
9898 
9899      g_add_rec.person_id := g_per_rec.person_id;
9900      g_add_rec.party_id  := g_per_rec.party_id;
9901      g_add_rec.business_group_id := p_business_group_id;
9902 
9903      InsUpd_Address
9904      (p_effective_date           => g_per_rec.start_date
9905      ,p_HR_address_id            => g_add_rec.address_id
9906      ,p_HR_object_version_number => g_add_rec.object_version_number
9907       );
9908 
9909       --$ Update Assignment only if User wants to i.e. he has entered mandatory column
9910       -- 'Assign Organization'
9911       --$ while updating assignment pass assignment effective start date as obtained
9912       -- from spreadsheet by default and if it is null then use person start date as
9913       -- assignment effective start date
9914 
9915      if (g_asg_rec.organization_id is NOT NULL) then
9916      Update_Assignment
9917      (p_effective_date    => nvl(g_asg_rec.effective_start_date,g_per_rec.start_date) --p_effective_date
9918      ,p_business_group_id => p_business_group_id
9919      ,p_person_id         => g_per_rec.person_id
9920       );
9921       end if;
9922 
9923   end  if;
9924 
9925   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
9926 
9927 end Direct_API_Call;
9928 
9929 -- =============================================================================
9930 -- Get_AplAsg_Id:
9931 -- =============================================================================
9932 function Get_AplAsg_Id
9933          (p_person_id         in number
9934          ,p_apl_asg_no        in varchar2
9935          ,p_business_group_id in number
9936          ,p_effective_date    in date
9937          ) return number is
9938 
9939   cursor csr_asg (c_assignment_number in varchar2
9940                  ,c_person_id         in number
9941                  ,c_business_group_id in number
9942                  ,c_effective_date    in date
9943                  ) is
9944   select paf.assignment_id
9945     from per_all_assignments_f paf
9946    where paf.person_id = c_person_id
9947      and paf.assignment_type = 'A'
9948      and paf.assignment_number = c_assignment_number
9949      and paf.business_group_id = c_business_group_id
9950      and c_effective_date between paf.effective_start_date
9951                               and paf.effective_end_date;
9952 --$ New cursor for Applicant with no assignment number.
9953   cursor csr_asg_n (c_person_id         in number
9954                  ,c_business_group_id in number
9955                  ,c_effective_date    in date
9956                  ) is
9957   select paf.assignment_id
9958     from per_all_assignments_f paf
9959    where paf.person_id = c_person_id
9960      and paf.assignment_type = 'A'
9961      and paf.business_group_id = c_business_group_id
9962      and c_effective_date between paf.effective_start_date
9963                               and paf.effective_end_date;
9964 
9965   l_asg_rec        csr_asg%rowtype;
9966   l_asg_rec_n	   csr_asg_n%rowtype;
9967   l_AsgUpdCrit_Api t_AsgUpdCrit_Api;
9968   l_apl_asg_id     number;
9969   l_proc_name    constant varchar2(150) := g_pkg||'Get_AplAsg_Id';
9970 
9971 begin
9972   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
9973 if p_apl_asg_no is not null then
9974   open csr_asg (c_assignment_number => p_apl_asg_no
9975                ,c_person_id         => p_person_id
9976                ,c_business_group_id => p_business_group_id
9977                ,c_effective_date    => p_effective_date
9978                );
9979   fetch csr_asg into l_asg_rec;
9980 
9981   if  csr_asg%notfound then
9982     close csr_asg;
9983     return l_apl_asg_id;
9984   else
9985     l_apl_asg_id := l_asg_rec.assignment_id;
9986   end if;
9987   close csr_asg;
9988   return l_apl_asg_id;
9989 else
9990 	open csr_asg_n (c_person_id         => p_person_id
9991                ,c_business_group_id => p_business_group_id
9992                ,c_effective_date    => p_effective_date
9993                );
9994 	fetch csr_asg_n into l_asg_rec_n;
9995 	if  csr_asg_n%notfound then
9996 		 close csr_asg_n;
9997 	return l_apl_asg_id;
9998 	else
9999 	l_apl_asg_id := l_asg_rec_n.assignment_id;
10000 	end if;
10001 	     close csr_asg_n;
10002 	  return l_apl_asg_id;
10003 end if;
10004 
10005  Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
10006 
10007 end Get_AplAsg_Id;
10008 -- =============================================================================
10009 -- ~ InsUpd_PerAsgAdd_Rec:
10010 -- =============================================================================
10011 procedure InsUpd_PerAsgAdd_Rec
10012          (p_last_name                    in varchar2
10013          ,p_middle_name                  in varchar2
10014          ,p_first_name                   in varchar2
10015          ,p_suffix                       in varchar2
10016          ,p_prefix                       in varchar2
10017          ,p_title                        in varchar2
10018          ,p_email_address                in varchar2
10019          ,p_preferred_name               in varchar2
10020          ,p_dup_person_id                in number
10021          ,p_dup_party_id                 in number
10022          ,p_marital_status               in varchar2
10023          ,p_sex                          in varchar2
10024          ,p_nationality                  in varchar2
10025          ,p_national_identifier          in varchar2
10026          ,p_date_of_birth                in date
10027          ,p_date_of_hire                 in date
10028          ,p_employee_number              in varchar2
10029          ,p_primary_flag                 in varchar2
10030          ,p_address_style                in varchar2
10031          ,p_address_line1                in varchar2
10032          ,p_address_line2                in varchar2
10033          ,p_address_line3                in varchar2
10034          ,p_region1                      in varchar2
10035          ,p_region2                      in varchar2
10036          ,p_region3                      in varchar2
10037          ,p_town_or_city                 in varchar2
10038          ,p_country                      in varchar2
10039          ,p_postal_code                  in varchar2
10040          ,p_telephone_no1                in varchar2
10041          ,p_telephone_no2                in varchar2
10042          ,p_telephone_no3                in varchar2
10043          ,p_address_date_from            in date
10044          ,p_address_date_to              in date
10045          ,p_phone_type                   in varchar2
10046          ,p_phone_number                 in varchar2
10047          ,p_phone_date_from              in date
10048          ,p_phone_date_to                in date
10049          ,p_contact_type                 in varchar2
10050          ,p_contact_name                 in varchar2
10051          ,p_primary_contact              in varchar2
10052          ,p_personal_flag                in varchar2
10053          ,p_contact_date_from            in date
10054          ,p_contact_date_to              in date
10055          ,p_assign_organization          in varchar2
10056          ,p_job                          in number
10057          ,p_grade                        in number
10058          ,p_internal_location            in varchar2
10059          ,p_assign_group                 in varchar2
10060          ,p_position                     in number
10061          ,p_payroll                      in number
10062          ,p_status                       in varchar2
10063          ,p_assignment_no                in varchar2
10064          ,p_assignment_category          in varchar2
10065          ,p_collective_agreement         in varchar2
10066          ,p_employee_category            in varchar2
10067          ,p_user_person_type             in number
10068          ,p_salary_basis                 in number
10069          ,p_gre                          in varchar2
10070          ,p_web_adi_identifier           in varchar2
10071          ,p_assign_eff_dt_from           in date
10072          ,p_assign_eff_dt_to             in date
10073          -- Person DF Information
10074          ,p_per_attribute_category       in varchar2
10075          ,p_per_attribute1               in varchar2
10076          ,p_per_attribute2               in varchar2
10077          ,p_per_attribute3               in varchar2
10078          ,p_per_attribute4               in varchar2
10079          ,p_per_attribute5               in varchar2
10080          ,p_per_attribute6               in varchar2
10081          ,p_per_attribute7               in varchar2
10082          ,p_per_attribute8               in varchar2
10083          ,p_per_attribute9               in varchar2
10084          ,p_per_attribute10              in varchar2
10085          ,p_per_attribute11              in varchar2
10086          ,p_per_attribute12              in varchar2
10087          ,p_per_attribute13              in varchar2
10088          ,p_per_attribute14              in varchar2
10089          ,p_per_attribute15              in varchar2
10090          ,p_per_attribute16              in varchar2
10091          ,p_per_attribute17              in varchar2
10092          ,p_per_attribute18              in varchar2
10093          ,p_per_attribute19              in varchar2
10094          ,p_per_attribute20              in varchar2
10095          ,p_per_attribute21              in varchar2
10096          ,p_per_attribute22              in varchar2
10097          ,p_per_attribute23              in varchar2
10098          ,p_per_attribute24              in varchar2
10099          ,p_per_attribute25              in varchar2
10100          ,p_per_attribute26              in varchar2
10101          ,p_per_attribute27              in varchar2
10102          ,p_per_attribute28              in varchar2
10103          ,p_per_attribute29              in varchar2
10104          ,p_per_attribute30              in varchar2
10105          -- Person Legislative Information
10106          ,p_per_information_category     in varchar2
10107          ,p_per_information1             in varchar2
10108          ,p_per_information2             in varchar2
10109          ,p_per_information3             in varchar2
10110          ,p_per_information4             in varchar2
10111          ,p_per_information5             in varchar2
10112          ,p_per_information6             in varchar2
10113          ,p_per_information7             in varchar2
10114          ,p_per_information8             in varchar2
10115          ,p_per_information9             in varchar2
10116          ,p_per_information10            in varchar2
10117          ,p_per_information11            in varchar2
10118          ,p_per_information12            in varchar2
10119          ,p_per_information13            in varchar2
10120          ,p_per_information14            in varchar2
10121          ,p_per_information15            in varchar2
10122          ,p_per_information16            in varchar2
10123          ,p_per_information17            in varchar2
10124          ,p_per_information18            in varchar2
10125          ,p_per_information19            in varchar2
10126          ,p_per_information20            in varchar2
10127          ,p_per_information21            in varchar2
10128          ,p_per_information22            in varchar2
10129          ,p_per_information23            in varchar2
10130          ,p_per_information24            in varchar2
10131          ,p_per_information25            in varchar2
10132          ,p_per_information26            in varchar2
10133          ,p_per_information27            in varchar2
10134          ,p_per_information28            in varchar2
10135          ,p_per_information29            in varchar2
10136          ,p_per_information30            in varchar2
10137          -- Assignment DF Information
10138          ,p_ass_attribute_category       in varchar2
10139          ,p_ass_attribute1               in varchar2
10140          ,p_ass_attribute2               in varchar2
10141          ,p_ass_attribute3               in varchar2
10142          ,p_ass_attribute4               in varchar2
10143          ,p_ass_attribute5               in varchar2
10144          ,p_ass_attribute6               in varchar2
10145          ,p_ass_attribute7               in varchar2
10146          ,p_ass_attribute8               in varchar2
10147          ,p_ass_attribute9               in varchar2
10148          ,p_ass_attribute10              in varchar2
10149          ,p_ass_attribute11              in varchar2
10150          ,p_ass_attribute12              in varchar2
10151          ,p_ass_attribute13              in varchar2
10152          ,p_ass_attribute14              in varchar2
10153          ,p_ass_attribute15              in varchar2
10154          ,p_ass_attribute16              in varchar2
10155          ,p_ass_attribute17              in varchar2
10156          ,p_ass_attribute18              in varchar2
10157          ,p_ass_attribute19              in varchar2
10158          ,p_ass_attribute20              in varchar2
10159          ,p_ass_attribute21              in varchar2
10160          ,p_ass_attribute22              in varchar2
10161          ,p_ass_attribute23              in varchar2
10162          ,p_ass_attribute24              in varchar2
10163          ,p_ass_attribute25              in varchar2
10164          ,p_ass_attribute26              in varchar2
10165          ,p_ass_attribute27              in varchar2
10166          ,p_ass_attribute28              in varchar2
10167          ,p_ass_attribute29              in varchar2
10168          ,p_ass_attribute30              in varchar2
10169          -- Address Df Information
10170          ,p_adr_attribute_category       in varchar2
10171          ,p_adr_attribute1               in varchar2
10172          ,p_adr_attribute2               in varchar2
10173          ,p_adr_attribute3               in varchar2
10174          ,p_adr_attribute4               in varchar2
10175          ,p_adr_attribute5               in varchar2
10176          ,p_adr_attribute6               in varchar2
10177          ,p_adr_attribute7               in varchar2
10178          ,p_adr_attribute8               in varchar2
10179          ,p_adr_attribute9               in varchar2
10180          ,p_adr_attribute10              in varchar2
10181          ,p_adr_attribute11              in varchar2
10182          ,p_adr_attribute12              in varchar2
10183          ,p_adr_attribute13              in varchar2
10184          ,p_adr_attribute14              in varchar2
10185          ,p_adr_attribute15              in varchar2
10186          ,p_adr_attribute16              in varchar2
10187          ,p_adr_attribute17              in varchar2
10188          ,p_adr_attribute18              in varchar2
10189          ,p_adr_attribute19              in varchar2
10190          ,p_adr_attribute20              in varchar2
10191 
10192          ,p_business_group_id            in number
10193          ,p_data_pump_flag               in varchar2
10194          ,p_add_information13            in varchar2
10195          ,p_add_information14            in varchar2
10196          ,p_add_information15            in varchar2
10197          ,p_add_information16            in varchar2
10198          ,p_add_information17            in varchar2
10199          ,p_add_information18            in varchar2
10200          ,p_add_information19            in varchar2
10201          ,p_add_information20            in varchar2
10202          -- People Group KFF
10203          ,p_concat_segments              in varchar2
10204          ,p_people_segment1              in varchar2
10205          ,p_people_segment2              in varchar2
10206          ,p_people_segment3              in varchar2
10207          ,p_people_segment4              in varchar2
10208          ,p_people_segment5              in varchar2
10209          ,p_people_segment6              in varchar2
10210          ,p_people_segment7              in varchar2
10211          ,p_people_segment8              in varchar2
10212          ,p_people_segment9              in varchar2
10213          ,p_people_segment10             in varchar2
10214          ,p_people_segment11             in varchar2
10215          ,p_people_segment12             in varchar2
10216          ,p_people_segment13             in varchar2
10217          ,p_people_segment14             in varchar2
10218          ,p_people_segment15             in varchar2
10219          ,p_people_segment16             in varchar2
10220          ,p_people_segment17             in varchar2
10221          ,p_people_segment18             in varchar2
10222          ,p_people_segment19             in varchar2
10223          ,p_people_segment20             in varchar2
10224          ,p_people_segment21             in varchar2
10225          ,p_people_segment22             in varchar2
10226          ,p_people_segment23             in varchar2
10227          ,p_people_segment24             in varchar2
10228          ,p_people_segment25             in varchar2
10229          ,p_people_segment26             in varchar2
10230          ,p_people_segment27             in varchar2
10231          ,p_people_segment28             in varchar2
10232          ,p_people_segment29             in varchar2
10233          ,p_people_segment30             in varchar2
10234          -- Soft Coding KFF
10235          ,p_soft_segments                in varchar2
10236          ,p_soft_segment1                in varchar2
10237          ,p_soft_segment2                in varchar2
10238          ,p_soft_segment3                in varchar2
10239          ,p_soft_segment4                in varchar2
10240          ,p_soft_segment5                in varchar2
10241          ,p_soft_segment6                in varchar2
10242          ,p_soft_segment7                in varchar2
10243          ,p_soft_segment8                in varchar2
10244          ,p_soft_segment9                in varchar2
10245          ,p_soft_segment10               in varchar2
10246          ,p_soft_segment11               in varchar2
10247          ,p_soft_segment12               in varchar2
10248          ,p_soft_segment13               in varchar2
10249          ,p_soft_segment14               in varchar2
10250          ,p_soft_segment15               in varchar2
10251          ,p_soft_segment16               in varchar2
10252          ,p_soft_segment17               in varchar2
10253          ,p_soft_segment18               in varchar2
10254          ,p_soft_segment19               in varchar2
10255          ,p_soft_segment20               in varchar2
10256          ,p_soft_segment21               in varchar2
10257          ,p_soft_segment22               in varchar2
10258          ,p_soft_segment23               in varchar2
10259          ,p_soft_segment24               in varchar2
10260          ,p_soft_segment25               in varchar2
10261          ,p_soft_segment26               in varchar2
10262          ,p_soft_segment27               in varchar2
10263          ,p_soft_segment28               in varchar2
10264          ,p_soft_segment29               in varchar2
10265          ,p_soft_segment30               in varchar2
10266 
10267          ,p_business_group_name          in varchar2
10268          ,p_batch_id                     in number
10269          ,p_data_pump_batch_line_id      in varchar2
10270          ,p_per_comments                 in varchar2
10271          ,p_date_employee_data_verified  in date
10272          ,p_expense_check_send_to_addres in varchar2
10273          ,p_previous_last_name           in varchar2
10274          ,p_registered_disabled_flag     in varchar2
10275          ,p_vendor_id                    in number
10276          ,p_date_of_death                in date
10277          ,p_background_check_status      in varchar2
10278          ,p_background_date_check        in date
10279          ,p_blood_type                   in varchar2
10280          ,p_correspondence_language      in varchar2
10281          ,p_fast_path_employee           in varchar2
10282          ,p_fte_capacity                 in number
10283          ,p_honors                       in varchar2
10284          ,p_last_medical_test_by         in varchar2
10285          ,p_last_medical_test_date       in date
10286          ,p_mailstop                     in varchar2
10287          ,p_office_number                in varchar2
10288          ,p_on_military_service          in varchar2
10289          ,p_pre_name_adjunct             in varchar2
10290          ,p_projected_start_date         in date
10291          ,p_resume_exists                in varchar2
10292          ,p_resume_last_updated          in date
10293          ,p_second_passport_exists       in varchar2
10294          ,p_student_status               in varchar2
10295          ,p_work_schedule                in varchar2
10296          ,p_benefit_group_id             in number
10297          ,p_receipt_of_death_cert_date   in date
10298          ,p_coord_ben_med_pln_no         in varchar2
10299          ,p_coord_ben_no_cvg_flag        in varchar2
10300          ,p_coord_ben_med_ext_er         in varchar2
10301          ,p_coord_ben_med_pl_name        in varchar2
10302          ,p_coord_ben_med_insr_crr_name  in varchar2
10303          ,p_coord_ben_med_insr_crr_ident in varchar2
10304          ,p_coord_ben_med_cvg_strt_dt    in date
10305          ,p_coord_ben_med_cvg_end_dt     in date
10306          ,p_uses_tobacco_flag            in varchar2
10307          ,p_dpdnt_adoption_date          in date
10308          ,p_dpdnt_vlntry_svce_flag       in varchar2
10309          ,p_original_date_of_hire        in date
10310          ,p_adjusted_svc_date            in date
10311          ,p_town_of_birth                in varchar2
10312          ,p_region_of_birth              in varchar2
10313          ,p_country_of_birth             in varchar2
10314          ,p_global_person_id             in varchar2
10315          ,p_party_id                     in number
10316          ,p_supervisor_id                in number
10317          ,p_assignment_number            in varchar2
10318          ,p_change_reason                in varchar2
10319          ,p_asg_comments                 in varchar2
10320          ,p_date_probation_end           in date
10321          ,p_default_code_comb_id         in number
10322          ,p_frequency                    in varchar2
10323          ,p_internal_address_line        in varchar2
10324          ,p_manager_flag                 in varchar2
10325          ,p_normal_hours                 in number
10326          ,p_perf_review_period           in number
10327          ,p_perf_review_period_frequency in varchar2
10328          ,p_probation_period             in number
10329          ,p_probation_unit               in varchar2
10330          ,p_sal_review_period            in number
10331          ,p_sal_review_period_frequency  in varchar2
10332          ,p_set_of_books_id              in number
10333          ,p_source_type                  in varchar2
10334          ,p_time_normal_finish           in varchar2
10335          ,p_time_normal_start            in varchar2
10336          ,p_bargaining_unit_code         in varchar2
10337          ,p_labour_union_member_flag     in varchar2
10338          ,p_hourly_salaried_code         in varchar2
10339          ,p_pradd_ovlapval_override      in varchar2
10340          ,p_address_type                 in varchar2
10341          ,p_adr_comments                 in varchar2
10342          ,p_batch_name                   in varchar2
10343          ,p_location_id                  in number
10344          ,p_student_number               in varchar2
10345          ,p_apl_assignment_id            in varchar2
10346          ,p_applicant_number             in varchar2
10347          ,p_cwk_number                   in varchar2
10348          ,p_interface_code               in varchar2
10349 --$ Update Batch
10350          ,p_batch_link                   in number
10351 --$ Get the mode ("Create and Update", "Update Only" or "View Only" )
10352          ,p_crt_upd                      in varchar2
10353          ,p_assignment_id                in number
10354           ) as
10355   --
10356   -- Dynamic Ref Cursor
10357   --
10358   csr_get_party_id         ref_cur_typ;
10359   --
10360   -- Record types
10361   --
10362   l_emp_api_out            t_hrEmpApi;
10363   l_asg_crit_out           t_AsgUpdCrit_Api;
10364   l_updper_api_out         t_UpdEmp_Api;
10365   l_crt_emp_api_out        t_CreateContact_Api;
10366   l_HireToJobapi_out       t_HrToJob_Api;
10367   l_HireAppapi_out         t_HrApp_Api;
10368   --
10369   -- Type declarations
10370   --
10371   l_chk_per                chk_party%rowtype;
10372   l_national_identifier    per_people_f.national_identifier%type;
10373   l_party_id               per_people_f.party_id%type;
10374   l_dff_ctx                fnd_descr_flex_contexts.descriptive_flex_context_code%type;
10375 
10376   -- added by dbansal
10377    l_gre_name  HR_ALL_ORGANIZATION_UNITS_TL.name%type;
10378    temp varchar2(20);
10379   --
10380   -- Date variables
10381   --
10382   l_effective_date         date;
10383   --
10384   -- Number Variables
10385   --
10386   l_dup_asg_id             number(15);
10387   --
10388   -- String variables
10389   --
10390   l_ni_exists              varchar2(10);
10391   l_pp_error_code          varchar2(50);
10392   l_visa_error_code        varchar2(50);
10393   l_visit_error_code       varchar2(50);
10394   l_oss_error_code         varchar2(50);
10395   l_party_number           varchar2(100);
10396   l_dyn_sql_qry            varchar2(500);
10397   l_sql_qry                varchar2(500);
10398   l_error_message          varchar2(2000);
10399   --
10400   -- Boolean variables
10401   --
10402   l_ossDtls_warning        boolean;
10403   l_active_cwk             boolean;
10404   l_visit_warning          boolean;
10405   l_visa_warning           boolean;
10406   l_passport_warning       boolean;
10407   --
10408   -- Constants
10409   --
10410   l_apl_assignment_id      number;
10411   l_person_id              number;
10412   l_proc_name  constant    varchar2(150):= g_pkg ||'InsUpd_PerAsgAdd_Rec';
10413   id_flex_num              number(20);
10414 
10415   MSGDATA       varchar2(32000);
10416   MSGNAME       varchar2(30);
10417   MSGAPP        varchar2(50);
10418   MSGENCODED    varchar2(32100);
10419   MSGENCODEDLEN number(6);
10420   MSGNAMELOC    number(6);
10421   MSGTEXTLOC    number(6);
10422 
10423   l_migration_allowed      varchar2(1);
10424   l_crt_upd                varchar2(1);
10425 
10426 begin
10427 
10428   savepoint InsUpd_PerAsgAdd_Rec;
10429   g_debug := hr_utility.debug_enabled;
10430   hr_utility.set_location('Entering: ' || l_proc_name, 5);
10431 
10432   l_migration_allowed := SUBSTR(p_crt_upd,3,1);
10433   g_migration_flag := l_migration_allowed;
10434   l_crt_upd := SUBSTR(p_crt_upd,1,1);
10435   hr_utility.trace('l_crt_upd ='||l_crt_upd);
10436 
10437   if (l_crt_upd is not null) then
10438   g_crt_upd      := l_crt_upd;
10439   end if;
10440 
10441   if (g_crt_upd = 'D') then
10442   raise e_upl_not_allowed;
10443   end if;
10444 
10445   --
10446   -- Initialize the Person, Assignment, Address, Phones,
10447   -- People Group KFF and Assignment Soft Coding KFF records.
10448   --
10449 
10450 
10451  --hr_utility.trace_on(null,'TTT');
10452  --hr_utility.trace('employee_category='||p_employee_category);
10453  --hr_utility.trace('p_address_style = ' ||p_address_style);
10454  --hr_utility.trace('P_PRIMARY_FLAG = ' ||P_PRIMARY_FLAG);
10455  --hr_utility.trace('P_ADDRESS_DATE_FROM = ' ||P_ADDRESS_DATE_FROM);
10456 
10457 --hr_utility.trace('p_data_pump_flag .....'        || p_data_pump_flag);
10458 --hr_utility.trace('p_batch_id .....'        || p_batch_id);
10459  --hr_utility.trace('p_user_person_type = ' ||p_user_person_type);
10460  --hr_utility.trace('p_employee_number = ' ||p_employee_number);
10461  --hr_utility.trace('p_assign_organization = ' ||p_assign_organization);
10462  --hr_utility.trace('p_apl_assignment_id = ' ||p_apl_assignment_id);
10463  --hr_utility.trace('p_status = ' ||p_status);
10464  --hr_utility.trace('p_assignment_no = ' ||p_assignment_number);
10465  --hr_utility.trace('p_business_group_id = ' ||p_business_group_id);
10466  --hr_utility.trace('p_interface_code = ' ||p_interface_code);
10467  --hr_utility.trace('p_gre = ' ||p_gre);
10468  --hr_utility.trace('ass_attribute1 = ' ||p_ass_attribute1);
10469  --hr_utility.trace('ass_attribute2 = ' ||p_ass_attribute2);
10470  --hr_utility.trace('ass_attribute3 = ' ||p_ass_attribute3);
10471  --hr_utility.trace('ass_attribute4 = ' ||p_ass_attribute4);
10472  --hr_utility.trace('ass_attribute5 = ' ||p_ass_attribute5);
10473  --hr_utility.trace('ass_attribute6 = ' ||p_ass_attribute6);
10474  --hr_utility.trace('ass_attribute7 = ' ||p_ass_attribute7);
10475  --hr_utility.trace('ass_attribute8 = ' ||p_ass_attribute8);
10476  --hr_utility.trace('ass_attribute9 = ' ||p_ass_attribute9);
10477  --hr_utility.trace('ass_attribute10 = ' ||p_ass_attribute10);
10478  --hr_utility.trace('ass_attribute11 = ' ||p_ass_attribute11);
10479  --hr_utility.trace('ass_attribute12 = ' ||p_ass_attribute12);
10480  --hr_utility.trace('ass_attribute13 = ' ||p_ass_attribute13);
10481  --hr_utility.trace('ass_attribute14 = ' ||p_ass_attribute14);
10482  --hr_utility.trace('ass_attribute15 = ' ||p_ass_attribute15);
10483 
10484  --hr_utility.trace('p_soft_segments = ' ||p_soft_segments);
10485  --hr_utility.trace('p_soft_segment1 = ' ||p_soft_segment1);
10486  --hr_utility.trace('p_soft_segment2 = ' ||p_soft_segment2);
10487 
10488  --hr_utility.trace('Person Type = ' ||p_interface_code);
10489 
10490   --hr_utility.trace(' Person id = ' ||P_DUP_PERSON_ID);
10491   --hr_utility.trace(' Party id = ' ||P_DUP_PARTY_ID);
10492 
10493   --hr_utility.trace(' p_adr_attribute1 = ' ||p_adr_attribute1);
10494   --hr_utility.trace(' p_adr_attribute2 = ' ||p_adr_attribute2);
10495   --hr_utility.trace(' p_adr_attribute3 = ' ||p_adr_attribute3);
10496   --hr_utility.trace(' p_adr_attribute_category = ' ||p_adr_attribute_category);
10497   --hr_utility.trace(' p_add_information16 = ' ||p_add_information16);
10498 
10499   --hr_utility.trace(' P_INTERNAL_LOCATION = '||P_INTERNAL_LOCATION);
10500   --hr_utility.trace(' P_ADJUSTED_SVC_DATE = '||P_ADJUSTED_SVC_DATE);
10501   --hr_utility.trace(' P_COUNTRY_OF_BIRTH = '||P_COUNTRY_OF_BIRTH);
10502 
10503   hr_utility.set_location(' Initializing records ', 5);
10504   g_per_rec    := null;   g_grp_rec    := null;
10505   g_scl_rec    := null;   g_asg_rec    := null;
10506   g_add_rec    := null;   g_phn_rec    := null;
10507   g_interface_code := nvl(p_interface_code,'PQP_FLEXIBLE_WEBADI_INTF');
10508   --
10509   -- Set the effective date as the Hire/Re-hire or effective passed for
10510   -- date the person which will be used for Assignment  also.
10511   --
10512   l_effective_date := p_date_of_hire;
10513   l_dup_asg_id     := 0;
10514   l_party_number   := p_student_number;
10515 
10516   --
10517   -- Get business group id in a pkg global variable
10518   --
10519   open  csr_bg_code (p_business_group_id);
10520   fetch csr_bg_code into g_leg_code
10521                         ,g_emp_num_gen
10522                         ,g_apl_num_gen
10523                         ,g_cwk_num_gen
10524                         ,g_business_group_id;
10525   close csr_bg_code;
10526 
10527   if g_debug then
10528    hr_utility.set_location(' l_effective_date: '||l_effective_date, 10);
10529    hr_utility.set_location(' g_leg_code      : '||g_leg_code, 10);
10530    hr_utility.set_location(' g_emp_num_gen   : '||g_emp_num_gen, 10);
10531    hr_utility.set_location(' l_party_number  : '||l_party_number, 10);
10532    hr_utility.set_location(' p_business_group_id  : '||p_business_group_id, 10);
10533    hr_utility.set_location(' p_interface_code  : '||p_interface_code, 10);
10534 
10535   end if;
10536   --
10537   -- Get the Un-Masked National Indentifier
10538   --
10539   l_national_identifier :=
10540    Get_UnMasked_NI
10541   (p_national_identifier     => p_national_identifier
10542   ,p_batch_id                => p_batch_id
10543   ,p_data_pump_batch_line_id => p_data_pump_batch_line_id
10544   ,p_web_adi_identifier      => p_web_adi_identifier
10545    );
10546   --
10547   -- Get Party Id corresponding to Party Number is entered
10548   --
10549    hr_utility.set_location('l_party_number '|| l_party_number, 30);
10550   if (l_party_number is not null) then
10551       hr_utility.set_location(' Party number is not null ', 30);
10552       l_sql_qry := 'select party_id
10553                       from hz_parties
10554                      where party_number ='||l_party_number;
10555       open  csr_get_party_id for l_sql_qry;
10556       fetch csr_get_party_id into l_party_id;
10557       close csr_get_party_id;
10558   end if;
10559 
10560   hr_utility.set_location('l_party_id '|| l_party_id, 50);
10561   hr_utility.set_location('Start of filling person rec ', 50);
10562 
10563   -- ===========================================================================
10564   -- ~ Person Details
10565   -- ===========================================================================
10566   g_per_rec.national_identifier         := l_national_identifier;
10567   g_per_rec.party_id                    := l_party_id;
10568 
10569   g_per_rec.business_group_id           := p_business_group_id;
10570   g_per_rec.last_name                   := p_last_name;
10571   g_per_rec.middle_names                := p_middle_name;
10572   g_per_rec.first_name                  := p_first_name;
10573   g_per_rec.suffix                      := p_suffix;
10574   g_per_rec.pre_name_adjunct            := p_prefix; -- p_pre_name_adjunct ?
10575 
10576   g_per_rec.title                       := p_title;
10577   g_per_rec.email_address               := p_email_address;
10578   g_per_rec.known_as                    := p_preferred_name;
10579   g_per_rec.marital_status              := p_marital_status;
10580   g_per_rec.sex                         := p_sex;
10581   g_per_rec.nationality                 := p_nationality;
10582   g_per_rec.date_of_birth               := trunc(p_date_of_birth);
10583   g_per_rec.start_date                  := trunc(p_date_of_hire);
10584 
10585   --Added by Dbansal
10586   g_per_comments := p_per_comments;
10587   --
10588   -- Set the Emp, Appl or CWK number based on the bus.group setup
10589   --
10590   EmpAplCwk_NumGen
10591  (p_employee_number  => p_employee_number
10592  ,p_applicant_number => p_applicant_number
10593  ,p_cwk_number       => p_cwk_number
10594   );
10595   g_per_rec.person_type_id              := p_user_person_type;
10596   g_per_rec.date_employee_data_verified := p_date_employee_data_verified;
10597   g_per_rec.expense_check_send_to_address := p_expense_check_send_to_addres;
10598   g_per_rec.previous_last_name          := p_previous_last_name;
10599   g_per_rec.registered_disabled_flag    := p_registered_disabled_flag;
10600   g_per_rec.vendor_id                   := p_vendor_id;
10601   g_per_rec.date_of_death               := trunc(p_date_of_death);
10602   g_per_rec.background_check_status     := p_background_check_status;
10603   g_per_rec.background_date_check       := p_background_date_check;
10604   g_per_rec.blood_type                  := p_blood_type;
10605   g_per_rec.correspondence_language     := p_correspondence_language;
10606   g_per_rec.fast_path_employee          := p_fast_path_employee;
10607   g_per_rec.fte_capacity                := p_fte_capacity;
10608   g_per_rec.honors                      := p_honors;
10609   g_per_rec.last_medical_test_by        := p_last_medical_test_by;
10610   g_per_rec.last_medical_test_date      := p_last_medical_test_date;
10611   g_per_rec.mailstop                    := p_mailstop;
10612   g_per_rec.office_number               := p_office_number;
10613 
10614   g_per_rec.projected_start_date        := trunc(p_projected_start_date);
10615   g_per_rec.resume_last_updated         := p_resume_last_updated;
10616   g_per_rec.student_status              := p_student_status;
10617   g_per_rec.work_schedule               := p_work_schedule;
10618   g_per_rec.benefit_group_id            := p_benefit_group_id;
10619   g_per_rec.receipt_of_death_cert_date  := trunc(p_receipt_of_death_cert_date);
10620   g_per_rec.coord_ben_med_pln_no        := p_coord_ben_med_pln_no;
10621 
10622   g_per_rec.coord_ben_med_ext_er        := p_coord_ben_med_ext_er;
10623   g_per_rec.coord_ben_med_pl_name       := p_coord_ben_med_pl_name;
10624   g_per_rec.coord_ben_med_insr_crr_name := p_coord_ben_med_insr_crr_name;
10625   g_per_rec.coord_ben_med_insr_crr_ident:= p_coord_ben_med_insr_crr_ident;
10626   g_per_rec.coord_ben_med_cvg_strt_dt   := p_coord_ben_med_cvg_strt_dt;
10627   g_per_rec.coord_ben_med_cvg_end_dt    := p_coord_ben_med_cvg_end_dt;
10628   g_per_rec.uses_tobacco_flag           := p_uses_tobacco_flag;
10629   g_per_rec.dpdnt_adoption_date         := trunc(p_dpdnt_adoption_date);
10630 
10631   g_per_rec.original_date_of_hire       := trunc(p_original_date_of_hire);
10632   g_per_rec.town_of_birth               := p_town_of_birth;
10633   g_per_rec.region_of_birth             := p_region_of_birth;
10634   g_per_rec.country_of_birth            := p_country_of_birth;
10635   g_per_rec.global_person_id            := p_global_person_id;
10636   g_per_rec.dpdnt_vlntry_svce_flag      := nvl(p_dpdnt_vlntry_svce_flag,'N');
10637   g_per_rec.coord_ben_no_cvg_flag       := nvl(p_coord_ben_no_cvg_flag,'N');
10638   g_per_rec.second_passport_exists      := nvl(p_second_passport_exists,'N');
10639   g_per_rec.resume_exists               := nvl(p_resume_exists,'N');
10640   g_per_rec.on_military_service         := nvl(p_on_military_service,'N');
10641   g_per_rec.internal_location           := P_INTERNAL_LOCATION; -- Added by pkagrawa
10642 
10643 
10644   hr_utility.set_location('Person Details assigned to record : g_per_rec ',
10645                                                                  60);
10646   -- ===========================================================================
10647   -- Person DF: Customer defined
10648   -- ===========================================================================
10649 
10650       --$
10651        temp := 'p_per_attribute';
10652 
10653   if p_per_attribute_category is null then
10654        for i in 1..30 loop
10655          if (temp||to_char(i)) is null then
10656          --hr_utility.trace('Check PER_ATT NULL'||(temp||to_char(i)));
10657           null;
10658          else
10659        g_per_rec.attribute_category := 'Global Data Elements';
10660        --hr_utility.trace('Check PER_ATT_CAT NULL - Global Val'||p_per_attribute_category);
10661             exit;
10662          end if;
10663         end loop;
10664   end if;
10665 
10666   if p_per_attribute_category is not null or
10667   g_per_rec.attribute_category = 'Global Data Elements' then
10668 
10669      if( p_per_attribute_category is not null ) then
10670      g_per_rec.attribute_category := p_per_attribute_category;
10671      end if;
10672 
10673      g_per_rec.attribute1         := p_per_attribute1;
10674      g_per_rec.attribute2         := p_per_attribute2;
10675      g_per_rec.attribute3         := p_per_attribute3;
10676      g_per_rec.attribute4         := p_per_attribute4;
10677      g_per_rec.attribute5         := p_per_attribute5;
10678      g_per_rec.attribute6         := p_per_attribute6;
10679      g_per_rec.attribute7         := p_per_attribute7;
10680      g_per_rec.attribute8         := p_per_attribute8;
10681      g_per_rec.attribute9         := p_per_attribute9;
10682      g_per_rec.attribute10        := p_per_attribute10;
10683      g_per_rec.attribute11        := p_per_attribute11;
10684      g_per_rec.attribute12        := p_per_attribute12;
10685      g_per_rec.attribute13        := p_per_attribute13;
10686      g_per_rec.attribute14        := p_per_attribute14;
10687      g_per_rec.attribute15        := p_per_attribute15;
10688      g_per_rec.attribute16        := p_per_attribute16;
10689      g_per_rec.attribute17        := p_per_attribute17;
10690      g_per_rec.attribute18        := p_per_attribute18;
10691      g_per_rec.attribute19        := p_per_attribute19;
10692      g_per_rec.attribute20        := p_per_attribute20;
10693      g_per_rec.attribute21        := p_per_attribute21;
10694      g_per_rec.attribute22        := p_per_attribute22;
10695      g_per_rec.attribute23        := p_per_attribute23;
10696      g_per_rec.attribute24        := p_per_attribute24;
10697      g_per_rec.attribute25        := p_per_attribute25;
10698      g_per_rec.attribute26        := p_per_attribute26;
10699      g_per_rec.attribute27        := p_per_attribute27;
10700      g_per_rec.attribute28        := p_per_attribute28;
10701      g_per_rec.attribute29        := p_per_attribute29;
10702      g_per_rec.attribute30        := p_per_attribute30;
10703   end if;
10704   hr_utility.set_location('Person DF assigned to record :g_per_rec ', 70);
10705 
10706   -- ===========================================================================
10707   -- Person DDF: Different for each legislation
10708   -- ===========================================================================
10709   open  csr_style (c_context_code => g_leg_code);
10710   fetch csr_style into l_dff_ctx;
10711   if csr_style%found then
10712      g_per_rec.per_information_category  :=
10713                nvl(p_per_information_category, g_leg_code);
10714      g_per_rec.per_information1   := p_per_information1;
10715      g_per_rec.per_information2   := p_per_information2;
10716      g_per_rec.per_information3   := p_per_information3;
10717      g_per_rec.per_information4   := p_per_information4;
10718      g_per_rec.per_information5   := p_per_information5;
10719      g_per_rec.per_information6   := p_per_information6;
10720      g_per_rec.per_information7   := p_per_information7;
10721      g_per_rec.per_information8   := p_per_information8;
10722      g_per_rec.per_information9   := p_per_information9;
10723      g_per_rec.per_information10  := p_per_information10;
10724      g_per_rec.per_information11  := p_per_information11;
10725      g_per_rec.per_information12  := p_per_information12;
10726      g_per_rec.per_information13  := p_per_information13;
10727      g_per_rec.per_information14  := p_per_information14;
10728      g_per_rec.per_information15  := p_per_information15;
10729      g_per_rec.per_information16  := p_per_information16;
10730      g_per_rec.per_information17  := p_per_information17;
10731      g_per_rec.per_information18  := p_per_information18;
10732      g_per_rec.per_information19  := p_per_information19;
10733      g_per_rec.per_information20  := p_per_information20;
10734      g_per_rec.per_information21  := p_per_information21;
10735      g_per_rec.per_information22  := p_per_information22;
10736      g_per_rec.per_information23  := p_per_information23;
10737      g_per_rec.per_information24  := p_per_information24;
10738      g_per_rec.per_information25  := p_per_information25;
10739      g_per_rec.per_information26  := p_per_information26;
10740      g_per_rec.per_information27  := p_per_information27;
10741      g_per_rec.per_information28  := p_per_information28;
10742      g_per_rec.per_information29  := p_per_information29;
10743      g_per_rec.per_information30  := p_per_information30;
10744 
10745   end if;
10746   close csr_style;
10747 
10748   hr_utility.set_location('Person DDF assigned to record : '||
10749                               p_per_information_category, 80);
10750 
10751   -- ===========================================================================
10752   -- ~ Person Address Record
10753   -- ===========================================================================
10754   if (p_address_style is not null and
10755       p_primary_flag  is not null and
10756       p_address_line1 is not null) then
10757 
10758      g_add_rec.party_id            := l_party_id;
10759      g_add_rec.business_group_id   := p_business_group_id;
10760      g_add_rec.address_type        := p_address_type;
10761      g_add_rec.comments            := p_adr_comments;
10762      g_add_rec.primary_flag        := p_primary_flag;
10763      g_add_rec.style               := p_address_style;
10764      g_add_rec.address_line1       := p_address_line1;
10765      g_add_rec.address_line2       := p_address_line2;
10766      g_add_rec.address_line3       := p_address_line3;
10767      g_add_rec.region_1            := p_region1;
10768      g_add_rec.region_2            := p_region2;
10769      g_add_rec.region_3            := p_region3;
10770      g_add_rec.town_or_city        := p_town_or_city;
10771      g_add_rec.country             := p_country;
10772      g_add_rec.postal_code         := p_postal_code;
10773      g_add_rec.telephone_number_1  := p_telephone_no1;
10774      g_add_rec.telephone_number_2  := p_telephone_no2;
10775      g_add_rec.telephone_number_3  := p_telephone_no3;
10776      g_add_rec.date_from           := p_address_date_from;
10777      g_add_rec.date_to             := p_address_date_to;
10778      g_add_rec.add_information13   := p_add_information13;
10779      g_add_rec.add_information14   := p_add_information14;
10780      g_add_rec.add_information15   := p_add_information15;
10781      g_add_rec.add_information16   := p_add_information16;
10782      g_add_rec.add_information17   := p_add_information17;
10783      g_add_rec.add_information18   := p_add_information18;
10784      g_add_rec.add_information19   := p_add_information19;
10785      g_add_rec.add_information20   := p_add_information20;
10786 
10787   end if;
10788 
10789   hr_utility.set_location('Address Style: '||p_address_style, 90);
10790 
10791   -- ===========================================================================
10792   -- Address DF: Customer defined DF
10793   -- ===========================================================================
10794 
10795    --$
10796      temp := 'p_adr_attribute';
10797 
10798   if p_adr_attribute_category is null then
10799        for i in 1..20 loop
10800          if (temp||to_char(i)) is null then
10801          --hr_utility.trace('Check ADDR_ATT NULL'||(temp||to_char(i)));
10802           null;
10803          else
10804        g_add_rec.addr_attribute_category := 'Global Data Elements';
10805        --hr_utility.trace('Check ADDR_ATT_CAT NULL - Global Val'||p_adr_attribute_category);
10806             exit;
10807          end if;
10808         end loop;
10809   end if;
10810 
10811   if p_adr_attribute_category is not null or
10812   g_add_rec.addr_attribute_category = 'Global Data Elements' then
10813 
10814      if( p_adr_attribute_category is not null ) then
10815      g_add_rec.addr_attribute_category := p_adr_attribute_category;
10816      end if;
10817 
10818      g_add_rec.addr_attribute1         := p_adr_attribute1;
10819      g_add_rec.addr_attribute2         := p_adr_attribute2;
10820      g_add_rec.addr_attribute3         := p_adr_attribute3;
10821      g_add_rec.addr_attribute4         := p_adr_attribute4;
10822      g_add_rec.addr_attribute5         := p_adr_attribute5;
10823      g_add_rec.addr_attribute6         := p_adr_attribute6;
10824      g_add_rec.addr_attribute7         := p_adr_attribute7;
10825      g_add_rec.addr_attribute8         := p_adr_attribute8;
10826      g_add_rec.addr_attribute9         := p_adr_attribute9;
10827      g_add_rec.addr_attribute10        := p_adr_attribute10;
10828      g_add_rec.addr_attribute11        := p_adr_attribute11;
10829      g_add_rec.addr_attribute12        := p_adr_attribute12;
10830      g_add_rec.addr_attribute13        := p_adr_attribute13;
10831      g_add_rec.addr_attribute14        := p_adr_attribute14;
10832      g_add_rec.addr_attribute15        := p_adr_attribute15;
10833      g_add_rec.addr_attribute16        := p_adr_attribute16;
10834      g_add_rec.addr_attribute17        := p_adr_attribute17;
10835      g_add_rec.addr_attribute18        := p_adr_attribute18;
10836      g_add_rec.addr_attribute19        := p_adr_attribute19;
10837      g_add_rec.addr_attribute20        := p_adr_attribute20;
10838 
10839   end if;
10840 
10841   hr_utility.set_location('Address DF category: '||p_adr_attribute_category, 100);
10842 
10843   -- ===========================================================================
10844   -- ~ Person Primary Assignment
10845   -- ===========================================================================
10846   g_asg_rec.assignment_id                 := p_assignment_id;
10847   g_asg_rec.business_group_id             := p_business_group_id;
10848   g_asg_rec.organization_id               := p_assign_organization;
10849   g_asg_rec.job_id                        := p_job;
10850   g_asg_rec.grade_id                      := p_grade;
10851   g_asg_rec.people_group_id               := p_assign_group;
10852   g_asg_rec.position_id                   := p_position;
10853   g_asg_rec.payroll_id                    := p_payroll;
10854   g_asg_rec.pay_basis_id                  := p_salary_basis;
10855   g_asg_rec.assignment_status_type_id     := p_status;
10856   g_asg_rec.assignment_number             := p_assignment_no;
10857   g_asg_rec.effective_start_date          := p_assign_eff_dt_from;
10858   g_asg_rec.effective_end_date            := p_assign_eff_dt_to;
10859 
10860   g_asg_rec.assignment_category           := p_assignment_category;
10861   g_asg_rec.collective_agreement_id       := p_collective_agreement;
10862   g_asg_rec.employee_category             := p_employee_category;
10863   g_asg_rec.supervisor_id                 := p_supervisor_id;
10864   g_asg_rec.assignment_number             := p_assignment_number;
10865   g_asg_rec.change_reason                 := p_change_reason;
10866   g_asg_rec.date_probation_end            := p_date_probation_end;
10867   g_asg_rec.default_code_comb_id          := p_default_code_comb_id;
10868   g_asg_rec.frequency                     := p_frequency;
10869   g_asg_rec.internal_address_line         := p_internal_address_line;
10870   g_asg_rec.manager_flag                  := p_manager_flag;
10871   g_asg_rec.normal_hours                  := p_normal_hours;
10872   g_asg_rec.perf_review_period            := p_perf_review_period;
10873   g_asg_rec.perf_review_period_frequency  := p_perf_review_period_frequency;
10874   g_asg_rec.probation_period              := p_probation_period;
10875   g_asg_rec.probation_unit                := p_probation_unit;
10876   g_asg_rec.sal_review_period             := p_sal_review_period;
10877   g_asg_rec.sal_review_period_frequency   := p_sal_review_period_frequency;
10878   g_asg_rec.set_of_books_id               := p_set_of_books_id;
10879   g_asg_rec.source_type                   := p_source_type;
10880   g_asg_rec.time_normal_finish            := p_time_normal_finish;
10881   g_asg_rec.time_normal_start             := p_time_normal_start;
10882   g_asg_rec.bargaining_unit_code          := p_bargaining_unit_code;
10883   g_asg_rec.labour_union_member_flag      := p_labour_union_member_flag;
10884   g_asg_rec.hourly_salaried_code          := p_hourly_salaried_code;
10885   g_asg_rec.location_id                   := p_location_id;
10886 
10887   --Added by Dbansal
10888   g_asg_comments   := p_asg_comments;
10889 
10890 
10891   --hr_utility.trace('LOCATION_ID = '||g_asg_rec.location_id);
10892   --hr_utility.trace('g_asg_rec.employee_category='||g_asg_rec.employee_category);
10893   --hr_utility.trace('g_asg_rec.assignment_category'||g_asg_rec.assignment_category);
10894   hr_utility.set_location('Primary Assignment details assigned to record', 110);
10895 
10896   -- ===========================================================================
10897   -- Additional Assignment Details
10898   -- ===========================================================================
10899 
10900   -- Added by Dbansal
10901   temp := 'p_ass_attribute';
10902 
10903   if p_ass_attribute_category is null then
10904        for i in 1..30 loop
10905          if (temp||to_char(i)) is null then
10906          --hr_utility.trace('Check ASS_ATT NULL'||(temp||to_char(i)));
10907           null;
10908          else
10909          g_asg_rec.ass_attribute_category := 'Global Data Elements';
10910        --hr_utility.trace('Check ASS_ATT_CAT NULL - Global Val'||p_ass_attribute_category);
10911             exit;
10912          end if;
10913         end loop;
10914   end if;
10915 
10916 
10917   if p_ass_attribute_category is not null or
10918   g_asg_rec.ass_attribute_category = 'Global Data Elements' then
10919 
10920      if( p_ass_attribute_category is not null ) then
10921       g_asg_rec.ass_attribute_category := p_ass_attribute_category;
10922      end if;
10923 
10924      g_asg_rec.ass_attribute1         := p_ass_attribute1;
10925      g_asg_rec.ass_attribute2         := p_ass_attribute2;
10926      g_asg_rec.ass_attribute3         := p_ass_attribute3;
10927      g_asg_rec.ass_attribute4         := p_ass_attribute4;
10928      g_asg_rec.ass_attribute5         := p_ass_attribute5;
10929      g_asg_rec.ass_attribute6         := p_ass_attribute6;
10930      g_asg_rec.ass_attribute7         := p_ass_attribute7;
10931      g_asg_rec.ass_attribute8         := p_ass_attribute8;
10932      g_asg_rec.ass_attribute9         := p_ass_attribute9;
10933      g_asg_rec.ass_attribute10        := p_ass_attribute10;
10934      g_asg_rec.ass_attribute11        := p_ass_attribute11;
10935      g_asg_rec.ass_attribute12        := p_ass_attribute12;
10936      g_asg_rec.ass_attribute13        := p_ass_attribute13;
10937      g_asg_rec.ass_attribute14        := p_ass_attribute14;
10938      g_asg_rec.ass_attribute15        := p_ass_attribute15;
10939      g_asg_rec.ass_attribute16        := p_ass_attribute16;
10940      g_asg_rec.ass_attribute17        := p_ass_attribute17;
10941      g_asg_rec.ass_attribute18        := p_ass_attribute18;
10942      g_asg_rec.ass_attribute19        := p_ass_attribute19;
10943      g_asg_rec.ass_attribute20        := p_ass_attribute20;
10944      g_asg_rec.ass_attribute21        := p_ass_attribute21;
10945      g_asg_rec.ass_attribute22        := p_ass_attribute22;
10946      g_asg_rec.ass_attribute23        := p_ass_attribute23;
10947      g_asg_rec.ass_attribute24        := p_ass_attribute24;
10948      g_asg_rec.ass_attribute25        := p_ass_attribute25;
10949      g_asg_rec.ass_attribute26        := p_ass_attribute26;
10950      g_asg_rec.ass_attribute27        := p_ass_attribute27;
10951      g_asg_rec.ass_attribute28        := p_ass_attribute28;
10952      g_asg_rec.ass_attribute29        := p_ass_attribute29;
10953      g_asg_rec.ass_attribute30        := p_ass_attribute30;
10954 
10955   end if;
10956 
10957   hr_utility.set_location('Assignment DF category: '||p_ass_attribute_category, 120);
10958 
10959   -- ===========================================================================
10960   -- ~ Contact Details
10961   -- ===========================================================================
10962 
10963   if p_contact_name is not null then
10964 
10965      g_cnt_rec.business_group_id    := p_business_group_id;
10966      g_cnt_rec.contact_type         := p_contact_type;
10967      g_cnt_rec.primary_contact_flag := p_primary_contact;
10968      g_cnt_rec.personal_flag        := p_personal_flag;
10969 
10970   end if;
10971   hr_utility.set_location('Contact details assigned to record ', 130);
10972 
10973   -- ===========================================================================
10974   -- ~ Person Phones
10975   -- ===========================================================================
10976 
10977   if p_phone_number is not null then
10978      g_phn_rec.party_id     := l_party_id;
10979      g_phn_rec.phone_type   := p_phone_type;
10980      g_phn_rec.phone_number := p_phone_number;
10981      g_phn_rec.date_from    := p_phone_date_from;
10982      g_phn_rec.date_to      := p_phone_date_to;
10983      g_phn_rec.parent_table := 'PER_ALL_PEOPLE_F';
10984   end if;
10985   hr_utility.set_location('Phone Details assigned to record ', 140);
10986 
10987   -- ===========================================================================
10988   -- ~ Soft Coding Keyflex field
10989   -- ===========================================================================
10990  --hr_utility.trace('p_soft_segments = ' ||p_soft_segments);
10991  --hr_utility.trace('p_soft_segment1 = ' ||p_soft_segment1);
10992  --hr_utility.trace('p_soft_segment2 = ' ||p_soft_segment2);
10993 
10994   g_scl_rec.concatenated_segments := p_soft_segments;
10995   g_scl_rec.segment1              := nvl(p_soft_segment1, p_gre);
10996   g_scl_rec.segment2              := p_soft_segment2;
10997   g_scl_rec.segment3              := p_soft_segment3;
10998   g_scl_rec.segment4              := p_soft_segment4;
10999   g_scl_rec.segment5              := p_soft_segment5;
11000   g_scl_rec.segment6              := p_soft_segment6;
11001   g_scl_rec.segment7              := p_soft_segment7;
11002   g_scl_rec.segment8              := p_soft_segment8;
11003   g_scl_rec.segment9              := p_soft_segment9;
11004   g_scl_rec.segment10             := p_soft_segment10;
11005   g_scl_rec.segment11             := p_soft_segment11;
11006   g_scl_rec.segment12             := p_soft_segment12;
11007   g_scl_rec.segment13             := p_soft_segment13;
11008   g_scl_rec.segment14             := p_soft_segment14;
11009   g_scl_rec.segment15             := p_soft_segment15;
11010   g_scl_rec.segment16             := p_soft_segment16;
11011   g_scl_rec.segment17             := p_soft_segment17;
11012   g_scl_rec.segment18             := p_soft_segment18;
11013   g_scl_rec.segment19             := p_soft_segment19;
11014   g_scl_rec.segment20             := p_soft_segment20;
11015   g_scl_rec.segment21             := p_soft_segment21;
11016   g_scl_rec.segment22             := p_soft_segment22;
11017   g_scl_rec.segment23             := p_soft_segment23;
11018   g_scl_rec.segment24             := p_soft_segment24;
11019   g_scl_rec.segment25             := p_soft_segment25;
11020   g_scl_rec.segment26             := p_soft_segment26;
11021   g_scl_rec.segment27             := p_soft_segment27;
11022   g_scl_rec.segment28             := p_soft_segment28;
11023   g_scl_rec.segment29             := p_soft_segment29;
11024   g_scl_rec.segment30             := p_soft_segment30;
11025 
11026   --Added by psengupt
11027   --If for the selected business Group Soft coded Flexfield is not defined
11028   --and still the user has entered the values then we have to set
11029   --the values to null so that the api does not throw an error.
11030   Begin
11031       select plr.rule_mode        into             id_flex_num
11032         from   pay_legislation_rules               plr,
11033                per_business_groups_perf            pgr
11034         where  plr.legislation_code                = pgr.legislation_code
11035         and    pgr.business_group_id               = p_business_group_id
11036         and    plr.rule_type                       = 'S'
11037         and    exists
11038               (select 1
11039                from   fnd_segment_attribute_values fsav
11040                where  to_char(fsav.id_flex_num)    = plr.rule_mode
11041                and    fsav.application_id          = 800
11042                and    fsav.id_flex_code            = 'SCL'
11043                and    fsav.segment_attribute_type  = 'ASSIGNMENT'
11044                and    fsav.attribute_value         = 'Y')
11045         and    exists
11046               (select 1
11047                from   pay_legislation_rules        plr2
11048                where  plr2.legislation_code        = plr.legislation_code
11049                and    plr2.rule_type               = 'SDL'
11050                and    plr2.rule_mode               = 'A') ;
11051   Exception
11052   when no_data_found then
11053        g_scl_rec.concatenated_segments := null;
11054        g_scl_rec.segment1 := p_gre;
11055        g_scl_rec.segment2 := null;
11056        g_scl_rec.segment3 := null;
11057        g_scl_rec.segment4 := null;
11058        g_scl_rec.segment5 := null;
11059        g_scl_rec.segment6 := null;
11060        g_scl_rec.segment7 := null;
11061        g_scl_rec.segment8 := null;
11062        g_scl_rec.segment9 := null;
11063        g_scl_rec.segment10 := null;
11064        g_scl_rec.segment11 := null;
11065        g_scl_rec.segment12 := null;
11066        g_scl_rec.segment13 := null;
11067        g_scl_rec.segment14 := null;
11068        g_scl_rec.segment15 := null;
11069        g_scl_rec.segment16 := null;
11070        g_scl_rec.segment17 := null;
11071        g_scl_rec.segment18 := null;
11072        g_scl_rec.segment19 := null;
11073        g_scl_rec.segment20 := null;
11074        g_scl_rec.segment21 := null;
11075        g_scl_rec.segment22 := null;
11076        g_scl_rec.segment23 := null;
11077        g_scl_rec.segment24 := null;
11078        g_scl_rec.segment25 := null;
11079        g_scl_rec.segment26 := null;
11080        g_scl_rec.segment27 := null;
11081        g_scl_rec.segment28 := null;
11082        g_scl_rec.segment29 := null;
11083        g_scl_rec.segment30 := null;
11084   End;
11085   -------------------------------------------------------------------------
11086 
11087   hr_utility.set_location('Soft Coding KFF segments assigned to record: ' ||
11088                                        'g_scl_rec ', 150);
11089   -- ===========================================================================
11090   -- ~ People Group Keyflex
11091   -- ===========================================================================
11092 
11093   g_grp_rec.group_name   := p_concat_segments;
11094   g_grp_rec.segment1     := p_people_segment1;
11095   g_grp_rec.segment2     := p_people_segment2;
11096   g_grp_rec.segment3     := p_people_segment3;
11097   g_grp_rec.segment4     := p_people_segment4;
11098   g_grp_rec.segment5     := p_people_segment5;
11099   g_grp_rec.segment6     := p_people_segment6;
11100   g_grp_rec.segment7     := p_people_segment7;
11101   g_grp_rec.segment8     := p_people_segment8;
11102   g_grp_rec.segment9     := p_people_segment9;
11103   g_grp_rec.segment10    := p_people_segment10;
11104   g_grp_rec.segment11    := p_people_segment11;
11105   g_grp_rec.segment12    := p_people_segment12;
11106   g_grp_rec.segment13    := p_people_segment13;
11107   g_grp_rec.segment14    := p_people_segment14;
11108   g_grp_rec.segment15    := p_people_segment15;
11109   g_grp_rec.segment16    := p_people_segment16;
11110   g_grp_rec.segment17    := p_people_segment17;
11111   g_grp_rec.segment18    := p_people_segment18;
11112   g_grp_rec.segment19    := p_people_segment19;
11113   g_grp_rec.segment20    := p_people_segment20;
11114   g_grp_rec.segment21    := p_people_segment21;
11115   g_grp_rec.segment22    := p_people_segment22;
11116   g_grp_rec.segment23    := p_people_segment23;
11117   g_grp_rec.segment24    := p_people_segment24;
11118   g_grp_rec.segment25    := p_people_segment25;
11119   g_grp_rec.segment26    := p_people_segment26;
11120   g_grp_rec.segment27    := p_people_segment27;
11121   g_grp_rec.segment28    := p_people_segment28;
11122   g_grp_rec.segment29    := p_people_segment29;
11123   g_grp_rec.segment30    := p_people_segment30;
11124 
11125   hr_utility.set_location('People Grp KFF segments assigned to record: ' ||
11126                                   'g_grp_rec ', 160);
11127   hr_utility.trace('l_migration_allowed ='||l_migration_allowed);
11128 --$ If migration allowed only call Chk_NI_Exists. Modification for Applicant Issue.
11129   --if l_migration_allowed ='Y' then
11130   l_person_id := Chk_NI_Exists
11131                 (p_national_identifier => g_per_rec.national_identifier
11132                 ,p_business_group_id   => p_business_group_id
11133                 ,p_effective_date      => g_per_rec.start_date
11134                 ,p_dup_person_id       => p_dup_person_id
11135                  );
11136  /* else
11137       if p_dup_person_id is null then
11138         l_person_id := Chk_NI_Exists
11139                 (p_national_identifier => g_per_rec.national_identifier
11140                 ,p_business_group_id   => p_business_group_id
11141                 ,p_effective_date      => g_per_rec.start_date
11142                  );
11143       else
11144          g_per_rec.person_id := p_dup_person_id;
11145          l_person_id :=	p_dup_person_id;
11146       end if;
11147   end if;*/
11148   l_apl_assignment_id :=
11149          Get_AplAsg_Id
11150         (p_person_id         => g_per_rec.person_id
11151         ,p_apl_asg_no        => p_apl_assignment_id
11152         ,p_business_group_id => p_business_group_id
11153         ,p_effective_date    => g_per_rec.start_date
11154                           );
11155 
11156   if g_asg_rec.assignment_id is not null then
11157       l_apl_assignment_id := g_asg_rec.assignment_id;
11158   end if;
11159 
11160  --hr_utility.trace(' l_apl_assignment_id = ' ||l_apl_assignment_id);
11161  -- if g_asg_rec.assignment_id is null then
11162  -- g_asg_rec.assignment_id := l_apl_assignment_id;
11163  -- end if;
11164 
11165   if p_data_pump_flag = 'Y' then
11166 
11167   --hr_utility.trace('DataPump_API_Call');
11168 
11169      DataPump_API_Call
11170      (p_data_pump_batch_line_id => p_data_pump_batch_line_id
11171      ,p_batch_id                => p_batch_id
11172      ,p_dup_party_id            => p_dup_party_id
11173      ,p_dup_person_id           => l_person_id
11174      ,p_contact_name            => p_contact_name
11175      ,p_dp_mode                 => null
11176      ,p_adjusted_svc_date       => p_adjusted_svc_date
11177 --$ Pass Link value in case of updating batch lines
11178      ,p_batch_link              => p_batch_link
11179      );
11180   else
11181     --hr_utility.trace('Direct_API_Call');
11182 
11183      Direct_API_Call
11184      (p_dup_person_id       => l_person_id
11185      ,p_dup_party_id        => p_dup_party_id
11186      ,p_appl_asg_id         => l_apl_assignment_id
11187      ,p_effective_date      => g_per_rec.start_date
11188      ,p_business_group_id   => p_business_group_id
11189      ,p_adjusted_svc_date   => p_adjusted_svc_date  -- Added by pkagrawa
11190       );
11191   end if;
11192 
11193 
11194     MSGENCODED := fnd_message.get_encoded();
11195     MSGENCODEDLEN := LENGTH(MSGENCODED);
11196     MSGNAMELOC := INSTR(MSGENCODED, chr(0));
11197     MSGAPP := SUBSTR(MSGENCODED, 1, MSGNAMELOC-1);
11198     MSGENCODED := SUBSTR(MSGENCODED, MSGNAMELOC+1, MSGENCODEDLEN);
11199     MSGENCODEDLEN := LENGTH(MSGENCODED);
11200     MSGTEXTLOC := INSTR(MSGENCODED, chr(0));
11201     MSGNAME := SUBSTR(MSGENCODED, 1, MSGTEXTLOC-1);
11202     if(MSGNAME <> 'CONC-SINGLE PENDING REQUEST' OR MSGAPP<>'FND') then
11203         fnd_message.set_name(MSGAPP, MSGNAME);
11204     end if;
11205 
11206   hr_utility.set_location('Leaving: ' || l_proc_name, 350);
11207 
11208 exception
11209   when e_upl_not_allowed then
11210     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
11211     hr_utility.set_message_token('GENERIC_TOKEN',g_upl_err_msg);
11212     hr_utility.set_location('Leaving: ' || l_proc_name, 370);
11213     hr_utility.raise_error;
11214   when e_crt_per_not_allowed then
11215     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
11216     hr_utility.set_message_token('GENERIC_TOKEN',g_crt_per_err_msg);
11217     hr_utility.set_location('Leaving: ' || l_proc_name, 370);
11218     hr_utility.raise_error;
11219   when e_crt_asg_not_allowed then
11220     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
11221     hr_utility.set_message_token('GENERIC_TOKEN',g_crt_asg_err_msg);
11222     hr_utility.set_location('Leaving: ' || l_proc_name, 370);
11223     hr_utility.raise_error;
11224   when e_crt_add_not_allowed then
11225     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
11226     hr_utility.set_message_token('GENERIC_TOKEN',g_crt_add_err_msg);
11227     hr_utility.set_location('Leaving: ' || l_proc_name, 370);
11228     hr_utility.raise_error;
11229   when Others then
11230 --   close chk_party;
11231    hr_utility.set_location('sqlerrm' || substr(sqlerrm,1,50), 370);
11232    hr_utility.set_location('sqlerrm' || substr(sqlerrm,51,100), 370);
11233    hr_utility.set_location('sqlerrm' || substr(sqlerrm,101,150), 370);
11234 
11235    --hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
11236    --hr_utility.set_message_token('GENERIC_TOKEN',substr(sqlerrm,1,50) );
11237 
11238    --hr_utility.trace(' Final Error = '||sqlerrm);
11239 
11240    rollback to InsUpd_PerAsgAdd_Rec;
11241    hr_utility.raise_error;
11242 
11243 end InsUpd_PerAsgAdd_Rec;
11244 
11245 end PQP_PerAsgAdd_RIW;