DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_PERASGADD_RIW

Source


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