DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_HROSS_INTEGRATION

Source


1 package body PQP_HROSS_integration  as
2 /* $Header: pqphrossintg.pkb 120.4 2006/09/05 11:31:17 brsinha noship $ */
3 -- =============================================================================
4 -- ~ Package Body Global variables:
5 -- =============================================================================
6   g_debug                       Boolean;
7   g_pkg                CONSTANT Varchar2(150) := 'PQP_HROSS_Integration.';
8   g_leg_code                    Varchar2(5);
9   g_emp_num_gen                 Varchar2(5);
10   g_debug_on                    Boolean;
11   l_per_rec                     per_all_people_f%ROWTYPE;
12   l_asg_rec                     per_all_assignments_f%ROWTYPE;
13   l_add_rec                     per_addresses%ROWTYPE;
14   l_cntct_rec                   per_contact_relationships%ROWTYPE;
15   l_phones_rec                  per_phones%ROWTYPE;
16   l_hr_soft_rec                 hr_soft_coding_keyflex%ROWTYPE;
17   l_ppl_grp_rec                 pay_people_groups%ROWTYPE;
18 
19   TYPE t_hrEmpApi IS RECORD
20   (person_id                    per_all_people_f.person_id%TYPE
21   ,assignment_id                per_all_assignments_f.assignment_id%TYPE
22   ,per_object_version_number    per_all_people_f.object_version_number%TYPE
23   ,asg_object_version_number    per_all_assignments_f.object_version_number%TYPE
24   ,per_effective_start_date     Date
25   ,per_effective_end_date       Date
26   ,full_name                    per_all_people_f.full_name%TYPE
27   ,per_comment_id               per_all_people_f.comment_id%TYPE
28   ,assignment_sequence          per_all_assignments_f.assignment_sequence%TYPE
29   ,assignment_number            per_all_assignments_f.assignment_number%TYPE
30   ,name_combination_warning     Boolean
31   ,assign_payroll_warning       Boolean
32   ,orig_hire_warning            Boolean
33   );
34 
35   TYPE t_AsgUpdCrit_Api IS RECORD
36   (asg_object_version_number    per_all_assignments_f.object_version_number%TYPE
37   ,special_ceiling_step_id    per_all_assignments_f.special_ceiling_step_id%TYPE
38   ,people_group_id              per_all_assignments_f.people_group_id%TYPE
39   ,soft_coding_keyflex_id      per_all_assignments_f.soft_coding_keyflex_id%TYPE
40   ,group_name                   pay_people_groups.group_name%TYPE
41   ,asg_effective_start_date     per_all_assignments_f.effective_start_date%TYPE
42   ,asg_effective_end_date       per_all_assignments_f.effective_end_date%TYPE
43   ,org_now_no_manager_warning   Boolean
44   ,other_manager_warning        Boolean
45   ,spp_delete_warning           Boolean
46   ,entries_changed_warning      Varchar2(50)
47   ,tax_district_changed_warning Boolean
48   ,concatenated_segments       hr_soft_coding_keyflex.concatenated_segments%TYPE
49   ,gsp_post_process_warning     Varchar2(2000)
50   ,comment_id                   per_assignments_f.comment_id%TYPE
51   );
52 
53   TYPE t_Upd_Emp_Asg_Api IS RECORD
54   (cagr_grade_def_id            per_all_assignments_f.cagr_grade_def_id%TYPE
55   ,cagr_concatenated_segments   Varchar2(2000)
56   ,concatenated_segments        Varchar2(2000)
57   ,soft_coding_keyflex_id      per_all_assignments_f.soft_coding_keyflex_id%TYPE
58   ,comment_id                   per_all_assignments_f.comment_id%TYPE
59   ,effective_start_date         per_all_assignments_f.effective_start_date%TYPE
60   ,effective_end_date           per_all_assignments_f.effective_end_date%TYPE
61   ,no_managers_warning          Boolean
62   ,other_manager_warning        Boolean
63   ,hourly_salaried_warning      Boolean
64   ,gsp_post_process_warning     Varchar2(2000)
65   );
66 
67   TYPE t_RehireEmp_Api IS RECORD
68   (assignment_id                per_all_assignments_f.assignment_id%TYPE
69   ,asg_object_version_number    per_all_assignments_f.object_version_number%TYPE
70   ,per_effective_start_date     per_all_people_f.effective_start_date%TYPE
71   ,per_effective_end_date       per_all_people_f.effective_end_date%TYPE
72   ,assignment_sequence          per_all_assignments_f.assignment_sequence%TYPE
73   ,assignment_number            per_all_assignments_f.assignment_number%TYPE
74   ,assign_payroll_warning       Boolean
75   );
76 
77   TYPE t_UpdEmp_Api IS RECORD
78   (effective_start_date        per_all_people_f.effective_start_date%TYPE
79   ,effective_end_date          per_all_people_f.effective_end_date%TYPE
80   ,full_name                   per_all_people_f.full_name%TYPE
81   ,comment_id                  Number
82   ,name_combination_warning    Boolean
83   ,assign_payroll_warning      Boolean
84   ,orig_hire_warning           Boolean
85   );
86 
87   TYPE t_HrToJob_Api IS RECORD
88   (effective_start_date        per_all_people_f.effective_start_date%TYPE
89   ,effective_end_date          per_all_people_f.effective_end_date%TYPE
90   ,assignment_id               per_all_assignments_f.assignment_id%TYPE
91   ,assign_payroll_warning      Boolean
92   ,orig_hire_warning           Boolean
93   );
94 
95   TYPE t_HrApp_Api IS RECORD
96   (effective_start_date        per_all_people_f.effective_start_date%TYPE
97   ,effective_end_date          per_all_people_f.effective_end_date%TYPE
98   ,assign_payroll_warning      Boolean
99   ,oversubscribed_vacancy_id   Number
100   );
101 
102   TYPE t_CreateContact_Api IS RECORD
103  (contact_relationship_id per_contact_relationships.contact_relationship_id%TYPE
104  ,ctr_object_version_number per_contact_relationships.object_version_number%TYPE
105   ,per_person_id               per_contact_relationships.contact_person_id%TYPE
106   ,per_object_version_number
107                            per_contact_relationships.object_version_number%TYPE
108   ,per_effective_start_date    per_contact_relationships.date_start%TYPE
109   ,per_effective_end_date      per_contact_relationships.date_start%TYPE
110   ,full_name                   per_all_people_f.full_name%TYPE
111   ,per_comment_id              per_all_people_f.comment_id%TYPE
112   ,name_combination_warning    Boolean
113   ,orig_hire_warning           Boolean
114   );
115 
116 -- =============================================================================
117 -- ~ Package Body Cursor variables:
118 -- =============================================================================
119    -- Cursor to get the leg. code
120    CURSOR csr_bg_code (c_bg_grp_id IN Number) IS
121    SELECT pbg.legislation_code
122          ,pbg.method_of_generation_emp_num
123      FROM per_business_groups pbg
124     WHERE pbg.business_group_id = c_bg_grp_id;
125 
126    -- Cursor to get the meaning and code for a lookup type
127    CURSOR csr_chk_code (c_lookup_type    IN Varchar2
128                        ,c_lookup_code    IN Varchar2
129                        ,c_effective_date IN Date) IS
130    SELECT hrl.meaning
131          ,hrl.lookup_code
132      FROM hr_lookups hrl
133     WHERE hrl.lookup_type = c_lookup_type
134       AND hrl.lookup_code = c_lookup_code
135       AND hrl.enabled_flag = 'Y'
136       AND Trunc(c_effective_date)
137           BETWEEN NVL(hrl.start_date_active,Trunc(c_effective_date))
138               AND NVL(hrl.end_date_active,  Trunc(c_effective_date));
139 
140    -- Cursor to check the valid DF context
141    CURSOR csr_style (c_context_code IN Varchar2) IS
142    SELECT dfc.descriptive_flex_context_code
143      FROM fnd_descr_flex_contexts dfc
144     WHERE dfc.application_id = 800
145       AND dfc.descriptive_flexfield_name = 'Person Developer DF'
146       AND dfc.enabled_flag = 'Y';
147 
148   -- Cursor to get details of a particular person
149   CURSOR csr_per (c_person_id IN Number
150                  ,c_business_group_id IN Number
151                  ,c_effective_date IN Date ) IS
152   SELECT *
153     FROM per_all_people_f ppf
154    WHERE ppf.person_id = c_person_id
155      AND ppf.business_group_id = c_business_group_id
156      AND c_effective_date BETWEEN ppf.effective_start_date
157                               AND ppf.effective_end_date;
158 
159   -- Check the person or party if exists in HRMS
160   CURSOR chk_party (c_party_id       IN Number
161                    ,c_bg_grp_id      IN Number
162                    ,c_person_id      IN Number
163                    ,c_effective_date IN Date) IS
164   SELECT ppt.system_person_type
165         ,ppf.effective_start_date
166         ,ppf.effective_end_date
167         ,ppf.employee_number
168         ,ppt.person_type_id
169         ,ppf.person_id
170     FROM per_all_people_f ppf
171         ,per_person_types ppt
172    WHERE ppt.person_type_id = ppf.person_type_id
173      AND ppf.business_group_id = c_bg_grp_id
174      AND ppt.business_group_id = ppf.business_group_id
175      AND ppt.active_flag = 'Y'
176      AND ((c_person_id IS NOT NULL AND ppf.person_id = c_person_id) OR
177           (c_party_id IS NOT NULL AND ppf.party_id = c_party_id))
178      AND c_effective_date BETWEEN ppf.effective_start_date
179                               AND ppf.effective_end_date;
180 
181   -- Cursor to get the person types used as of a date
182   CURSOR csr_per_ptu (c_person_id         IN Number
183                      ,c_business_group_id IN Number
184                      ,c_effective_date    IN Date) IS
185   SELECT ptu.person_id
186         ,ptu.person_type_id
187         ,ppt.active_flag
188         ,ppt.system_person_type
189         ,ppt.user_person_type
190     FROM per_person_type_usages_f ptu
191         ,per_person_types         ppt
192    WHERE ptu.person_id = c_person_id
193      AND ppt.business_group_id = c_business_group_id
194      AND ppt.person_type_id = ptu.person_type_id
195      AND c_effective_date BETWEEN ptu.effective_start_date
196                               AND ptu.effective_end_date
197      AND ppt.system_person_type
198          IN ('EMP','EMP_APL','EX_EMP',
199              'APL','APL_EX_APL','EX_APL','EX_EMP_APL',
200              'CWK','EX_CWK')
201   ORDER BY ptu.effective_start_date desc;
202 
203   -- Cursor to check if the person has any future person type
204   -- changes of EMP, APL, CWK or OTHER i.e. Contact type
205   CURSOR chk_perType_usage (c_person_id         IN NUMBER
206                            ,c_effective_date    IN Date
207                            ,c_business_group_id IN Number) Is
208   SELECT ptu.person_type_id
209         ,ppt.system_person_type
210         ,ppt.user_person_type
211     FROM per_person_type_usages_f ptu
212         ,per_person_types         ppt
213    WHERE ptu.person_id = c_person_id
214      AND ppt.person_type_id = ptu.person_type_id
215      AND ppt.business_group_id = c_business_group_id
216      AND ptu.effective_start_date > c_effective_date
217      AND ppt.system_person_type
218            IN ('EMP'   ,'CWK'       ,'APL'       ,'EMP_APL',
219                'EX_APL','EX_CWK'    ,'EX_EMP_APL',
220                'OTHER' ,'APL_EX_APL','EX_EMP'
221                );
222 
223   -- Cursor to check if the applicant assignment is accepted
224   CURSOR csr_accepted_asgs(c_person_id         IN Number
225                           ,c_business_group_id IN Number
226                           ,c_effective_date    IN Date
227                           ,c_assignment_id     IN Number
228                           ) IS
229   SELECT asg.assignment_id
230         ,asg.object_version_number
231         ,asg.vacancy_id
232     FROM per_assignments_f asg
233         ,per_assignment_status_types ast
234    WHERE asg.assignment_status_type_id = ast.assignment_status_type_id
235      AND asg.person_id = c_person_id
236      AND asg.business_group_id = c_business_group_id
237      AND (c_assignment_id IS NULL OR
238           asg.assignment_id = c_assignment_id)
239      AND c_effective_date BETWEEN asg.effective_start_date
240                               AND asg.effective_end_date
241      AND asg.assignment_type = 'A'
242      AND ast.per_system_status = 'ACCEPTED';
243 
244   -- Cursor to check if the applicant assignment is accepted
245   CURSOR csr_not_accepted_asgs(c_person_id         IN Number
246                               ,c_business_group_id IN Number
247                               ,c_effective_date    IN Date
248                               ,c_assignment_id     IN Number
249                               ) IS
250   SELECT asg.assignment_id
251         ,asg.object_version_number
252         ,asg.vacancy_id
253     FROM per_assignments_f asg
254         ,per_assignment_status_types ast
255    WHERE asg.assignment_status_type_id = ast.assignment_status_type_id
256      AND asg.person_id = c_person_id
257      AND asg.business_group_id = c_business_group_id
258      AND (c_assignment_id IS NULL OR
259           asg.assignment_id = c_assignment_id)
260      AND c_effective_date BETWEEN asg.effective_start_date
261                               AND asg.effective_end_date
262      AND asg.assignment_type = 'A'
263      AND ast.per_system_status <> 'ACCEPTED';
264 
265   -- Cursor to get the Assignment Status Id of accepted Applicant Assig.
266   CURSOR csr_asg_status (c_leg_code IN Varchar2
267                         ,c_business_group_id IN NUMBER
268                         ) IS
269   SELECT assignment_status_type_id
270         ,active_flag
271         ,per_system_status
272    FROM per_assignment_status_types
273   WHERE per_system_status = 'ACCEPTED'
274     AND (business_group_id = c_business_group_id
275          OR legislation_code = c_leg_code
276          OR (legislation_code IS NULL
277              AND business_group_id IS NULL)
278          )
279     AND default_flag = 'Y'
280     AND active_flag  = 'Y';
281 
282   -- Cursor to get the User Person Type
283   CURSOR csr_per_type(c_person_type_id Number
284                      ,c_business_group_id IN Number) IS
285   SELECT ppt.user_person_type
286     FROM per_person_types ppt
287    WHERE ppt.person_type_id    = c_person_type_id
288      AND ppt.business_group_id = c_business_group_id;
289 
290   -- Cursor to get the Grade Name
291   CURSOR csr_grade(c_grade_id IN Number
292                   ,c_business_group_id IN Number
293                   ,c_effective_date IN Date) IS
294   SELECT gtl.NAME
295     FROM per_grades    pgr
296         ,per_grades_tl gtl
297    WHERE pgr.grade_id = c_grade_id
298      AND gtl.grade_id = pgr.grade_id
299      AND gtl.LANGUAGE = Userenv('LANG')
300      AND  pgr.business_group_id = c_business_group_id
301      AND c_effective_date BETWEEN pgr.date_from
302                               AND NVL(pgr.date_to,c_effective_date);
303 
304   -- Cursor to get the Position Name
305   CURSOR csr_position(c_position_id IN Number
306                      ,c_business_group_id IN Number
307                      ,c_effective_date IN Date) IS
308   SELECT ptl.NAME
309     FROM hr_all_positions_f    pos
310         ,hr_all_positions_f_tl ptl
311    WHERE pos.position_id = c_position_id
312      AND ptl.position_id = pos.position_id
313      AND ptl.LANGUAGE = Userenv('LANG')
314      AND pos.business_group_id = c_business_group_id
315      AND c_effective_date BETWEEN pos.effective_start_date
316                               AND pos.effective_end_date;
317 
318   -- Cursor to get the Job Name
319   CURSOR csr_job(c_job_id IN Number
320                 ,c_business_group_id IN Number
321                 ,c_effective_date IN Date) IS
322   SELECT jtl.NAME
323     FROM per_jobs    pjb
324         ,per_jobs_tl jtl
325    WHERE pjb.job_id = c_job_id
326      AND jtl.job_id = pjb.job_id
327      AND jtl.LANGUAGE = Userenv('LANG')
328      AND pjb.business_group_id = c_business_group_id
329      AND c_effective_date BETWEEN pjb.date_from
330                               AND NVL(pjb.date_to,c_effective_date);
331 
332   -- Cursor to get the Payroll Name
333   CURSOR csr_payroll(c_payroll_id IN Number
334                     ,c_business_group_id IN Number
335                     ,c_effective_date IN Date) IS
336   SELECT payroll_name
337     FROM pay_payrolls_f ppf
338    WHERE ppf.payroll_id = c_payroll_id
339      AND ppf.business_group_id = c_business_group_id
340      AND c_effective_date BETWEEN ppf.effective_start_date
341                               AND ppf.effective_end_date;
342 
343   -- Cursor to get the Location Code
344   CURSOR csr_location(c_location_id IN Number
345                      ,c_business_group_id IN Number
346                      ) IS
347   SELECT htl.location_code
348     FROM hr_locations          hrl
349         ,hr_locations_all_tl   htl
350    WHERE hrl.location_id = c_location_id
351      AND htl.location_id = hrl.location_id
352      AND htl.LANGUAGE = Userenv('LANG')
353      AND (hrl.business_group_id IS NULL OR
354           hrl.business_group_id = c_business_group_id);
355 
356   -- Cursor to get the Organization Name
357   CURSOR csr_organization(c_organization_id IN Number
358                          ,c_business_group_id IN Number
359                          ,c_effective_date IN Date
360                           ) IS
361   SELECT htl.NAME
362     FROM hr_all_organization_units_tl htl
363         ,hr_all_organization_units    hao
364    WHERE hao.organization_id = c_organization_id
365      AND hao.business_group_id = c_business_group_id
366      AND htl.organization_id = hao.organization_id
367      AND htl.LANGUAGE = Userenv('LANG')
368      AND c_effective_date BETWEEN hao.date_from
369                               AND NVL(hao.date_to,c_effective_date);
370 
371   -- Cursor to get the Pay Basis Name
372   CURSOR csr_paybasis(c_pay_basis_id IN Number
373                      ,c_business_group_id IN Number
374                      ) IS
375   SELECT ppb.NAME
376     FROM per_pay_bases ppb
377    WHERE ppb.pay_basis_id = c_pay_basis_id
378      AND ppb.business_group_id = c_business_group_id;
379 
380   -- Cursor to check if address already exists
381   CURSOR csr_ck_add_xsts (c_person_id         IN Number
382                          ,c_business_group_id IN Number
383                          ,c_effective_date    IN Date
384                          ,c_primary_flag      IN Varchar2) IS
385   SELECT *
386     FROM per_addresses
387    WHERE person_id = c_person_id
388      AND business_group_id = c_business_group_id
389      AND primary_flag = c_primary_flag
390      AND c_effective_date BETWEEN date_from
391                               AND NVL(date_to, c_effective_date);
392 
393   -- Cursor to check if Contact for a person already exists
394   CURSOR csr_ck_cont_xsts(c_person_id         IN Number
395                          ,c_business_group_id IN Number
396                          ,c_effective_date    IN Date) IS
397   SELECT object_version_number
398     FROM per_contact_relationships
399    WHERE person_id = c_person_id
400      AND business_group_id = c_business_group_id
401      AND c_effective_date BETWEEN date_start
402                               AND NVL(date_end, c_effective_date);
403 
404   -- Cursor to get the Employee Number
405   CURSOR csr_get_employee_num(c_person_id   IN Number) IS
406   SELECT employee_number
407     FROM per_people_f
408    WHERE person_id = c_person_id;
409 
410 -- =============================================================================
411 -- ~ Student_FICA_Status: Procedure to update the FICA status of a student
412 -- ~ employee. This is only required to US legislation when the user selects the
413 -- ~ FICA option as Yes on the OAF UI.
414 -- =============================================================================
415 PROCEDURE Student_FICA_Status
416           (p_assignment_id     IN Number
417           ,p_effective_date    IN Date
418           ,p_business_group_id IN Number
419           ,p_FICA_Status       IN Varchar2) IS
420 
421   -- Cursor to get the current FICA status
422   CURSOR csr_tax (c_effective_date IN Date
423                  ,c_assignment_id  IN Number) IS
424   SELECT *
425     FROM pay_us_emp_fed_tax_rules_f ftx
426    WHERE ftx.assignment_id = c_assignment_id
427      AND c_effective_date between ftx.effective_start_date
428                               AND ftx.effective_end_date;
429 
430   l_fed_rec               csr_tax%Rowtype;
431   --
432   l_effective_date        Date;
433   l_start_effective_date  Date;
434   l_end_effective_date    Date;
435   --
436   l_dt_update             Boolean;
437   l_dt_upd_override       Boolean;
438   l_upd_chg_ins           Boolean;
439   l_dt_correction         Boolean;
440   --
441   l_Datetrack_mode        Varchar2(50);
442   l_error_msg             Varchar2(2000);
443   l_proc_name    Constant Varchar2(150) :='Student_FICA_Status';
444 
445 BEGIN
446   Hr_Utility.set_location('Entering: '||l_proc_name, 5);
447 
448   OPEN csr_tax (c_effective_date => p_effective_date
449                ,c_assignment_id  => p_assignment_id);
450   FETCH csr_tax INTO l_fed_rec;
451   Hr_Utility.set_location(' EMP_FED_TAX_RULE_ID: '||l_fed_rec.emp_fed_tax_rule_id, 10);
452   IF csr_tax%NOTFOUND THEN
453      CLOSE csr_tax;
454      RETURN;
455   END IF;
456   CLOSE csr_tax;
457 
458   Dt_Api.Find_DT_Upd_Modes
459   (p_effective_date       => p_effective_date
460   ,p_base_table_name      => 'PAY_US_EMP_FED_TAX_RULES_F'
461   ,p_base_key_column      => 'EMP_FED_TAX_RULE_ID'
462   ,p_base_key_value       => l_fed_rec.emp_fed_tax_rule_id
463   ,p_correction           => l_dt_correction
464   ,p_update               => l_dt_update
465   ,p_update_override      => l_dt_upd_override
466   ,p_update_change_insert => l_upd_chg_ins
467    );
468 
469   IF l_dt_update THEN
470      l_datetrack_mode := 'UPDATE';
471   ELSIF l_dt_upd_override OR
472         l_upd_chg_ins THEN
473         -- Need to check if person type in future is EMP, APL or CWK , if yes
474         -- then raise error
475         NULL;
476   ELSE
477      l_Datetrack_mode := 'CORRECTION';
478   END IF;
479 
480   Hr_Utility.set_location(' l_datetrack_mode: '||l_datetrack_mode, 15);
481   IF l_fed_rec.emp_fed_tax_rule_id IS NOT NULL THEN
482      IF NVL(p_FICA_Status,'N') = 'N' THEN
483        l_fed_rec.medicare_tax_exempt := 'N';
484        l_fed_rec.ss_tax_exempt       := 'N';
485      ELSE
486        l_fed_rec.medicare_tax_exempt := 'Y';
487        l_fed_rec.ss_tax_exempt       := 'Y';
488      END IF;
489 
490      Pay_Federal_Tax_Rule_Api.UpDate_Fed_Tax_Rule
491      (p_validate              => false
492      ,p_effective_date        => p_effective_date
493      ,p_datetrack_update_mode => l_datetrack_mode
494      ,p_emp_fed_tax_rule_id   => l_fed_rec.emp_fed_tax_rule_id
495      ,p_object_version_number => l_fed_rec.object_version_number
496      ,p_medicare_tax_exempt   => l_fed_rec.medicare_tax_exempt
497      ,p_ss_tax_exempt         => l_fed_rec.ss_tax_exempt
498      ,p_effective_start_date  => l_start_effective_date
499      ,p_effective_end_date    => l_end_effective_date
500      );
501   END IF;
502   Hr_Utility.set_location('Leaving: '||l_proc_name, 80);
503 
504 EXCEPTION
505   WHEN OTHERS THEN
506    IF csr_tax%ISOPEN THEN
507       CLOSE csr_tax;
508    END IF;
509    l_error_msg := sqlerrm;
510    Hr_Utility.set_location('SQLCODE :'||SQLCODE,90);
511    Hr_Utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
512    Hr_Utility.set_message_token('GENERIC_TOKEN',l_error_msg );
513    Hr_Utility.set_location('Leaving: '||l_proc_name, 90);
514    Hr_Utility.raise_error;
515 
516 END Student_FICA_Status;
517 -- =============================================================================
518 -- ~ FICA_Status: Function to return the FICA status of an employee assignment.
519 -- ~ This only appicable for US legislation
520 -- =============================================================================
521 FUNCTION FICA_Status
522          (p_assignment_id     IN Number
523          ,p_effective_date    IN Date
524           ) RETURN Varchar2 IS
525 
526   --Cursor to get the current FICA status
527   CURSOR csr_tax (c_effective_date IN DATE
528                 ,c_assignment_id IN NUMBER) IS
529   SELECT *
530    FROM pay_us_emp_fed_tax_rules_f ftx
531   WHERE ftx.assignment_id = c_assignment_id
532     AND c_effective_date between ftx.effective_start_date
533                              AND ftx.effective_end_date;
534 
535   -- Local Variable to hold the cursor values
536   l_fed_rec                   csr_tax%ROWTYPE;
537 
538   -- Other local variables
539   l_error_message             Varchar2(2000);
540   l_return_status             Varchar2(5);
541   l_proc_name      CONSTANT   Varchar2(150) := g_pkg||'FICA_Status';
542 
543 BEGIN
544   Hr_utility.set_location('Entering:' || l_proc_name, 10);
545   Hr_utility.set_location('p_assignment_id = ' || p_assignment_id, 20);
546 
547   l_return_status := 'N';
548   OPEN csr_tax(c_effective_date =>  p_effective_date
549               ,c_assignment_id  =>  p_assignment_id);
550   FETCH csr_tax INTO l_fed_rec;
551   IF csr_tax%NOTFOUND THEN
552     CLOSE csr_tax;
553   ELSE
554     Hr_utility.set_location('Tax record found', 30);
555     Hr_utility.set_location('SS :'||l_fed_rec.ss_tax_exempt, 30);
556     Hr_utility.set_location('Medicare: '||l_fed_rec.medicare_tax_exempt, 30);
557     IF NVL(l_fed_rec.medicare_tax_exempt,'N') = 'Y' AND
558        NVL(l_fed_rec.ss_tax_exempt,'N') = 'Y' THEN
559        l_return_status := 'Y';
560     END IF;
561   END IF;
562   Hr_Utility.set_location('Leaving:' || l_proc_name, 50);
563   RETURN l_return_status;
564 
565 EXCEPTION
566   WHEN OTHERS THEN
567    IF csr_tax%ISOPEN THEN
568       CLOSE csr_tax;
569    END IF;
570    Hr_Utility.set_location('Leaving:' || l_proc_name, 90);
571    RETURN l_return_status;
572 
573 END FICA_Status;
574 -- =============================================================================
575 -- ~ Update_StuEmpAsg_Criteria :
576 -- =============================================================================
577 PROCEDURE Update_StuEmpAsg_Criteria
578          (p_effective_date IN Date
579          ,p_asg_crit_out   IN OUT NOCOPY t_AsgUpdCrit_Api
580          --,p_UpdEmpAsg_out  IN OUT NOCOPY t_Upd_Emp_Asg_Api
581           ) AS
582 
583   -- Cursor to get Assignment details
584   CURSOR csr_asg (c_effective_date IN Date
585                  ,c_assignment_id  IN Number
586                  ,c_business_group_id IN Number)IS
587   SELECT *
588     FROM per_all_assignments_f paf
589    WHERE paf.assignment_id = c_assignment_id
590      AND paf.business_group_id = c_business_group_id
591      AND c_effective_date BETWEEN paf.effective_start_date
592                               AND paf.effective_end_date;
593 
594   l_cur_asg_rec            csr_asg%ROWTYPE;
595 
596   -- Cursor to get people group flexfield details
597   CURSOR csr_ppg (c_people_grp_id IN Number) IS
598   SELECT *
599     FROM pay_people_groups
600    WHERE people_group_id = c_people_grp_id;
601 
602   l_cur_ppl_grp_rec        pay_people_groups%ROWTYPE;
603 
604   -- Cursor to get Soft coding flexfield details
605   CURSOR csr_scl (c_scl_kff_id IN Number) IS
606   SELECT *
607     FROM hr_soft_coding_keyflex
608    WHERE soft_coding_keyflex_id = c_scl_kff_id;
609 
610   l_cur_scl_rec        hr_soft_coding_keyflex%ROWTYPE;
611 
612   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Update_StuEmpAsg_Criteria';
613   l_error_msg              Varchar2(2000);
614   l_datetrack_update_mode  Varchar2(50);
615   l_dt_correction          Boolean;
616   l_dt_update              Boolean;
617   l_dt_upd_override        Boolean;
618   l_upd_chg_ins            Boolean;
619   e_empasg_notfound        EXCEPTION;
620   l_UpdEmpAsg_out          t_Upd_Emp_Asg_Api;
621 
622 BEGIN
623   hr_utility.set_location('Entering: ' || l_proc_name, 10);
624 
625   OPEN  csr_asg (c_effective_date    => p_effective_date
626                 ,c_assignment_id     => l_asg_rec.assignment_id
627                 ,c_business_group_id => l_asg_rec.business_group_id
628                  );
629   FETCH csr_asg INTO l_cur_asg_rec;
630   IF csr_asg%NOTFOUND THEN
631      CLOSE csr_asg;
632      RAISE e_empasg_notfound;
633   END IF;
634   CLOSE csr_asg;
635   hr_utility.set_location(' l_cur_asg_rec: ' || p_effective_date, 20);
636   hr_utility.set_location(' l_cur_asg_rec: ' || l_asg_rec.assignment_id, 20);
637   hr_utility.set_location(' l_cur_asg_rec: ' || l_asg_rec.business_group_id, 20);
638 
639   OPEN  csr_ppg(c_people_grp_id => l_asg_rec.people_group_id);
640   FETCH csr_ppg INTO l_cur_ppl_grp_rec;
641   IF csr_ppg%FOUND THEN
642      p_asg_crit_out.people_group_id := l_asg_rec.people_group_id;
643   END IF;
644   CLOSE csr_ppg;
645   hr_utility.set_location(' people_group_id: ' || l_asg_rec.people_group_id, 30);
646 
647   OPEN  csr_scl(c_scl_kff_id => l_asg_rec.soft_coding_keyflex_id);
648   FETCH csr_scl INTO l_cur_scl_rec;
649   IF csr_scl%FOUND THEN
650      p_asg_crit_out.soft_coding_keyflex_id := l_asg_rec.soft_coding_keyflex_id;
651   END IF;
652   CLOSE csr_scl;
653   hr_utility.set_location(' soft_coding_keyflex_id: ' ||
654                             l_asg_rec.soft_coding_keyflex_id, 40);
655 
656   Dt_Api.Find_DT_Upd_Modes
657   (p_effective_date        => p_effective_date
658   ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
659   ,p_base_key_column       => 'ASSIGNMENT_ID'
660   ,p_base_key_value        => l_asg_rec.assignment_id
661   ,p_correction            => l_dt_correction
662   ,p_update                => l_dt_update
663   ,p_update_override       => l_dt_upd_override
664   ,p_update_change_insert  => l_upd_chg_ins
665    );
666 
667   IF l_dt_update THEN
668      l_datetrack_update_mode := 'UPDATE';
669   ELSIF l_dt_upd_override OR
670         l_upd_chg_ins THEN
671         -- Need to check if person type in future is EMP, APL or CWK , if yes
672         -- then raise error
673      l_datetrack_update_mode := 'UPDATE';
674      hr_utility.set_location(' l_dt_upd_override or l_upd_chg_ins ', 50);
675   ELSE
676      l_datetrack_update_mode := 'CORRECTION';
677   END IF;
678   hr_utility.set_location(' l_datetrack_update_mode: ' ||
679                             l_datetrack_update_mode, 60);
680 
681   Hr_Assignment_Api.Update_Emp_Asg_Criteria
682   (p_effective_date               => p_effective_date
683   ,p_datetrack_update_mode        => l_datetrack_update_mode
684   ,p_assignment_id                => l_asg_rec.assignment_id
685   ,p_validate                     => FALSE
686   ,p_called_from_mass_update      => FALSE
687   ,p_grade_id                     => NVL(l_asg_rec.grade_id,
688                                          l_cur_asg_rec.grade_id)
689   ,p_position_id                  => NVL(l_asg_rec.position_id,
690                                          l_cur_asg_rec.position_id)
691   ,p_job_id                       => NVL(l_asg_rec.job_id,
692                                          l_cur_asg_rec.job_id)
693   ,p_payroll_id                   => NVL(l_asg_rec.payroll_id,
694                                          l_cur_asg_rec.payroll_id)
695   ,p_location_id                  => NVL(l_asg_rec.location_id,
696                                          l_cur_asg_rec.location_id)
697   ,p_organization_id              => NVL(l_asg_rec.organization_id,
698                                          l_cur_asg_rec.organization_id)
699   ,p_pay_basis_id                 => NVL(l_asg_rec.pay_basis_id,
700                                          l_cur_asg_rec.pay_basis_id)
701   ,p_employment_category          => NVL(l_asg_rec.employment_category,
702                                          l_cur_asg_rec.employment_category)
703   ,p_segment1                     => l_ppl_grp_rec.segment1
704   ,p_segment2                     => l_ppl_grp_rec.segment2
705   ,p_segment3                     => l_ppl_grp_rec.segment3
706   ,p_segment4                     => l_ppl_grp_rec.segment4
707   ,p_segment5                     => l_ppl_grp_rec.segment5
708   ,p_segment6                     => l_ppl_grp_rec.segment6
709   ,p_segment7                     => l_ppl_grp_rec.segment7
710   ,p_segment8                     => l_ppl_grp_rec.segment8
711   ,p_segment9                     => l_ppl_grp_rec.segment9
712   ,p_segment10                    => l_ppl_grp_rec.segment10
713   ,p_segment11                    => l_ppl_grp_rec.segment11
714   ,p_segment12                    => l_ppl_grp_rec.segment12
715   ,p_segment13                    => l_ppl_grp_rec.segment13
716   ,p_segment14                    => l_ppl_grp_rec.segment14
717   ,p_segment15                    => l_ppl_grp_rec.segment15
718   ,p_segment16                    => l_ppl_grp_rec.segment16
719   ,p_segment17                    => l_ppl_grp_rec.segment17
720   ,p_segment18                    => l_ppl_grp_rec.segment18
721   ,p_segment19                    => l_ppl_grp_rec.segment19
722   ,p_segment20                    => l_ppl_grp_rec.segment20
723   ,p_segment21                    => l_ppl_grp_rec.segment21
724   ,p_segment22                    => l_ppl_grp_rec.segment22
725   ,p_segment23                    => l_ppl_grp_rec.segment23
726   ,p_segment24                    => l_ppl_grp_rec.segment24
727   ,p_segment25                    => l_ppl_grp_rec.segment25
728   ,p_segment26                    => l_ppl_grp_rec.segment26
729   ,p_segment27                    => l_ppl_grp_rec.segment27
730   ,p_segment28                    => l_ppl_grp_rec.segment28
731   ,p_segment29                    => l_ppl_grp_rec.segment29
732   ,p_segment30                    => l_ppl_grp_rec.segment30
733   ,p_concat_segments              => l_ppl_grp_rec.group_name
734 /*
735   ,p_contract_id                  IN     NUMBER   DEFAULT Hr_Api.g_number
736   ,p_establishment_id             IN     NUMBER   DEFAULT Hr_Api.g_number
737   ,p_grade_ladder_pgm_id          IN     NUMBER   DEFAULT Hr_Api.g_number
738   ,p_supervisor_assignment_id     IN     NUMBER   DEFAULT Hr_Api.g_number
739 */
740   ,p_scl_segment1                 => l_hr_soft_rec.segment1
741   ,p_object_version_number        => l_cur_asg_rec.object_version_number
742   ,p_special_ceiling_step_id      => p_asg_crit_out.special_ceiling_step_id
743   ,p_people_group_id              => p_asg_crit_out.people_group_id
744   ,p_soft_coding_keyflex_id       => p_asg_crit_out.soft_coding_keyflex_id
745   ,p_group_name                   => p_asg_crit_out.group_name
746   ,p_effective_start_date         => p_asg_crit_out.asg_effective_start_date
747   ,p_effective_end_date           => p_asg_crit_out.asg_effective_end_date
748   ,p_org_now_no_manager_warning   => p_asg_crit_out.org_now_no_manager_warning
749   ,p_other_manager_warning        => p_asg_crit_out.other_manager_warning
750   ,p_spp_delete_warning           => p_asg_crit_out.spp_delete_warning
751   ,p_entries_changed_warning      => p_asg_crit_out.entries_changed_warning
752   ,p_tax_district_changed_warning => p_asg_crit_out.tax_district_changed_warning
753   ,p_concatenated_segments        => p_asg_crit_out.concatenated_segments
754   ,p_gsp_post_process_warning     => p_asg_crit_out.gsp_post_process_warning
755   );
756   IF g_debug_on THEN
757      hr_utility.set_location(' people_group_id: ' ||
758                                p_asg_crit_out.people_group_id, 70);
759      hr_utility.set_location(' soft_coding_keyflex_id: ' ||
760                                p_asg_crit_out.soft_coding_keyflex_id, 70);
761      hr_utility.set_location(' group_name: ' ||
762                                p_asg_crit_out.group_name, 70);
763      hr_utility.set_location(' asg_effective_start_date: ' ||
764                                p_asg_crit_out.asg_effective_start_date, 70);
765   END IF;
766   l_datetrack_update_mode := 'CORRECTION';
767 
768   l_asg_rec.cagr_grade_def_id := NVL(l_asg_rec.cagr_grade_def_id,
769                                      l_cur_asg_rec.cagr_grade_def_id);
770   l_asg_rec.soft_coding_keyflex_id := p_asg_crit_out.soft_coding_keyflex_id;
771   --
772   -- Hr_Assignment_Api.Update_Emp_Asg: Use the overloaded update_emp_asg(NEW3)
773   --
774   Hr_Assignment_Api.Update_Emp_Asg
775   (p_validate                     => FALSE
776   ,p_effective_date               => p_effective_date
777   ,p_datetrack_update_mode        => l_datetrack_update_mode
778   ,p_assignment_id                => l_cur_asg_rec.assignment_id
779   ,p_object_version_number        => l_cur_asg_rec.object_version_number
780   ,p_supervisor_id                => NVL(l_asg_rec.supervisor_id,
781                                          l_cur_asg_rec.supervisor_id)
782   ,p_assignment_number            => NVL(l_asg_rec.assignment_number,
783                                          l_cur_asg_rec.assignment_number)
784   ,p_change_reason                => NVL(l_asg_rec.change_reason,
785                                          l_cur_asg_rec.change_reason)
786   ,p_date_probation_end           => NVL(l_asg_rec.date_probation_end,
787                                          l_cur_asg_rec.date_probation_end)
788   ,p_default_code_comb_id         => NVL(l_asg_rec.default_code_comb_id,
789                                          l_cur_asg_rec.default_code_comb_id)
790   ,p_frequency                    => NVL(l_asg_rec.frequency,
791                                          l_cur_asg_rec.frequency)
792   ,p_internal_address_line        => NVL(l_asg_rec.internal_address_line,
793                                          l_cur_asg_rec.internal_address_line)
794   ,p_manager_flag                 => NVL(l_asg_rec.manager_flag,
795                                          l_cur_asg_rec.manager_flag)
796   ,p_normal_hours                 => NVL(l_asg_rec.normal_hours,
797                                          l_cur_asg_rec.normal_hours)
798   ,p_perf_review_period           => NVL(l_asg_rec.perf_review_period,
799                                          l_cur_asg_rec.perf_review_period)
800   ,p_perf_review_period_frequency => NVL(l_asg_rec.perf_review_period_frequency,
801                                      l_cur_asg_rec.perf_review_period_frequency)
802   ,p_probation_period             => NVL(l_asg_rec.probation_period,
803                                          l_cur_asg_rec.probation_period)
804   ,p_probation_unit               => NVL(l_asg_rec.probation_unit,
805                                          l_cur_asg_rec.probation_unit)
806   ,p_sal_review_period            => NVL(l_asg_rec.sal_review_period,
807                                          l_cur_asg_rec.sal_review_period)
808   ,p_sal_review_period_frequency  => NVL(l_asg_rec.sal_review_period_frequency,
809                                      l_cur_asg_rec.sal_review_period_frequency)
810   ,p_set_of_books_id              => NVL(l_asg_rec.set_of_books_id,
811                                          l_cur_asg_rec.set_of_books_id)
812   ,p_source_type                  => NVL(l_asg_rec.source_type,
813                                          l_cur_asg_rec.source_type)
814   ,p_time_normal_finish           => NVL(l_asg_rec.time_normal_finish,
815                                          l_cur_asg_rec.time_normal_finish)
816   ,p_time_normal_start            => NVL(l_asg_rec.time_normal_start,
817                                          l_cur_asg_rec.time_normal_start)
818   ,p_bargaining_unit_code         => NVL(l_asg_rec.bargaining_unit_code,
819                                          l_cur_asg_rec.bargaining_unit_code)
820   ,p_labour_union_member_flag     => NVL(l_asg_rec.labour_union_member_flag,
821                                          l_cur_asg_rec.labour_union_member_flag)
822   ,p_hourly_salaried_code         => NVL(l_asg_rec.hourly_salaried_code,
823                                          l_cur_asg_rec.hourly_salaried_code)
824   ,p_title                        => NVL(l_asg_rec.title,
825                                          l_cur_asg_rec.title)
826   -- Assignment DF
827   ,p_ass_attribute_category       => l_asg_rec.ass_attribute_category
828   ,p_ass_attribute1               => l_asg_rec.ass_attribute1
829   ,p_ass_attribute2               => l_asg_rec.ass_attribute2
830   ,p_ass_attribute3               => l_asg_rec.ass_attribute3
831   ,p_ass_attribute4               => l_asg_rec.ass_attribute4
832   ,p_ass_attribute5               => l_asg_rec.ass_attribute5
833   ,p_ass_attribute6               => l_asg_rec.ass_attribute6
834   ,p_ass_attribute7               => l_asg_rec.ass_attribute7
835   ,p_ass_attribute8               => l_asg_rec.ass_attribute8
836   ,p_ass_attribute9               => l_asg_rec.ass_attribute9
837   ,p_ass_attribute10              => l_asg_rec.ass_attribute10
838   ,p_ass_attribute11              => l_asg_rec.ass_attribute11
839   ,p_ass_attribute12              => l_asg_rec.ass_attribute12
840   ,p_ass_attribute13              => l_asg_rec.ass_attribute13
841   ,p_ass_attribute14              => l_asg_rec.ass_attribute14
842   ,p_ass_attribute15              => l_asg_rec.ass_attribute15
843   ,p_ass_attribute16              => l_asg_rec.ass_attribute16
844   ,p_ass_attribute17              => l_asg_rec.ass_attribute17
845   ,p_ass_attribute18              => l_asg_rec.ass_attribute18
846   ,p_ass_attribute19              => l_asg_rec.ass_attribute19
847   ,p_ass_attribute20              => l_asg_rec.ass_attribute20
848   ,p_ass_attribute21              => l_asg_rec.ass_attribute21
849   ,p_ass_attribute22              => l_asg_rec.ass_attribute22
850   ,p_ass_attribute23              => l_asg_rec.ass_attribute23
851   ,p_ass_attribute24              => l_asg_rec.ass_attribute24
852   ,p_ass_attribute25              => l_asg_rec.ass_attribute25
853   ,p_ass_attribute26              => l_asg_rec.ass_attribute26
854   ,p_ass_attribute27              => l_asg_rec.ass_attribute27
855   ,p_ass_attribute28              => l_asg_rec.ass_attribute28
856   ,p_ass_attribute29              => l_asg_rec.ass_attribute29
857   ,p_ass_attribute30              => l_asg_rec.ass_attribute30
858   -- Hr Soft Coding KeyFlex segments
859   ,p_segment1                     => l_hr_soft_rec.segment1
860   ,p_segment2                     => l_hr_soft_rec.segment2
861   ,p_segment3                     => l_hr_soft_rec.segment3
862   ,p_segment4                     => l_hr_soft_rec.segment4
863   ,p_segment5                     => l_hr_soft_rec.segment5
864   ,p_segment6                     => l_hr_soft_rec.segment6
865   ,p_segment7                     => l_hr_soft_rec.segment7
866   ,p_segment8                     => l_hr_soft_rec.segment8
867   ,p_segment9                     => l_hr_soft_rec.segment9
868   ,p_segment10                    => l_hr_soft_rec.segment10
869   ,p_segment11                    => l_hr_soft_rec.segment11
870   ,p_segment12                    => l_hr_soft_rec.segment12
871   ,p_segment13                    => l_hr_soft_rec.segment13
872   ,p_segment14                    => l_hr_soft_rec.segment14
873   ,p_segment15                    => l_hr_soft_rec.segment15
874   ,p_segment16                    => l_hr_soft_rec.segment16
875   ,p_segment17                    => l_hr_soft_rec.segment17
876   ,p_segment18                    => l_hr_soft_rec.segment18
877   ,p_segment19                    => l_hr_soft_rec.segment19
878   ,p_segment20                    => l_hr_soft_rec.segment20
879   ,p_segment21                    => l_hr_soft_rec.segment21
880   ,p_segment22                    => l_hr_soft_rec.segment22
881   ,p_segment23                    => l_hr_soft_rec.segment23
882   ,p_segment24                    => l_hr_soft_rec.segment24
883   ,p_segment25                    => l_hr_soft_rec.segment25
884   ,p_segment26                    => l_hr_soft_rec.segment26
885   ,p_segment27                    => l_hr_soft_rec.segment27
886   ,p_segment28                    => l_hr_soft_rec.segment28
887   ,p_segment29                    => l_hr_soft_rec.segment29
888   ,p_segment30                    => l_hr_soft_rec.segment30
889   ,p_concat_segments              => l_hr_soft_rec.concatenated_segments
890   -- Out Parameters
891   ,p_cagr_grade_def_id            => l_asg_rec.cagr_grade_def_id
892   ,p_soft_coding_keyflex_id       => l_asg_rec.soft_coding_keyflex_id
893   ,p_cagr_concatenated_segments   => l_UpdEmpAsg_out.cagr_concatenated_segments
894   ,p_comment_id                   => l_UpdEmpAsg_out.comment_id
895   ,p_effective_start_date         => l_UpdEmpAsg_out.effective_start_date
896   ,p_effective_end_date           => l_UpdEmpAsg_out.effective_end_date
897   ,p_concatenated_segments        => l_UpdEmpAsg_out.concatenated_segments
898   ,p_no_managers_warning          => l_UpdEmpAsg_out.no_managers_warning
899   ,p_other_manager_warning        => l_UpdEmpAsg_out.other_manager_warning
900   ,p_hourly_salaried_warning      => l_UpdEmpAsg_out.hourly_salaried_warning
901   ,p_gsp_post_process_warning     => l_UpdEmpAsg_out.gsp_post_process_warning
902   );
903 
904 /*
905   ,p_contract_id                  =>
906   ,p_establishment_id             =>
907   ,p_collective_agreement_id      =>
908   ,p_cagr_id_flex_num             =>
909   ,p_cag_segment1                 =>
910   ,p_cag_segment2                 =>
911   ,p_cag_segment3                 =>
912   ,p_cag_segment4                 =>
913   ,p_cag_segment5                 =>
914   ,p_cag_segment6                 =>
915   ,p_cag_segment7                 =>
916   ,p_cag_segment8                 =>
917   ,p_cag_segment9                 =>
918   ,p_cag_segment10                =>
919   ,p_cag_segment11                =>
920   ,p_cag_segment12                =>
921   ,p_cag_segment13                =>
922   ,p_cag_segment14                =>
923   ,p_cag_segment15                =>
924   ,p_cag_segment16                =>
925   ,p_cag_segment17                =>
926   ,p_cag_segment18                =>
927   ,p_cag_segment19                =>
928   ,p_cag_segment20                =>
929   ,p_notice_period                =>
930   ,p_notice_period_uom            =>
931   ,p_employee_category            =>
932   ,p_work_at_home                 =>
933   ,p_job_post_source_name         =>
934   ,p_supervisor_assignment_id     =>
935 
936    -- Out Variables
937   ,p_cagr_grade_def_id
938 
939   ,p_concatenated_segments        => p_updasg_api_out.concatenated_segments
940   ,p_soft_coding_keyflex_id       => NVL(l_asg_rec.soft_coding_keyflex_id
941                                         ,l_cur_asg_rec.soft_coding_keyflex_id
942   ,p_cagr_concatenated_segments      OUT nocopy Varchar2
943   ,p_comment_id                   => p_updasg_api_out.comment_id
944   ,p_effective_start_date         => p_updasg_api_out.effective_start_date
945   ,p_effective_end_date           => p_updasg_api_out.effective_end_date
946   ,p_no_managers_warning          => p_updasg_api_out.no_managers_warning
947   ,p_other_manager_warning        => p_updasg_api_out.other_manager_warning
948   ,p_hourly_salaried_warning      => p_updasg_api_out.hourly_salaried_warning
949   ,p_gsp_post_process_warning     => p_updasg_api_out.gsp_post_process_warning
950   )*/
951 
952   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
953 
954 EXCEPTION
955   WHEN e_empasg_notfound  THEN
956    l_error_msg :=
957               'Employee Assignment could not be found as of the effective date';
958    hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
959    hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
960    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
961    hr_utility.raise_error;
962 
963   WHEN Others THEN
964    l_error_msg := SQLERRM;
965    hr_utility.set_location('SQLCODE :' || SQLCODE,100);
966    hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
967    hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
968    hr_utility.set_location('Leaving: ' || l_proc_name, 100);
969    hr_utility.raise_error;
970 
971 END Update_StuEmpAsg_Criteria;
972 
973 -- =============================================================================
974 -- ~ InsUpd_Address:
975 -- =============================================================================
976 PROCEDURE InsUpd_Address
977           (p_effective_date           IN Date
978           ,p_HR_address_id            OUT NOCOPY Number
979           ,p_HR_object_version_number OUT NOCOPY Number ) AS
980 
981   CURSOR csr_add (c_person_id         IN Number
982                  ,c_business_group_id IN Number
983                  ,c_effective_date    IN Date
984                  ,c_primary_flag      IN Varchar2) IS
985   SELECT *
986     FROM per_addresses pad
987    WHERE pad.person_id = c_person_id
988      AND pad.business_group_id = c_business_group_id
989      AND pad.primary_flag = c_primary_flag
990      AND c_effective_date BETWEEN pad.date_from
991                               AND NVL(pad.date_to, c_effective_date);
992   l_cur_add_rec            per_addresses%ROWTYPE;
993   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'InsUpd_Address';
994   l_error_msg              Varchar2(2000);
995 
996 BEGIN
997   hr_utility.set_location('Entering: ' || l_proc_name, 10);
998 
999   OPEN  csr_add(c_person_id         => l_add_rec.person_id
1000                ,c_business_group_id => l_add_rec.business_group_id
1001                ,c_effective_date    => p_effective_date
1002                ,c_primary_flag      => NVL(l_add_rec.primary_flag,'Y'));
1003   FETCH csr_add INTO l_cur_add_rec;
1004 
1005   IF csr_add%NOTFOUND THEN
1006      hr_utility.set_location(' Primary Address Not found', 20);
1007      Pqp_Hrtca_Integration.Person_Address_Api
1008      (p_HR_Address_Rec           => l_add_rec
1009      ,p_validate                 => FALSE
1010      ,p_action                   => 'CREATE'
1011      ,p_effective_date           => p_effective_date
1012      ,p_pradd_ovlapval_override  => FALSE
1013      ,p_primary_flag             => 'Y'
1014      ,p_validate_county          => TRUE
1015      ,p_HR_address_id            => l_add_rec.address_id
1016      ,p_HR_object_version_number => l_add_rec.object_version_number);
1017   ELSE
1018      hr_utility.set_location(' Primary Address found: ' ||
1019                                l_cur_add_rec.address_id, 30);
1020 
1021      IF Trunc(l_cur_add_rec.date_from) = Trunc(p_effective_date) THEN
1022         l_add_rec.address_id := l_cur_add_rec.address_id;
1023         l_add_rec.object_version_number := l_cur_add_rec.object_version_number;
1024         l_add_rec.style := l_cur_add_rec.style;
1025         Pqp_Hrtca_Integration.Person_Address_Api
1026         (p_HR_Address_Rec           => l_add_rec
1027         ,p_validate                 => FALSE
1028         ,p_action                   => 'UPDATE'
1029         ,p_effective_date           => p_effective_date
1030         ,p_pradd_ovlapval_override  => FALSE
1031         ,p_primary_flag             => 'Y'
1032         ,p_validate_county          => TRUE
1033         ,p_HR_address_id            => l_add_rec.address_id
1034         ,p_HR_object_version_number => l_add_rec.object_version_number);
1035 
1036      ELSIF Trunc(p_effective_date) > Trunc(l_cur_add_rec.date_from) THEN
1037         hr_utility.set_location(' l_add_rec.date_from: ' ||
1038 	                          l_add_rec.date_from, 40);
1039         hr_utility.set_location(' l_add_rec.date_to: ' ||
1040 	                          l_add_rec.date_to, 40);
1041         Pqp_Hrtca_Integration.Person_Address_Api
1042         (p_HR_Address_Rec           => l_add_rec
1043         ,p_validate                 => FALSE
1044         ,p_action                   => 'CREATE'
1045         ,p_effective_date           => p_effective_date
1046         ,p_pradd_ovlapval_override  => TRUE
1047         ,p_primary_flag             => 'Y'
1048         ,p_validate_county          => TRUE
1049         ,p_HR_address_id            => l_add_rec.address_id
1050         ,p_HR_object_version_number => l_add_rec.object_version_number);
1051      END IF;
1052   END IF;
1053   CLOSE csr_add;
1054 
1055   hr_utility.set_location('Leaving: ' || l_proc_name, 50);
1056 
1057 EXCEPTION
1058    WHEN Others THEN
1059    IF  csr_add%ISOPEN THEN
1060     CLOSE csr_add;
1061    END IF;
1062    l_error_msg := Substr(SQLERRM,1,2000);
1063    hr_utility.set_location('SQLCODE :' || SQLCODE,60);
1064    hr_utility.set_location('SQLERRM :' || SQLERRM,60);
1065    hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
1066    hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
1067    hr_utility.set_location('Leaving: ' || l_proc_name, 60);
1068    hr_utility.raise_error;
1069 
1070 END InsUpd_Address;
1071 
1072 -- =============================================================================
1073 -- ~ Hire_Applicant_IntoEmp:
1074 -- =============================================================================
1075 PROCEDURE Hire_Applicant_IntoEmp
1076          (p_validate            Boolean  DEFAULT FALSE
1077          ,p_hire_date           Date
1078          ,p_person_id           Number
1079          ,p_assignment_id       Number
1080          ,p_adjusted_svc_date   Date     DEFAULT NULL
1081          ,p_updper_api_out      OUT NOCOPY t_UpdEmp_Api
1082          ,p_HireAppapi_out      OUT NOCOPY t_HrApp_Api
1083          ) AS
1084 
1085   CURSOR csr_asg (c_person_id IN Number
1086                  ,c_business_group_id IN Number
1087                  ,c_effective_date IN DATE
1088                  ,c_asg_type IN Varchar2
1089                  ,c_assignment_id IN Number) IS
1090   SELECT paf.assignment_id
1091         ,ppf.person_id
1092         ,ppf.object_version_number per_ovn
1093         ,paf.object_version_number asg_ovn
1094     FROM per_all_assignments_f paf
1095         ,per_all_people_f      ppf
1096    WHERE paf.person_id = c_person_id
1097      AND paf.business_group_id = c_business_group_id
1098      AND paf.assignment_type = c_asg_type
1099      AND paf.assignment_id = c_assignment_id
1100      AND paf.person_id = ppf.person_id
1101      AND c_effective_date BETWEEN ppf.effective_start_date
1102                               AND ppf.effective_end_date
1103      AND c_effective_date BETWEEN paf.effective_start_date
1104                               AND paf.effective_end_date;
1105 
1106   l_perasg_rec             csr_asg%ROWTYPE;
1107   l_cur_per_rec            csr_per%ROWTYPE;
1108   l_accpetd_asg_rec        csr_accepted_asgs%ROWTYPE;
1109   l_asg_status_rec         csr_asg_status%ROWTYPE;
1110   l_datetrack_update_mode  Varchar2(50);
1111   l_dt_correction          Boolean;
1112   l_dt_update              Boolean;
1113   l_dt_upd_override        Boolean;
1114   l_upd_chg_ins            Boolean;
1115   l_error_msg              Varchar2(2000);
1116   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Hire_Applicant_IntoEmp';
1117   l_assignment_id          Number;
1118   l_appl_asg_start_date    Date;
1119   l_appl_asg_end_date      Date;
1120   l_accp_asg_count         Number;
1121   l_hire_all_accepted_asgs Varchar2(3);
1122   l_not_accp_asg_count     Number;
1123   l_tot_appl_asgs          Number;
1124   l_effective_date         Date;
1125   l_unaccepted_asg_del_warning Boolean;
1126 
1127 BEGIN
1128   hr_utility.set_location('Entering: ' || l_proc_name, 10);
1129 
1130   g_debug := hr_utility.debug_enabled;
1131   l_effective_date := p_hire_date;
1132 
1133   -- Get the person details for the person
1134   OPEN  csr_per(c_person_id         => l_per_rec.person_id
1135                ,c_business_group_id => l_per_rec.business_group_id
1136                ,c_effective_date    => l_effective_date);
1137   FETCH csr_per INTO l_cur_per_rec;
1138   CLOSE csr_per;
1139   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
1140 
1141   -- Get the Applicant assignment details
1142   OPEN  csr_asg (c_person_id         => l_per_rec.person_id
1143                 ,c_business_group_id => l_per_rec.business_group_id
1144                 ,c_effective_date    => l_effective_date
1145                 ,c_asg_type          => 'A'
1146                 ,c_assignment_id     => p_assignment_id);
1147   FETCH csr_asg INTO l_perasg_rec;
1148   CLOSE csr_asg;
1149 
1150   IF g_debug THEN
1151    hr_utility.set_location(' l_perasg_rec.person_id: ' ||
1152                              l_perasg_rec.person_id, 30);
1153    hr_utility.set_location(' l_perasg_rec.asg_id: ' ||
1154                              l_perasg_rec.assignment_id, 30);
1155    hr_utility.set_location(' l_perasg_rec.person_ovn: ' ||
1156                              l_perasg_rec.per_ovn, 30);
1157    hr_utility.set_location(' l_perasg_rec.asg_ovn: ' ||
1158                              l_perasg_rec.asg_ovn, 30);
1159    hr_utility.set_location(' l_effective_date: ' ||
1160                              l_effective_date, 30);
1161   END IF;
1162   l_accp_asg_count := 0;
1163   FOR accp_ags IN csr_accepted_asgs
1164                  (c_person_id         => l_per_rec.person_id
1165                  ,c_business_group_id => l_per_rec.business_group_id
1166                  ,c_effective_date    => l_effective_date
1167                  ,c_assignment_id     => p_assignment_id)
1168   LOOP
1169     l_accp_asg_count := l_accp_asg_count +1;
1170   END LOOP;
1171 
1172   IF l_accp_asg_count < 1 THEN
1173     -- Means the Applicant Assignment is not accepted, so update the applicant
1174     -- as accepted as of the hire date.
1175     hr_utility.set_location(' Asg Id NOT Accepted : ' || p_assignment_id, 40);
1176     Dt_Api.Find_DT_Upd_Modes
1177     (p_effective_date        => p_hire_date
1178     ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
1179     ,p_base_key_column       => 'ASSIGNMENT_ID'
1180     ,p_base_key_value        => p_assignment_id
1181     ,p_correction            => l_dt_correction
1182     ,p_update                => l_dt_update
1183     ,p_update_override       => l_dt_upd_override
1184     ,p_update_change_insert  => l_upd_chg_ins
1185      );
1186 
1187     -- Get the date-track mode
1188     IF l_dt_update THEN
1189        l_datetrack_update_mode := 'UPDATE';
1190     ELSIF l_dt_upd_override OR
1191           l_upd_chg_ins THEN
1192           -- Need to check if person has future asgs changes, if yes
1193           -- then raise error
1194           NULL;
1195     ELSE
1196        l_datetrack_update_mode := 'CORRECTION';
1197     END IF;
1198     hr_utility.set_location(' DT Mode for Update of Appl Asg : ' ||
1199                               l_datetrack_update_mode, 50);
1200 
1201     -- Get the Accepted Applicant Status Id
1202     OPEN csr_asg_status (c_leg_code          => g_leg_code
1203                         ,c_business_group_id => l_per_rec.business_group_id
1204                         );
1205     FETCH csr_asg_status INTO l_asg_status_rec;
1206     CLOSE csr_asg_status;
1207     hr_utility.set_location(' Accepted Asg Status ID: ' ||
1208                               l_asg_status_rec.assignment_status_type_id, 60);
1209 
1210     -- Now accept the Applicant assigment used to hire the person
1211     HR_Assignment_API.Accept_APL_Asg
1212     (p_validate                    => False
1213     ,p_effective_date              => l_effective_date-1
1214     ,p_datetrack_update_mode       => l_datetrack_update_mode
1215     ,p_assignment_id               => p_assignment_id
1216     ,p_object_version_number       => l_perasg_rec.asg_ovn
1217     ,p_assignment_status_type_id   => l_asg_status_rec.assignment_status_type_id
1218     ,p_change_reason               => Null
1219     ,p_effective_start_date        => l_appl_asg_start_date
1220     ,p_effective_end_date          => l_appl_asg_end_date
1221     );
1222     IF g_debug THEN
1223      hr_utility.set_location(' l_appl_asg_start_date: ' ||
1224                                l_appl_asg_start_date, 70);
1225      hr_utility.set_location(' l_appl_asg_end_date: ' ||
1226                                l_appl_asg_end_date, 70);
1227      hr_utility.set_location(' l_perasg_rec.asg_ovn: ' ||
1228                                l_perasg_rec.asg_ovn, 70);
1229     END IF;
1230 
1231     -- Get again the person details for the person
1232     OPEN  csr_per(c_person_id         => l_per_rec.person_id
1233                  ,c_business_group_id => l_per_rec.business_group_id
1234                  ,c_effective_date    => l_effective_date);
1235     FETCH csr_per INTO l_cur_per_rec;
1236     CLOSE csr_per;
1237     hr_utility.set_location(' per_rec.ovn: ' ||
1238                               l_cur_per_rec.object_version_number, 80);
1239   ELSE
1240     hr_utility.set_location(' Asg Id Accepted Already: ' ||
1241                               p_assignment_id, 90);
1242   END IF;
1243 
1244   -- Get the count of accepted Applicant Assignments
1245   l_accp_asg_count := 0;
1246   FOR accp_ags IN csr_accepted_asgs
1247                  (c_person_id         => l_per_rec.person_id
1248                  ,c_business_group_id => l_per_rec.business_group_id
1249                  ,c_effective_date    => l_effective_date
1250                  ,c_assignment_id     => Null)
1251   LOOP
1252     l_accp_asg_count := l_accp_asg_count +1;
1253   END LOOP;
1254 
1255   -- Get the count of not accepted Applicant Assignments
1256   l_not_accp_asg_count := 0;
1257   FOR accp_ags IN csr_not_accepted_asgs
1258                  (c_person_id         => l_per_rec.person_id
1259                  ,c_business_group_id => l_per_rec.business_group_id
1260                  ,c_effective_date    => l_effective_date
1261                  ,c_assignment_id     => Null)
1262   LOOP
1263     l_not_accp_asg_count := l_not_accp_asg_count +1;
1264   END LOOP;
1265   -- Get the total no. of Applicant assignments
1266   l_tot_appl_asgs := l_accp_asg_count + l_not_accp_asg_count;
1267 
1268   IF l_tot_appl_asgs = 1 THEN
1269      l_hire_all_accepted_asgs := 'Y';
1270   ELSIF l_tot_appl_asgs > 2 THEN
1271      l_hire_all_accepted_asgs := 'N';
1272   END IF;
1273 
1274   -- Now get the date-track mode to update the person as an employee
1275   Dt_Api.Find_DT_Upd_Modes
1276   (p_effective_date        => l_effective_date
1277   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
1278   ,p_base_key_column       => 'PERSON_ID'
1279   ,p_base_key_value        => l_cur_per_rec.person_id
1280   ,p_correction            => l_dt_correction
1281   ,p_update                => l_dt_update
1282   ,p_update_override       => l_dt_upd_override
1283   ,p_update_change_insert  => l_upd_chg_ins
1284    );
1285 
1286   -- If person has future changes, like becomes CWK, APL i.e. any person
1287   -- type changes then raise an error, saying that the person has future
1288   -- dated changes.
1289   IF l_dt_update THEN
1290      l_datetrack_update_mode := 'UPDATE';
1291   ELSIF l_dt_upd_override OR
1292         l_upd_chg_ins THEN
1293         -- Need to check if person type in future is EMP, APL or CWK , if yes
1294         -- then raise error
1295         NULL;
1296   ELSE
1297      l_datetrack_update_mode := 'CORRECTION';
1298   END IF;
1299 
1300   hr_utility.set_location(' l_datetrack_update_mode: ' ||
1301                             l_datetrack_update_mode, 100);
1302   l_per_rec.object_version_number := l_cur_per_rec.object_version_number;
1303   IF l_tot_appl_asgs = 1 THEN
1304      -- As the person has only one applicant assignment then hire person so that
1305      -- the person type now becomes EMP
1306      HR_Applicant_API.Hire_Applicant
1307      (p_validate                  => FALSE
1308      ,p_hire_date                 => l_effective_date
1309      ,p_person_id                 => l_cur_per_rec.person_id
1310      ,p_assignment_id             => p_assignment_id
1311      ,p_person_type_id            => l_per_rec.person_type_id
1312      ,p_per_object_version_number => l_cur_per_rec.object_version_number
1313      ,p_employee_number           => l_per_rec.employee_number
1314      ,p_per_effective_start_date  => p_HireAppapi_out.effective_start_date
1315      ,p_per_effective_end_date    => p_HireAppapi_out.effective_end_date
1316      ,p_unaccepted_asg_del_warning => l_unaccepted_asg_del_warning
1317      ,p_assign_payroll_warning    => p_HireAppapi_out.assign_payroll_warning
1318      ,p_original_date_of_hire     => NULL
1319      ,p_migrate                   => TRUE
1320      );
1321   ELSE
1322      -- Now hire the person ONLY for the accepted applicant assignment, so that
1323      -- person type would be EMP_APL
1324      HR_Employee_Applicant_API.Hire_to_Employee_Applicant
1325      (p_validate                  => FALSE
1326      ,p_hire_date                 => l_effective_date
1327      ,p_person_id                 => l_cur_per_rec.person_id
1328      ,p_per_object_version_number => l_cur_per_rec.object_version_number
1329      ,p_person_type_id            => l_per_rec.person_type_id
1330      ,p_hire_all_accepted_asgs    => l_hire_all_accepted_asgs
1331      ,p_assignment_id             => p_assignment_id
1332      ,p_national_identifier       => l_per_rec.national_identifier
1333      ,p_employee_number           => l_per_rec.employee_number
1334      ,p_per_effective_start_date  => p_HireAppapi_out.effective_start_date
1335      ,p_per_effective_end_date    => p_HireAppapi_out.effective_end_date
1336      ,p_assign_payroll_warning    => p_HireAppapi_out.assign_payroll_warning
1337      ,p_oversubscribed_vacancy_id => p_HireAppapi_out.oversubscribed_vacancy_id
1338      );
1339     END IF;
1340 
1341   -- Get the new employee assignment created after the person is hired
1342   OPEN  csr_asg (c_person_id         => l_cur_per_rec.person_id
1343                 ,c_business_group_id => l_per_rec.business_group_id
1344                 ,c_effective_date    => p_HireAppapi_out.effective_start_date
1345                 ,c_asg_type          => 'E'
1346                 ,c_assignment_id     => p_assignment_id);
1347   FETCH csr_asg INTO l_perasg_rec;
1348   CLOSE csr_asg;
1349   l_per_rec.object_version_number := l_perasg_rec.per_ovn;
1350 
1351   -- Get the person record after he is hired
1352   OPEN  csr_per(c_person_id         => l_per_rec.person_id
1353                ,c_business_group_id => l_per_rec.business_group_id
1354                ,c_effective_date    => l_effective_date);
1355   FETCH csr_per INTO l_cur_per_rec;
1356   CLOSE csr_per;
1357 
1358   IF g_debug_on THEN
1359     hr_utility.set_location('..effective_start_date      : ' ||
1360                              p_HireAppapi_out.effective_start_date, 110);
1361     hr_utility.set_location('..effective_end_date        : ' ||
1362                              p_HireAppapi_out.effective_end_date, 110);
1363     hr_utility.set_location('..Old:object_version_number : ' ||
1364                              l_cur_per_rec.object_version_number, 110);
1365   END IF;
1366   l_datetrack_update_mode := 'CORRECTION';
1367 
1368   Hr_Person_Api.Update_Person
1369   (p_validate                     => p_validate
1370   ,p_effective_date               => p_hire_date
1371   ,p_datetrack_update_mode        => l_datetrack_update_mode
1372   ,p_person_id                    => l_cur_per_rec.person_id
1373   ,p_party_id                     => l_per_rec.party_id
1374   ,p_object_version_number        => l_cur_per_rec.object_version_number
1375   ,p_employee_number              => l_per_rec.employee_number
1376   ,p_last_name                    => NVL(l_per_rec.last_name
1377                                         ,l_cur_per_rec.last_name)
1378   ,p_first_name                   => NVL(l_per_rec.first_name
1379                                         ,l_cur_per_rec.first_name)
1380   ,p_date_of_birth                => NVL(l_per_rec.date_of_birth
1381                                         ,l_cur_per_rec.date_of_birth)
1382   ,p_marital_status               => NVL(l_per_rec.marital_status
1383                                         ,l_cur_per_rec.marital_status)
1384   ,p_middle_names                 => NVL(l_per_rec.middle_names
1385                                         ,l_cur_per_rec.middle_names)
1386   ,p_sex                          => NVL(l_per_rec.sex
1387                                         ,l_cur_per_rec.sex)
1388   ,p_title                        => NVL(l_per_rec.title
1389                                         ,l_cur_per_rec.title)
1390   ,p_nationality                  => NVL(l_per_rec.nationality
1391                                         ,l_cur_per_rec.nationality)
1392   ,p_previous_last_name           => NVL(l_per_rec.previous_last_name
1393                                         ,l_cur_per_rec.previous_last_name)
1394   ,p_known_as                     => NVL(l_per_rec.known_as
1395                                         ,l_cur_per_rec.known_as)
1396   ,p_email_address                => NVL(l_per_rec.email_address
1397                                         ,l_cur_per_rec.email_address)
1398   ,p_registered_disabled_flag     => NVL(l_per_rec.registered_disabled_flag
1399                                         ,l_cur_per_rec.registered_disabled_flag)
1400   ,p_date_employee_data_verified  => NVL(l_per_rec.date_employee_data_verified
1401                                     ,l_cur_per_rec.date_employee_data_verified)
1402   ,p_expense_check_send_to_addres => NVL(l_per_rec.expense_check_send_to_address
1403                                    ,l_cur_per_rec.expense_check_send_to_address)
1404   ,p_per_information_category     => l_per_rec.per_information_category
1405   ,p_per_information1             => l_per_rec.per_information1
1406   ,p_per_information2             => l_per_rec.per_information2
1407   ,p_per_information3             => l_per_rec.per_information3
1408   ,p_per_information4             => l_per_rec.per_information4
1409   ,p_per_information5             => l_per_rec.per_information5
1410   ,p_per_information6             => l_per_rec.per_information6
1411   ,p_per_information7             => l_per_rec.per_information7
1412   ,p_per_information8             => l_per_rec.per_information8
1413   ,p_per_information9             => l_per_rec.per_information9
1414   ,p_per_information10            => l_per_rec.per_information10
1415   ,p_per_information11            => l_per_rec.per_information11
1416   ,p_per_information12            => l_per_rec.per_information12
1417   ,p_per_information13            => l_per_rec.per_information13
1418   ,p_per_information14            => l_per_rec.per_information14
1419   ,p_per_information15            => l_per_rec.per_information15
1420   ,p_per_information16            => l_per_rec.per_information16
1421   ,p_per_information17            => l_per_rec.per_information17
1422   ,p_per_information18            => l_per_rec.per_information18
1423   ,p_per_information19            => l_per_rec.per_information19
1424   ,p_per_information20            => l_per_rec.per_information20
1425   ,p_per_information21            => l_per_rec.per_information21
1426   ,p_per_information22            => l_per_rec.per_information22
1427   ,p_per_information23            => l_per_rec.per_information23
1428   ,p_per_information24            => l_per_rec.per_information24
1429   ,p_per_information25            => l_per_rec.per_information25
1430   ,p_per_information26            => l_per_rec.per_information26
1431   ,p_per_information27            => l_per_rec.per_information27
1432   ,p_per_information28            => l_per_rec.per_information28
1433   ,p_per_information29            => l_per_rec.per_information29
1434   ,p_per_information30            => l_per_rec.per_information30
1435   -- Person DF
1436   ,p_attribute_category           => l_per_rec.attribute_category
1437   ,p_attribute1                   => l_per_rec.attribute1
1438   ,p_attribute2                   => l_per_rec.attribute2
1439   ,p_attribute3                   => l_per_rec.attribute3
1440   ,p_attribute4                   => l_per_rec.attribute4
1441   ,p_attribute5                   => l_per_rec.attribute5
1442   ,p_attribute6                   => l_per_rec.attribute6
1443   ,p_attribute7                   => l_per_rec.attribute7
1444   ,p_attribute8                   => l_per_rec.attribute8
1445   ,p_attribute9                   => l_per_rec.attribute9
1446   ,p_attribute10                  => l_per_rec.attribute10
1447   ,p_attribute11                  => l_per_rec.attribute11
1448   ,p_attribute12                  => l_per_rec.attribute12
1449   ,p_attribute13                  => l_per_rec.attribute13
1450   ,p_attribute14                  => l_per_rec.attribute14
1451   ,p_attribute15                  => l_per_rec.attribute15
1452   ,p_attribute16                  => l_per_rec.attribute16
1453   ,p_attribute17                  => l_per_rec.attribute17
1454   ,p_attribute18                  => l_per_rec.attribute18
1455   ,p_attribute19                  => l_per_rec.attribute19
1456   ,p_attribute20                  => l_per_rec.attribute20
1457   ,p_attribute21                  => l_per_rec.attribute21
1458   ,p_attribute22                  => l_per_rec.attribute22
1459   ,p_attribute23                  => l_per_rec.attribute23
1460   ,p_attribute24                  => l_per_rec.attribute24
1461   ,p_attribute25                  => l_per_rec.attribute25
1462   ,p_attribute26                  => l_per_rec.attribute26
1463   ,p_attribute27                  => l_per_rec.attribute27
1464   ,p_attribute28                  => l_per_rec.attribute28
1465   ,p_attribute29                  => l_per_rec.attribute29
1466   ,p_attribute30                  => l_per_rec.attribute30
1467   ,p_date_of_death                => NVL(l_per_rec.date_of_death
1468                                         ,l_cur_per_rec.date_of_death)
1469   ,p_background_check_status      => NVL(l_per_rec.background_check_status
1470                                         ,l_cur_per_rec.background_check_status)
1471   ,p_background_date_check        => NVL(l_per_rec.background_date_check
1472                                         ,l_cur_per_rec.background_date_check)
1473   ,p_blood_type                   => NVL(l_per_rec.blood_type
1474                                         ,l_cur_per_rec.blood_type)
1475   ,p_correspondence_language      => NVL(l_per_rec.correspondence_language
1476                                         ,l_cur_per_rec.correspondence_language)
1477   ,p_fte_capacity                 => NVL(l_per_rec.fte_capacity
1478                                         ,l_cur_per_rec.fte_capacity)
1479   ,p_hold_applicant_date_until    => NVL(l_per_rec.hold_applicant_date_until
1480                                     ,l_cur_per_rec.hold_applicant_date_until)
1481   ,p_honors                       => NVL(l_per_rec.honors
1482                                         ,l_cur_per_rec.honors)
1483   ,p_internal_location            => NVL(l_per_rec.internal_location
1484                                         ,l_cur_per_rec.internal_location)
1485   ,p_last_medical_test_by         => NVL(l_per_rec.last_medical_test_by
1486                                         ,l_cur_per_rec.last_medical_test_by)
1487   ,p_last_medical_test_date       => NVL(l_per_rec.last_medical_test_date
1488                                         ,l_cur_per_rec.last_medical_test_date)
1489   ,p_mailstop                     => NVL(l_per_rec.mailstop
1490                                         ,l_cur_per_rec.mailstop)
1491   ,p_office_number                => NVL(l_per_rec.office_number
1492                                         ,l_cur_per_rec.office_number)
1493   ,p_on_military_service          => NVL(l_per_rec.on_military_service
1494                                         ,l_cur_per_rec.on_military_service)
1495   ,p_pre_name_adjunct             => NVL(l_per_rec.pre_name_adjunct
1496                                         ,l_cur_per_rec.pre_name_adjunct)
1497   ,p_projected_start_date         => NVL(l_per_rec.projected_start_date
1498                                         ,l_cur_per_rec.projected_start_date)
1499   ,p_rehire_authorizor            => NVL(l_per_rec.rehire_authorizor
1500                                         ,l_cur_per_rec.rehire_authorizor)
1501   ,p_rehire_recommendation        => NVL(l_per_rec.rehire_recommendation
1502                                         ,l_cur_per_rec.rehire_recommendation)
1503   ,p_resume_exists                => NVL(l_per_rec.resume_exists
1504                                         ,l_cur_per_rec.resume_exists )
1505   ,p_resume_last_updated          => NVL(l_per_rec.resume_last_updated
1506                                         ,l_cur_per_rec.resume_last_updated)
1507   ,p_second_passport_exists       => NVL(l_per_rec.second_passport_exists
1508                                         ,l_cur_per_rec.second_passport_exists)
1509   ,p_student_status               => NVL(l_per_rec.student_status
1510                                         ,l_cur_per_rec.student_status)
1511   ,p_work_schedule                => NVL(l_per_rec.work_schedule
1512                                         ,l_cur_per_rec.work_schedule)
1513   ,p_rehire_reason                => NVL(l_per_rec.rehire_reason
1514                                         ,l_cur_per_rec.rehire_reason)
1515   ,p_suffix                       => NVL(l_per_rec.suffix
1516                                         ,l_cur_per_rec.suffix)
1517   ,p_benefit_group_id             => NVL(l_per_rec.benefit_group_id
1518                                         ,l_cur_per_rec.benefit_group_id)
1519   ,p_receipt_of_death_cert_date   => NVL(l_per_rec.receipt_of_death_cert_date
1520                                     ,l_cur_per_rec.receipt_of_death_cert_date)
1521   ,p_coord_ben_med_pln_no         => NVL(l_per_rec.coord_ben_med_pln_no
1522                                         ,l_cur_per_rec.coord_ben_med_pln_no)
1523   ,p_coord_ben_no_cvg_flag        => NVL(l_per_rec.coord_ben_no_cvg_flag
1524                                         ,l_cur_per_rec.coord_ben_no_cvg_flag)
1525   ,p_coord_ben_med_ext_er         => NVL(l_per_rec.coord_ben_med_ext_er
1526                                         ,l_cur_per_rec.coord_ben_med_ext_er)
1527   ,p_coord_ben_med_pl_name        => NVL(l_per_rec.coord_ben_med_pl_name
1528                                         ,l_cur_per_rec.coord_ben_med_pl_name)
1529   ,p_coord_ben_med_insr_crr_name  => NVL(l_per_rec.coord_ben_med_insr_crr_name
1530                                     ,l_cur_per_rec.coord_ben_med_insr_crr_name)
1531   ,p_coord_ben_med_insr_crr_ident => NVL(l_per_rec.coord_ben_med_insr_crr_ident
1532                                     ,l_cur_per_rec.coord_ben_med_insr_crr_ident)
1533   ,p_coord_ben_med_cvg_strt_dt    => NVL(l_per_rec.coord_ben_med_cvg_strt_dt
1534                                     ,l_cur_per_rec.coord_ben_med_cvg_strt_dt)
1535   ,p_coord_ben_med_cvg_end_dt     => NVL(l_per_rec.coord_ben_med_cvg_end_dt
1536                                     ,l_cur_per_rec.coord_ben_med_cvg_end_dt)
1537   ,p_uses_tobacco_flag            => NVL(l_per_rec.uses_tobacco_flag
1538                                         ,l_cur_per_rec.uses_tobacco_flag)
1539   ,p_dpdnt_adoption_date          => NVL(l_per_rec.dpdnt_adoption_date
1540                                         ,l_cur_per_rec.dpdnt_adoption_date)
1541   ,p_dpdnt_vlntry_svce_flag       => NVL(l_per_rec.dpdnt_vlntry_svce_flag
1542                                         ,l_cur_per_rec.dpdnt_vlntry_svce_flag)
1543   ,p_original_date_of_hire        => NVL(l_per_rec.original_date_of_hire
1544                                         ,l_cur_per_rec.original_date_of_hire)
1545   ,p_adjusted_svc_date            => p_adjusted_svc_date
1546   ,p_town_of_birth                => NVL(l_per_rec.town_of_birth
1547                                         ,l_cur_per_rec.town_of_birth)
1548   ,p_region_of_birth              => NVL(l_per_rec.region_of_birth
1549                                         ,l_cur_per_rec.region_of_birth)
1550   ,p_country_of_birth             => NVL(l_per_rec.country_of_birth
1551                                         ,l_cur_per_rec.country_of_birth)
1552   ,p_global_person_id             => NVL(l_per_rec.global_person_id
1553                                         ,l_cur_per_rec.global_person_id)
1554   --Out Variables
1555   ,p_effective_start_date         => p_updper_api_out.effective_start_date
1556   ,p_effective_end_date           => p_updper_api_out.effective_end_date
1557   ,p_full_name                    => p_updper_api_out.full_name
1558   ,p_comment_id                   => p_updper_api_out.comment_id
1559   ,p_name_combination_warning     => p_updper_api_out.name_combination_warning
1560   ,p_assign_payroll_warning       => p_updper_api_out.assign_payroll_warning
1561   ,p_orig_hire_warning            => p_updper_api_out.orig_hire_warning
1562   );
1563 
1564   IF g_debug_on THEN
1565     hr_utility.set_location('..effective_start_date : ' ||
1566                              p_updper_api_out.effective_start_date, 120);
1567     hr_utility.set_location('..effective_end_date   : ' ||
1568                              p_updper_api_out.effective_end_date, 120);
1569     hr_utility.set_location('..full_name            : ' ||
1570                              p_updper_api_out.full_name, 120);
1571     hr_utility.set_location('Leaving: ' || l_proc_name, 120);
1572   END IF;
1573 
1574 EXCEPTION
1575   WHEN Others THEN
1576     IF csr_asg%ISOPEN THEN
1577       CLOSE csr_asg;
1578     END IF;
1579     IF csr_per%ISOPEN THEN
1580       CLOSE csr_per;
1581     END IF;
1582     IF csr_asg_status%ISOPEN THEN
1583       CLOSE csr_asg_status;
1584     END IF;
1585     l_error_msg := Substr(SQLERRM,1,2000);
1586     hr_utility.set_location('SQLCODE :' || SQLCODE, 130);
1587     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
1588     hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
1589     hr_utility.set_location('Leaving: ' || l_proc_name, 130);
1590     hr_utility.raise_error;
1591 
1592 END Hire_Applicant_IntoEmp;
1593 
1594 -- =============================================================================
1595 -- ~ Hire_Person_IntoEmp:
1596 -- =============================================================================
1597 PROCEDURE Hire_Person_IntoEmp
1598          (p_validate            Boolean  DEFAULT FALSE
1599          ,p_hire_date           Date
1600          ,p_person_id           Number
1601          ,p_adjusted_svc_date   Date     DEFAULT NULL
1602          ,p_updper_api_out      OUT NOCOPY t_UpdEmp_Api
1603          ,p_HireToJobapi_out    OUT NOCOPY t_HrToJob_Api
1604          ) AS
1605   CURSOR csr_asg (c_person_id IN Number
1606                  ,c_business_group_id IN Number
1607                  ,c_effective_date IN Date) IS
1608   SELECT paf.assignment_id,
1609          ppf.object_version_number
1610     FROM per_all_assignments_f paf
1611         ,per_all_people_f      ppf
1612    WHERE paf.person_id = c_person_id
1613      AND paf.business_group_id = c_business_group_id
1614      AND paf.person_id = ppf.person_id
1615      AND paf.assignment_type = 'E'
1616      AND c_effective_date BETWEEN ppf.effective_start_date
1617                               AND ppf.effective_end_date
1618      AND c_effective_date BETWEEN paf.effective_start_date
1619                               AND paf.effective_end_date;
1620 
1621   l_cur_per_rec            csr_per%ROWTYPE;
1622   l_ptu_rec                chk_perType_usage%ROWTYPE;
1623   l_datetrack_update_mode  Varchar2(50);
1624   l_dt_correction          Boolean;
1625   l_dt_update              Boolean;
1626   l_dt_upd_override        Boolean;
1627   l_upd_chg_ins            Boolean;
1628   l_error_msg              Varchar2(2000);
1629   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Hire_Person_IntoEmp';
1630   e_future_chgs_exists     Exception;
1631 BEGIN
1632   hr_utility.set_location('Entering: ' || l_proc_name, 10);
1633 
1634   OPEN  csr_per(c_person_id         => l_per_rec.person_id
1635                ,c_business_group_id => l_per_rec.business_group_id
1636                ,c_effective_date    => p_hire_date);
1637   FETCH csr_per INTO l_cur_per_rec;
1638   CLOSE csr_per;
1639   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
1640 
1641   Dt_Api.Find_DT_Upd_Modes
1642   (p_effective_date        => p_hire_date
1643   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
1644   ,p_base_key_column       => 'PERSON_ID'
1645   ,p_base_key_value        => l_cur_per_rec.person_id
1646   ,p_correction            => l_dt_correction
1647   ,p_update                => l_dt_update
1648   ,p_update_override       => l_dt_upd_override
1649   ,p_update_change_insert  => l_upd_chg_ins
1650    );
1651 
1652   IF l_dt_update THEN
1653      l_datetrack_update_mode := 'UPDATE';
1654   ELSIF l_dt_upd_override OR
1655         l_upd_chg_ins THEN
1656         -- Need to check if person type in future is EMP, APL or CWK , if yes
1657         -- then raise error
1658         OPEN chk_perType_usage
1659            (c_person_id         => l_cur_per_rec.person_id
1660            ,c_effective_date    => p_hire_date
1661            ,c_business_group_id => l_per_rec.business_group_id);
1662         FETCH chk_perType_usage INTO l_ptu_rec;
1663         IF chk_perType_usage%FOUND THEN
1664            Close chk_perType_usage;
1665            RAISE e_future_chgs_exists;
1666         END IF;
1667         Close chk_perType_usage;
1668   ELSE
1669      l_datetrack_update_mode := 'CORRECTION';
1670   END IF;
1671 
1672   hr_utility.set_location('l_datetrack_update_mode: ' ||
1673                            l_datetrack_update_mode, 30);
1674   l_per_rec.object_version_number := l_cur_per_rec.object_version_number;
1675 
1676   Hr_Employee_Api.Hire_Into_Job
1677   (p_validate               => FALSE
1678   ,p_effective_date         => p_hire_date
1679   ,p_person_id              => l_cur_per_rec.person_id
1680   ,p_object_version_number  => l_cur_per_rec.object_version_number
1681   ,p_employee_number        => l_per_rec.employee_number
1682   ,p_datetrack_update_mode  => l_datetrack_update_mode
1683   ,p_person_type_id         => l_per_rec.person_type_id
1684   ,p_national_identifier    => l_per_rec.national_identifier
1685   ,p_per_information7       => l_per_rec.per_information7
1686   -- Out Variables
1687   ,p_effective_start_date   => p_HireToJobapi_out.effective_start_date
1688   ,p_effective_end_date     => p_HireToJobapi_out.effective_end_date
1689   ,p_assign_payroll_warning => p_HireToJobapi_out.assign_payroll_warning
1690   ,p_orig_hire_warning      => p_HireToJobapi_out.orig_hire_warning
1691   );
1692   -- Get the new assignment created after the person is hired
1693   OPEN  csr_asg (c_person_id         => l_cur_per_rec.person_id
1694                 ,c_business_group_id => l_per_rec.business_group_id
1695                 ,c_effective_date    =>p_HireToJobapi_out.effective_start_date);
1696   FETCH csr_asg INTO p_HireToJobapi_out.assignment_id
1697                     ,l_per_rec.object_version_number;
1698   CLOSE csr_asg;
1699   -- Get the person record after he is hired
1700   OPEN  csr_per(c_person_id         => l_per_rec.person_id
1701                ,c_business_group_id => l_per_rec.business_group_id
1702                ,c_effective_date    => p_hire_date);
1703   FETCH csr_per INTO l_cur_per_rec;
1704   CLOSE csr_per;
1705 
1706   IF g_debug_on THEN
1707     hr_utility.set_location('..effective_start_date      : ' ||
1708                              p_HireToJobapi_out.effective_start_date,40);
1709     hr_utility.set_location('..effective_end_date        : ' ||
1710                              p_HireToJobapi_out.effective_end_date,40);
1711     hr_utility.set_location('..New:object_version_number : ' ||
1712                              l_per_rec.object_version_number,40);
1713     hr_utility.set_location('..Old:object_version_number : ' ||
1714                              l_cur_per_rec.object_version_number,40);
1715     hr_utility.set_location('..New:Assignment Id         : ' ||
1716                              p_HireToJobapi_out.assignment_id,40);
1717   END IF;
1718   l_datetrack_update_mode := 'CORRECTION';
1719 
1720   Hr_Person_Api.Update_Person
1721   (p_validate                     => p_validate
1722   ,p_effective_date               => p_hire_date
1723   ,p_datetrack_update_mode        => l_datetrack_update_mode
1724   ,p_person_id                    => l_cur_per_rec.person_id
1725   ,p_party_id                     => l_per_rec.party_id
1726   ,p_object_version_number        => l_per_rec.object_version_number
1727   ,p_employee_number              => l_per_rec.employee_number
1728   ,p_last_name                    => NVL(l_per_rec.last_name
1729                                         ,l_cur_per_rec.last_name)
1730   ,p_first_name                   => NVL(l_per_rec.first_name
1731                                         ,l_cur_per_rec.first_name)
1732   ,p_date_of_birth                => NVL(l_per_rec.date_of_birth
1733                                         ,l_cur_per_rec.date_of_birth)
1734   ,p_marital_status               => NVL(l_per_rec.marital_status
1735                                         ,l_cur_per_rec.marital_status)
1736   ,p_middle_names                 => NVL(l_per_rec.middle_names
1737                                         ,l_cur_per_rec.middle_names)
1738   ,p_sex                          => NVL(l_per_rec.sex
1739                                         ,l_cur_per_rec.sex)
1740   ,p_title                        => NVL(l_per_rec.title
1741                                         ,l_cur_per_rec.title)
1742   ,p_nationality                  => NVL(l_per_rec.nationality
1743                                         ,l_cur_per_rec.nationality)
1744   ,p_previous_last_name           => NVL(l_per_rec.previous_last_name
1745                                         ,l_cur_per_rec.previous_last_name)
1746   ,p_known_as                     => NVL(l_per_rec.known_as
1747                                         ,l_cur_per_rec.known_as)
1748   ,p_email_address                => NVL(l_per_rec.email_address
1749                                         ,l_cur_per_rec.email_address)
1750   ,p_registered_disabled_flag     => NVL(l_per_rec.registered_disabled_flag
1751                                     ,l_cur_per_rec.registered_disabled_flag)
1752   ,p_date_employee_data_verified  => NVL(l_per_rec.date_employee_data_verified
1753                                     ,l_cur_per_rec.date_employee_data_verified)
1754   ,p_expense_check_send_to_addres =>NVL(l_per_rec.expense_check_send_to_address
1755                                    ,l_cur_per_rec.expense_check_send_to_address)
1756   ,p_per_information_category     => l_per_rec.per_information_category
1757   ,p_per_information1             => l_per_rec.per_information1
1758   ,p_per_information2             => l_per_rec.per_information2
1759   ,p_per_information3             => l_per_rec.per_information3
1760   ,p_per_information4             => l_per_rec.per_information4
1761   ,p_per_information5             => l_per_rec.per_information5
1762   ,p_per_information6             => l_per_rec.per_information6
1763   ,p_per_information7             => l_per_rec.per_information7
1764   ,p_per_information8             => l_per_rec.per_information8
1765   ,p_per_information9             => l_per_rec.per_information9
1766   ,p_per_information10            => l_per_rec.per_information10
1767   ,p_per_information11            => l_per_rec.per_information11
1768   ,p_per_information12            => l_per_rec.per_information12
1769   ,p_per_information13            => l_per_rec.per_information13
1770   ,p_per_information14            => l_per_rec.per_information14
1771   ,p_per_information15            => l_per_rec.per_information15
1772   ,p_per_information16            => l_per_rec.per_information16
1773   ,p_per_information17            => l_per_rec.per_information17
1774   ,p_per_information18            => l_per_rec.per_information18
1775   ,p_per_information19            => l_per_rec.per_information19
1776   ,p_per_information20            => l_per_rec.per_information20
1777   ,p_per_information21            => l_per_rec.per_information21
1778   ,p_per_information22            => l_per_rec.per_information22
1779   ,p_per_information23            => l_per_rec.per_information23
1780   ,p_per_information24            => l_per_rec.per_information24
1781   ,p_per_information25            => l_per_rec.per_information25
1782   ,p_per_information26            => l_per_rec.per_information26
1783   ,p_per_information27            => l_per_rec.per_information27
1784   ,p_per_information28            => l_per_rec.per_information28
1785   ,p_per_information29            => l_per_rec.per_information29
1786   ,p_per_information30            => l_per_rec.per_information30
1787   -- Person DF
1788   ,p_attribute_category           => l_per_rec.attribute_category
1789   ,p_attribute1                   => l_per_rec.attribute1
1790   ,p_attribute2                   => l_per_rec.attribute2
1791   ,p_attribute3                   => l_per_rec.attribute3
1792   ,p_attribute4                   => l_per_rec.attribute4
1793   ,p_attribute5                   => l_per_rec.attribute5
1794   ,p_attribute6                   => l_per_rec.attribute6
1795   ,p_attribute7                   => l_per_rec.attribute7
1796   ,p_attribute8                   => l_per_rec.attribute8
1797   ,p_attribute9                   => l_per_rec.attribute9
1798   ,p_attribute10                  => l_per_rec.attribute10
1799   ,p_attribute11                  => l_per_rec.attribute11
1800   ,p_attribute12                  => l_per_rec.attribute12
1801   ,p_attribute13                  => l_per_rec.attribute13
1802   ,p_attribute14                  => l_per_rec.attribute14
1803   ,p_attribute15                  => l_per_rec.attribute15
1804   ,p_attribute16                  => l_per_rec.attribute16
1805   ,p_attribute17                  => l_per_rec.attribute17
1806   ,p_attribute18                  => l_per_rec.attribute18
1807   ,p_attribute19                  => l_per_rec.attribute19
1808   ,p_attribute20                  => l_per_rec.attribute20
1809   ,p_attribute21                  => l_per_rec.attribute21
1810   ,p_attribute22                  => l_per_rec.attribute22
1811   ,p_attribute23                  => l_per_rec.attribute23
1812   ,p_attribute24                  => l_per_rec.attribute24
1813   ,p_attribute25                  => l_per_rec.attribute25
1814   ,p_attribute26                  => l_per_rec.attribute26
1815   ,p_attribute27                  => l_per_rec.attribute27
1816   ,p_attribute28                  => l_per_rec.attribute28
1817   ,p_attribute29                  => l_per_rec.attribute29
1818   ,p_attribute30                  => l_per_rec.attribute30
1819   ,p_date_of_death                => NVL(l_per_rec.date_of_death
1820                                         ,l_cur_per_rec.date_of_death)
1821   ,p_background_check_status      => NVL(l_per_rec.background_check_status
1822                                         ,l_cur_per_rec.background_check_status)
1823   ,p_background_date_check        => NVL(l_per_rec.background_date_check
1824                                         ,l_cur_per_rec.background_date_check)
1825   ,p_blood_type                   => NVL(l_per_rec.blood_type
1826                                         ,l_cur_per_rec.blood_type)
1827   ,p_correspondence_language      => NVL(l_per_rec.correspondence_language
1828                                         ,l_cur_per_rec.correspondence_language)
1829   ,p_fte_capacity                 => NVL(l_per_rec.fte_capacity
1830                                         ,l_cur_per_rec.fte_capacity)
1831   ,p_hold_applicant_date_until    => NVL(l_per_rec.hold_applicant_date_until
1832                                        ,l_cur_per_rec.hold_applicant_date_until)
1833   ,p_honors                       => NVL(l_per_rec.honors
1834                                         ,l_cur_per_rec.honors)
1835   ,p_internal_location            => NVL(l_per_rec.internal_location
1836                                         ,l_cur_per_rec.internal_location)
1837   ,p_last_medical_test_by         => NVL(l_per_rec.last_medical_test_by
1838                                         ,l_cur_per_rec.last_medical_test_by)
1839   ,p_last_medical_test_date       => NVL(l_per_rec.last_medical_test_date
1840                                         ,l_cur_per_rec.last_medical_test_date)
1841   ,p_mailstop                     => NVL(l_per_rec.mailstop
1842                                         ,l_cur_per_rec.mailstop)
1843   ,p_office_number                => NVL(l_per_rec.office_number
1844                                         ,l_cur_per_rec.office_number)
1845   ,p_on_military_service          => NVL(l_per_rec.on_military_service
1846                                         ,l_cur_per_rec.on_military_service)
1847   ,p_pre_name_adjunct             => NVL(l_per_rec.pre_name_adjunct
1848                                         ,l_cur_per_rec.pre_name_adjunct)
1849   ,p_projected_start_date         => NVL(l_per_rec.projected_start_date
1850                                         ,l_cur_per_rec.projected_start_date)
1851   ,p_rehire_authorizor            => NVL(l_per_rec.rehire_authorizor
1852                                         ,l_cur_per_rec.rehire_authorizor)
1853   ,p_rehire_recommendation        => NVL(l_per_rec.rehire_recommendation
1854                                         ,l_cur_per_rec.rehire_recommendation)
1855   ,p_resume_exists                => NVL(l_per_rec.resume_exists
1856                                         ,l_cur_per_rec.resume_exists )
1857   ,p_resume_last_updated          => NVL(l_per_rec.resume_last_updated
1858                                         ,l_cur_per_rec.resume_last_updated)
1859   ,p_second_passport_exists       => NVL(l_per_rec.second_passport_exists
1860                                         ,l_cur_per_rec.second_passport_exists)
1861   ,p_student_status               => NVL(l_per_rec.student_status
1862                                         ,l_cur_per_rec.student_status)
1863   ,p_work_schedule                => NVL(l_per_rec.work_schedule
1864                                         ,l_cur_per_rec.work_schedule)
1865   ,p_rehire_reason                => NVL(l_per_rec.rehire_reason
1866                                         ,l_cur_per_rec.rehire_reason)
1867   ,p_suffix                       => NVL(l_per_rec.suffix
1868                                         ,l_cur_per_rec.suffix)
1869   ,p_benefit_group_id             => NVL(l_per_rec.benefit_group_id
1870                                         ,l_cur_per_rec.benefit_group_id)
1871   ,p_receipt_of_death_cert_date   => NVL(l_per_rec.receipt_of_death_cert_date
1872                                       ,l_cur_per_rec.receipt_of_death_cert_date)
1873   ,p_coord_ben_med_pln_no         => NVL(l_per_rec.coord_ben_med_pln_no
1874                                         ,l_cur_per_rec.coord_ben_med_pln_no)
1875   ,p_coord_ben_no_cvg_flag        => NVL(l_per_rec.coord_ben_no_cvg_flag
1876                                         ,l_cur_per_rec.coord_ben_no_cvg_flag)
1877   ,p_coord_ben_med_ext_er         => NVL(l_per_rec.coord_ben_med_ext_er
1878                                         ,l_cur_per_rec.coord_ben_med_ext_er)
1879   ,p_coord_ben_med_pl_name        => NVL(l_per_rec.coord_ben_med_pl_name
1880                                         ,l_cur_per_rec.coord_ben_med_pl_name)
1881   ,p_coord_ben_med_insr_crr_name  => NVL(l_per_rec.coord_ben_med_insr_crr_name
1882                                      ,l_cur_per_rec.coord_ben_med_insr_crr_name)
1883   ,p_coord_ben_med_insr_crr_ident => NVL(l_per_rec.coord_ben_med_insr_crr_ident
1884                                     ,l_cur_per_rec.coord_ben_med_insr_crr_ident)
1885   ,p_coord_ben_med_cvg_strt_dt    => NVL(l_per_rec.coord_ben_med_cvg_strt_dt
1886                                        ,l_cur_per_rec.coord_ben_med_cvg_strt_dt)
1887   ,p_coord_ben_med_cvg_end_dt     => NVL(l_per_rec.coord_ben_med_cvg_end_dt
1888                                         ,l_cur_per_rec.coord_ben_med_cvg_end_dt)
1889   ,p_uses_tobacco_flag            => NVL(l_per_rec.uses_tobacco_flag
1890                                         ,l_cur_per_rec.uses_tobacco_flag)
1891   ,p_dpdnt_adoption_date          => NVL(l_per_rec.dpdnt_adoption_date
1892                                         ,l_cur_per_rec.dpdnt_adoption_date)
1893   ,p_dpdnt_vlntry_svce_flag       => NVL(l_per_rec.dpdnt_vlntry_svce_flag
1894                                         ,l_cur_per_rec.dpdnt_vlntry_svce_flag)
1895   ,p_original_date_of_hire        => NVL(l_per_rec.original_date_of_hire
1896                                         ,l_cur_per_rec.original_date_of_hire)
1897   ,p_adjusted_svc_date            => p_adjusted_svc_date
1898   ,p_town_of_birth                => NVL(l_per_rec.town_of_birth
1899                                         ,l_cur_per_rec.town_of_birth)
1900   ,p_region_of_birth              => NVL(l_per_rec.region_of_birth
1901                                         ,l_cur_per_rec.region_of_birth)
1902   ,p_country_of_birth             => NVL(l_per_rec.country_of_birth
1903                                         ,l_cur_per_rec.country_of_birth)
1904   ,p_global_person_id             => NVL(l_per_rec.global_person_id
1905                                         ,l_cur_per_rec.global_person_id)
1906   --Out Variables
1907   ,p_effective_start_date         => p_updper_api_out.effective_start_date
1908   ,p_effective_end_date           => p_updper_api_out.effective_end_date
1909   ,p_full_name                    => p_updper_api_out.full_name
1910   ,p_comment_id                   => p_updper_api_out.comment_id
1911   ,p_name_combination_warning     => p_updper_api_out.name_combination_warning
1912   ,p_assign_payroll_warning       => p_updper_api_out.assign_payroll_warning
1913   ,p_orig_hire_warning            => p_updper_api_out.orig_hire_warning
1914   );
1915   IF g_debug_on THEN
1916     hr_utility.set_location('..effective_start_date : ' ||
1917                              p_updper_api_out.effective_start_date, 50);
1918     hr_utility.set_location('..effective_end_date   : ' ||
1919                              p_updper_api_out.effective_end_date, 50);
1920     hr_utility.set_location('..full_name            : ' ||
1921                              p_updper_api_out.full_name, 50);
1922     hr_utility.set_location('Leaving: ' || l_proc_name, 50);
1923   END IF;
1924 
1925 EXCEPTION
1926   WHEN e_future_chgs_exists THEN
1927     l_error_msg := 'This person cannot be created in HRMS as a Student '||
1928                    'Employee due to future changes beyond the date: '||p_hire_date;
1929 
1930     hr_utility.set_location('..Future Update exists for the Student Employee', 60);
1931     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
1932     hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
1933     hr_utility.set_location('Leaving: ' || l_proc_name, 60);
1934     hr_utility.raise_error;
1935 
1936   WHEN Others THEN
1937    IF csr_asg%ISOPEN THEN
1938      CLOSE csr_asg;
1939    END IF;
1940    IF csr_per%ISOPEN THEN
1941      CLOSE csr_per;
1942    END IF;
1943    l_error_msg := Substr(SQLERRM,1,2000);
1944    hr_utility.set_location('SQLCODE :' || SQLCODE,90);
1945    hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
1946    hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
1947    hr_utility.set_location('Leaving: ' || l_proc_name, 90);
1948    hr_utility.raise_error;
1949 
1950 END Hire_Person_IntoEmp;
1951 
1952 -- =============================================================================
1953 -- ~ Rehire_EmpIn_HRMS: don't use, will remove it later.
1954 -- =============================================================================
1955 PROCEDURE Rehire_EmpIn_HRMS
1956          (p_validate            Boolean  DEFAULT FALSE
1957          ,p_rehire_date         Date
1958          ,p_person_id           Number
1959          ,p_adjusted_svc_date   Date     DEFAULT NULL
1960          ,p_rehire_api_out      OUT NOCOPY t_RehireEmp_Api
1961          ,p_updper_api_out      OUT NOCOPY t_UpdEmp_Api
1962          ) AS
1963 
1964   l_cur_per_rec            csr_per%ROWTYPE;
1965   l_datetrack_update_mode  Varchar2(50);
1966   l_dt_correction          Boolean;
1967   l_dt_update              Boolean;
1968   l_dt_upd_override        Boolean;
1969   l_upd_chg_ins            Boolean;
1970 
1971   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Rehire_EmpIn_HRMS';
1972 
1973 BEGIN
1974   hr_utility.set_location('Entering: ' || l_proc_name, 10);
1975 
1976   OPEN  csr_per(c_person_id         => l_per_rec.person_id
1977                ,c_business_group_id => l_per_rec.business_group_id
1978                ,c_effective_date    => p_rehire_date);
1979   FETCH csr_per INTO l_cur_per_rec;
1980   CLOSE csr_per;
1981   hr_utility.set_location(' l_cur_asg_rec: ' || l_cur_per_rec.person_id, 20);
1982   Dt_Api.Find_DT_Upd_Modes
1983   (p_effective_date        => p_rehire_date
1984   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
1985   ,p_base_key_column       => 'PERSON_ID'
1986   ,p_base_key_value        => l_cur_per_rec.person_id
1987   ,p_correction            => l_dt_correction
1988   ,p_update                => l_dt_update
1989   ,p_update_override       => l_dt_upd_override
1990   ,p_update_change_insert  => l_upd_chg_ins
1991    );
1992 
1993   IF NOT(l_dt_update AND
1994          l_dt_upd_override AND
1995          l_upd_chg_ins) THEN
1996      l_datetrack_update_mode := 'CORRECTION';
1997   ELSIF l_dt_update THEN
1998      l_datetrack_update_mode := 'UPDATE';
1999   ELSIF l_dt_upd_override OR
2000         l_upd_chg_ins THEN
2001         -- Need to check if person type in future is EMP, APL or CWK , if yes
2002         -- then raise error
2003         NULL;
2004   END IF;
2005   hr_utility.set_location(' l_datetrack_update_mode: ' ||
2006                             l_cur_per_rec.person_id, 30);
2007 
2008   Hr_Employee_Api.re_hire_ex_employee
2009   (p_validate                      => p_validate
2010   ,p_hire_date                     => p_rehire_date
2011   ,p_person_id                     => l_cur_per_rec.person_id
2012   ,p_person_type_id                => l_per_rec.person_type_id
2013   ,p_rehire_reason                 => NULL
2014   ,p_per_object_version_number     => l_cur_per_rec.object_version_number
2015   -- Out Variables
2016   ,p_assignment_id                 => p_rehire_api_out.assignment_id
2017   ,p_asg_object_version_number     => p_rehire_api_out.asg_object_version_number
2018   ,p_per_effective_start_date      => p_rehire_api_out.per_effective_start_date
2019   ,p_per_effective_end_date        => p_rehire_api_out.per_effective_end_date
2020   ,p_assignment_sequence           => p_rehire_api_out.assignment_sequence
2021   ,p_assignment_number             => p_rehire_api_out.assignment_number
2022   ,p_assign_payroll_warning        => p_rehire_api_out.assign_payroll_warning
2023   );
2024   hr_utility.set_location('.. assignment_id            : ' ||
2025                            p_rehire_api_out.assignment_id,40);
2026   hr_utility.set_location('.. object_version_number    : ' ||
2027                            p_rehire_api_out.asg_object_version_number,40);
2028   hr_utility.set_location('.. per_effective_start_date : ' ||
2029                            p_rehire_api_out.per_effective_start_date,40);
2030   hr_utility.set_location('.. per_effective_end_date   : ' ||
2031                            p_rehire_api_out.per_effective_end_date,40);
2032   hr_utility.set_location('.. assignment_sequence      : ' ||
2033                            p_rehire_api_out.assignment_sequence,40);
2034   hr_utility.set_location('.. assignment_number        : ' ||
2035                            p_rehire_api_out.assignment_number,40);
2036   hr_utility.set_location('.. Employee Re-hired        : ' ||
2037                            l_cur_per_rec.person_id, 40);
2038 
2039   l_per_rec.employee_number := NVL(l_per_rec.employee_number
2040                                   ,l_cur_per_rec.employee_number);
2041   l_datetrack_update_mode   := 'CORRECTION';
2042 
2043   Hr_Person_Api.Update_Person
2044   (p_validate                     => p_validate
2045   ,p_effective_date               => p_rehire_date
2046   ,p_datetrack_update_mode        => l_datetrack_update_mode
2047   ,p_person_id                    => l_cur_per_rec.person_id
2048   ,p_party_id                     => l_per_rec.party_id
2049   ,p_object_version_number        => l_cur_per_rec.object_version_number
2050   ,p_person_type_id               => l_per_rec.person_type_id
2051   ,p_employee_number              => l_per_rec.employee_number
2052   ,p_last_name                    => NVL(l_per_rec.last_name
2053                                         ,l_cur_per_rec.last_name)
2054   ,p_first_name                   => NVL(l_per_rec.first_name
2055                                         ,l_cur_per_rec.first_name)
2056   ,p_date_of_birth                => NVL(l_per_rec.date_of_birth
2057                                         ,l_cur_per_rec.date_of_birth)
2058   ,p_marital_status               => NVL(l_per_rec.marital_status
2059                                         ,l_cur_per_rec.marital_status)
2060   ,p_middle_names                 => NVL(l_per_rec.middle_names
2061                                         ,l_cur_per_rec.middle_names)
2062   ,p_sex                          => NVL(l_per_rec.sex
2063                                         ,l_cur_per_rec.sex)
2064   ,p_title                        => NVL(l_per_rec.title
2065                                         ,l_cur_per_rec.title)
2066   ,p_nationality                  => NVL(l_per_rec.nationality
2067                                         ,l_cur_per_rec.nationality)
2068   ,p_national_identifier          => NVL(l_per_rec.national_identifier
2069                                         ,l_cur_per_rec.national_identifier)
2070   ,p_previous_last_name           => NVL(l_per_rec.previous_last_name
2071                                         ,l_cur_per_rec.previous_last_name)
2072   ,p_known_as                     => NVL(l_per_rec.known_as
2073                                         ,l_cur_per_rec.known_as)
2074   ,p_registered_disabled_flag     => NVL(l_per_rec.registered_disabled_flag
2075                                         ,l_cur_per_rec.registered_disabled_flag)
2076 /*
2077   ,p_applicant_number             =>
2078   ,p_comments                     =>
2079 */
2080   ,p_date_employee_data_verified  => NVL(l_per_rec.date_employee_data_verified
2081                                      ,l_cur_per_rec.date_employee_data_verified)
2082   ,p_email_address                => NVL(l_per_rec.email_address
2083                                         ,l_cur_per_rec.email_address)
2084 
2085   ,p_expense_check_send_to_addres => NVL(l_per_rec.expense_check_send_to_address
2086                                    ,l_cur_per_rec.expense_check_send_to_address)
2087    -- Person DDF
2088 /*
2089   ,p_per_information_category     IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2090   ,p_per_information1             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2091   ,p_per_information2             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2092   ,p_per_information3             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2093   ,p_per_information4             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2094   ,p_per_information5             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2095   ,p_per_information6             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2096   ,p_per_information7             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2097   ,p_per_information8             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2098   ,p_per_information9             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2099   ,p_per_information10            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2100   ,p_per_information11            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2101   ,p_per_information12            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2102   ,p_per_information13            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2103   ,p_per_information14            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2104   ,p_per_information15            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2105   ,p_per_information16            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2106   ,p_per_information17            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2107   ,p_per_information18            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2108   ,p_per_information19            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2109   ,p_per_information20            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2110   ,p_per_information21            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2111   ,p_per_information22            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2112   ,p_per_information23            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2113   ,p_per_information24            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2114   ,p_per_information25            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2115   ,p_per_information26            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2116   ,p_per_information27            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2117   ,p_per_information28            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2118   ,p_per_information29            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2119   ,p_per_information30            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2120   -- Person DF
2121   ,p_attribute_category           IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2122   ,p_attribute1                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2123   ,p_attribute2                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2124   ,p_attribute3                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2125   ,p_attribute4                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2126   ,p_attribute5                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2127   ,p_attribute6                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2128   ,p_attribute7                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2129   ,p_attribute8                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2130   ,p_attribute9                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2131   ,p_attribute10                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2132   ,p_attribute11                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2133   ,p_attribute12                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2134   ,p_attribute13                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2135   ,p_attribute14                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2136   ,p_attribute15                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2137   ,p_attribute16                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2138   ,p_attribute17                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2139   ,p_attribute18                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2140   ,p_attribute19                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2141   ,p_attribute20                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2142   ,p_attribute21                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2143   ,p_attribute22                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2144   ,p_attribute23                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2145   ,p_attribute24                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2146   ,p_attribute25                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2147   ,p_attribute26                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2148   ,p_attribute27                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2149   ,p_attribute28                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2150   ,p_attribute29                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2151   ,p_attribute30                  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2152 
2153   ,p_vendor_id                    IN      NUMBER   DEFAULT Hr_Api.g_number
2154   ,p_work_telephone               IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2155   ,p_date_of_death                IN      DATE     DEFAULT Hr_Api.g_date
2156   ,p_background_check_status      IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2157   ,p_background_date_check        IN      DATE     DEFAULT Hr_Api.g_date
2158   ,p_blood_type                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2159   ,p_correspondence_language      IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2160   ,p_fast_path_employee           IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2161   ,p_fte_capacity                 IN      NUMBER   DEFAULT Hr_Api.g_number
2162   ,p_hold_applicant_date_until    IN      DATE     DEFAULT Hr_Api.g_date
2163   ,p_honors                       IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2164   ,p_internal_location            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2165   ,p_last_medical_test_by         IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2166   ,p_last_medical_test_date       IN      DATE     DEFAULT Hr_Api.g_date
2167   ,p_mailstop                     IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2168   ,p_office_number                IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2169   ,p_on_military_service          IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2170   ,p_pre_name_adjunct             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2171   ,p_projected_start_date         IN      DATE     DEFAULT Hr_Api.g_date
2172   ,p_rehire_authorizor            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2173   ,p_rehire_recommendation        IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2174   ,p_resume_exists                IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2175   ,p_resume_last_updated          IN      DATE     DEFAULT Hr_Api.g_date
2176   ,p_second_passport_exists       IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2177   ,p_student_status               IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2178   ,p_work_schedule                IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2179   ,p_rehire_reason                IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2180   ,p_suffix                       IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2181   ,p_benefit_group_id             IN      NUMBER   DEFAULT Hr_Api.g_number
2182   ,p_receipt_of_death_cert_date   IN      DATE     DEFAULT Hr_Api.g_date
2183   ,p_coord_ben_med_pln_no         IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2184   ,p_coord_ben_no_cvg_flag        IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2185   ,p_coord_ben_med_ext_er         IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2186   ,p_coord_ben_med_pl_name        IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2187   ,p_coord_ben_med_insr_crr_name  IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2188   ,p_coord_ben_med_insr_crr_ident IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2189   ,p_coord_ben_med_cvg_strt_dt    IN      DATE     DEFAULT Hr_Api.g_date
2190   ,p_coord_ben_med_cvg_end_dt     IN      DATE     DEFAULT Hr_Api.g_date
2191   ,p_uses_tobacco_flag            IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2192   ,p_dpdnt_adoption_date          IN      DATE     DEFAULT Hr_Api.g_date
2193   ,p_dpdnt_vlntry_svce_flag       IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2194   ,p_original_date_of_hire        IN      DATE     DEFAULT Hr_Api.g_date
2195   ,p_adjusted_svc_date            IN      DATE     DEFAULT Hr_Api.g_date
2196   ,p_town_of_birth                IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2197   ,p_region_of_birth              IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2198   ,p_country_of_birth             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2199   ,p_global_person_id             IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2200   ,p_npw_number                   IN      Varchar2 DEFAULT Hr_Api.g_Varchar2
2201   */
2202   ,p_effective_start_date         => p_updper_api_out.effective_start_date
2203   ,p_effective_end_date           => p_updper_api_out.effective_end_date
2204   ,p_full_name                    => p_updper_api_out.full_name
2205   ,p_comment_id                   => p_updper_api_out.comment_id
2206   ,p_name_combination_warning     => p_updper_api_out.name_combination_warning
2207   ,p_assign_payroll_warning       => p_updper_api_out.assign_payroll_warning
2208   ,p_orig_hire_warning            => p_updper_api_out.orig_hire_warning
2209   );
2210 
2211   hr_utility.set_location('.. effective_start_date : ' ||
2212                            p_updper_api_out.effective_start_date, 50);
2213   hr_utility.set_location('.. effective_end_date   : ' ||
2214                            p_updper_api_out.effective_end_date, 50);
2215   hr_utility.set_location('.. full_name            : ' ||
2216                            p_updper_api_out.full_name, 50);
2217 
2218   hr_utility.set_location('Leaving: ' || l_proc_name, 50);
2219 
2220 EXCEPTION
2221   WHEN Others THEN
2222   hr_utility.set_location('Leaving: ' || l_proc_name, 60);
2223   RAISE;
2224 
2225 END Rehire_EmpIn_HRMS;
2226 
2227 -- =============================================================================
2228 -- ~ Create_EmpIn_HRMS:
2229 -- =============================================================================
2230 PROCEDURE Create_EmpIn_HRMS
2231          (p_validate            Boolean  DEFAULT FALSE
2232          ,p_effective_date      Date
2233          ,p_adjusted_svc_date   Date     DEFAULT NULL
2234          ,p_per_comments        Varchar2 DEFAULT NULL
2235          ,p_emp_api_out         OUT NOCOPY t_hrEmpApi)AS
2236 
2237   l_person_id                  per_all_people_f.person_id%TYPE;
2238   l_assignment_id              per_all_assignments_f.assignment_id%TYPE;
2239   l_per_object_version_number  per_all_people_f.object_version_number%TYPE;
2240   l_asg_object_version_number  per_all_assignments_f.object_version_number%TYPE;
2241   l_per_effective_start_date   Date;
2242   l_per_effective_end_date     Date;
2243   l_full_name                  per_all_people_f.full_name%TYPE;
2244   l_per_comment_id             per_all_people_f.comment_id%TYPE;
2245   l_assignment_sequence        per_all_assignments_f.assignment_sequence%TYPE;
2246   l_assignment_number          per_all_assignments_f.assignment_number%TYPE;
2247   l_name_combination_warning   Boolean;
2248   l_assign_payroll_warning     Boolean;
2249   l_orig_hire_warning          Boolean;
2250 
2251   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Create_EmpIn_HRMS';
2252 
2253 BEGIN
2254   hr_utility.set_location('Entering: ' || l_proc_name, 10);
2255 
2256   IF g_emp_num_gen <> 'M' THEN
2257      l_per_rec.employee_number := Null;
2258   END IF;
2259 
2260   Hr_Employee_Api.Create_Employee
2261   (p_validate                     => p_validate
2262   ,p_hire_date                    => l_per_rec.start_date
2263   ,p_business_group_id            => l_per_rec.business_group_id
2264   ,p_last_name                    => l_per_rec.last_name
2265   ,p_sex                          => l_per_rec.sex
2266   ,p_person_type_id               => l_per_rec.person_type_id
2267   ,p_per_comments                 => p_per_comments
2268   ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
2269   ,p_date_of_birth                => l_per_rec.date_of_birth
2270   ,p_email_address                => l_per_rec.email_address
2271   ,p_employee_number              => l_per_rec.employee_number
2272   ,p_expense_check_send_to_addres => l_per_rec.expense_check_send_to_address
2273   ,p_first_name                   => l_per_rec.first_name
2274   ,p_known_as                     => l_per_rec.known_as
2275   ,p_marital_status               => l_per_rec.marital_status
2276   ,p_middle_names                 => l_per_rec.middle_names
2277   ,p_nationality                  => l_per_rec.nationality
2278   ,p_national_identifier          => l_per_rec.national_identifier
2279   ,p_previous_last_name           => l_per_rec.previous_last_name
2280   ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
2281   ,p_title                        => l_per_rec.title
2282   ,p_vendor_id                    => l_per_rec.vendor_id
2283   ,p_attribute_category           => l_per_rec.attribute_category
2284   ,p_attribute1                   => l_per_rec.attribute1
2285   ,p_attribute2                   => l_per_rec.attribute2
2286   ,p_attribute3                   => l_per_rec.attribute3
2287   ,p_attribute4                   => l_per_rec.attribute4
2288   ,p_attribute5                   => l_per_rec.attribute5
2289   ,p_attribute6                   => l_per_rec.attribute6
2290   ,p_attribute7                   => l_per_rec.attribute7
2291   ,p_attribute8                   => l_per_rec.attribute8
2292   ,p_attribute9                   => l_per_rec.attribute9
2293   ,p_attribute10                  => l_per_rec.attribute10
2294   ,p_attribute11                  => l_per_rec.attribute11
2295   ,p_attribute12                  => l_per_rec.attribute12
2296   ,p_attribute13                  => l_per_rec.attribute13
2297   ,p_attribute14                  => l_per_rec.attribute14
2298   ,p_attribute15                  => l_per_rec.attribute15
2299   ,p_attribute16                  => l_per_rec.attribute16
2300   ,p_attribute17                  => l_per_rec.attribute17
2301   ,p_attribute18                  => l_per_rec.attribute18
2302   ,p_attribute19                  => l_per_rec.attribute19
2303   ,p_attribute20                  => l_per_rec.attribute20
2304   ,p_attribute21                  => l_per_rec.attribute21
2305   ,p_attribute22                  => l_per_rec.attribute22
2306   ,p_attribute23                  => l_per_rec.attribute23
2307   ,p_attribute24                  => l_per_rec.attribute24
2308   ,p_attribute25                  => l_per_rec.attribute25
2309   ,p_attribute26                  => l_per_rec.attribute26
2310   ,p_attribute27                  => l_per_rec.attribute27
2311   ,p_attribute28                  => l_per_rec.attribute28
2312   ,p_attribute29                  => l_per_rec.attribute29
2313   ,p_attribute30                  => l_per_rec.attribute30
2314   ,p_per_information_category     => l_per_rec.per_information_category
2315   ,p_per_information1             => l_per_rec.per_information1
2316   ,p_per_information2             => l_per_rec.per_information2
2317   ,p_per_information3             => l_per_rec.per_information3
2318   ,p_per_information4             => l_per_rec.per_information4
2319   ,p_per_information5             => l_per_rec.per_information5
2320   ,p_per_information6             => l_per_rec.per_information6
2321   ,p_per_information7             => l_per_rec.per_information7
2322   ,p_per_information8             => l_per_rec.per_information8
2323   ,p_per_information9             => l_per_rec.per_information9
2324   ,p_per_information10            => l_per_rec.per_information10
2325   ,p_per_information11            => l_per_rec.per_information11
2326   ,p_per_information12            => l_per_rec.per_information12
2327   ,p_per_information13            => l_per_rec.per_information13
2328   ,p_per_information14            => l_per_rec.per_information14
2329   ,p_per_information15            => l_per_rec.per_information15
2330   ,p_per_information16            => l_per_rec.per_information16
2331   ,p_per_information17            => l_per_rec.per_information17
2332   ,p_per_information18            => l_per_rec.per_information18
2333   ,p_per_information19            => l_per_rec.per_information19
2334   ,p_per_information20            => l_per_rec.per_information20
2335   ,p_per_information21            => l_per_rec.per_information21
2336   ,p_per_information22            => l_per_rec.per_information22
2337   ,p_per_information23            => l_per_rec.per_information23
2338   ,p_per_information24            => l_per_rec.per_information24
2339   ,p_per_information25            => l_per_rec.per_information25
2340   ,p_per_information26            => l_per_rec.per_information26
2341   ,p_per_information27            => l_per_rec.per_information27
2342   ,p_per_information28            => l_per_rec.per_information28
2343   ,p_per_information29            => l_per_rec.per_information29
2344   ,p_per_information30            => l_per_rec.per_information30
2345   ,p_date_of_death                => l_per_rec.date_of_death
2346   ,p_background_check_status      => l_per_rec.background_check_status
2347   ,p_background_date_check        => l_per_rec.background_date_check
2348   ,p_blood_type                   => l_per_rec.blood_type
2349   ,p_correspondence_language      => l_per_rec.correspondence_language
2350   ,p_fast_path_employee           => l_per_rec.fast_path_employee
2351   ,p_fte_capacity                 => l_per_rec.fte_capacity
2352   ,p_honors                       => l_per_rec.honors
2353   ,p_internal_location            => l_per_rec.internal_location
2354   ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
2355   ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
2356   ,p_mailstop                     => l_per_rec.mailstop
2357   ,p_office_number                => l_per_rec.office_number
2358   ,p_on_military_service          => l_per_rec.on_military_service
2359   ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
2360   ,p_rehire_recommendation        => l_per_rec.rehire_recommendation
2361   ,p_projected_start_date         => l_per_rec.projected_start_date
2362   ,p_resume_exists                => l_per_rec.resume_exists
2363   ,p_resume_last_updated          => l_per_rec.resume_last_updated
2364   ,p_second_passport_exists       => l_per_rec.second_passport_exists
2365   ,p_student_status               => l_per_rec.student_status
2366   ,p_work_schedule                => l_per_rec.work_schedule
2367   ,p_suffix                       => l_per_rec.suffix
2368   ,p_benefit_group_id             => l_per_rec.benefit_group_id
2369   ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
2370   ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
2371   ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
2372   ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
2373   ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
2374   ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
2375   ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
2376   ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
2377   ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
2378   ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
2379   ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
2380   ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
2381   ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
2382   ,p_adjusted_svc_date            => p_adjusted_svc_date
2383   ,p_town_of_birth                => l_per_rec.town_of_birth
2384   ,p_region_of_birth              => l_per_rec.region_of_birth
2385   ,p_country_of_birth             => l_per_rec.country_of_birth
2386   ,p_global_person_id             => l_per_rec.global_person_id
2387   ,p_party_id                     => l_per_rec.party_id
2388   -- Out Variables
2389   ,p_person_id                    => p_emp_api_out.person_id
2390   ,p_assignment_id                => p_emp_api_out.assignment_id
2391   ,p_per_object_version_number    => p_emp_api_out.per_object_version_number
2392   ,p_asg_object_version_number    => p_emp_api_out.asg_object_version_number
2393   ,p_per_effective_start_date     => p_emp_api_out.per_effective_start_date
2394   ,p_per_effective_end_date       => p_emp_api_out.per_effective_end_date
2395   ,p_full_name                    => p_emp_api_out.full_name
2396   ,p_per_comment_id               => p_emp_api_out.per_comment_id
2397   ,p_assignment_sequence          => p_emp_api_out.assignment_sequence
2398   ,p_assignment_number            => p_emp_api_out.assignment_number
2399   ,p_name_combination_warning     => p_emp_api_out.name_combination_warning
2400   ,p_assign_payroll_warning       => p_emp_api_out.assign_payroll_warning
2401   ,p_orig_hire_warning            => p_emp_api_out.orig_hire_warning
2402   );
2403 
2404   l_per_rec.person_id             := p_emp_api_out.person_id;
2405   l_per_rec.object_version_number := p_emp_api_out.per_object_version_number;
2406   l_per_rec.effective_start_date  := p_emp_api_out.per_effective_start_date;
2407   l_per_rec.effective_end_date    := p_emp_api_out.per_effective_end_date;
2408 
2409   IF g_debug_on THEN
2410     hr_utility.set_location('..person_id                 : ' ||
2411                              p_emp_api_out.person_id,20);
2412     hr_utility.set_location('..assignment_id             : ' ||
2413                              p_emp_api_out.assignment_id,20);
2414     hr_utility.set_location('..per_object_version_number : ' ||
2415                              p_emp_api_out.per_object_version_number,20);
2416     hr_utility.set_location('..asg_object_version_number : ' ||
2417                              p_emp_api_out.asg_object_version_number,20);
2418     hr_utility.set_location('..per_effective_start_date  : ' ||
2419                              p_emp_api_out.per_effective_start_date,20);
2420     hr_utility.set_location('..per_effective_end_date    : ' ||
2421                              p_emp_api_out.per_effective_end_date,20);
2422     hr_utility.set_location('..full_name                 : ' ||
2423                              p_emp_api_out.full_name,20);
2424     hr_utility.set_location('..per_comment_id            : ' ||
2425                              p_emp_api_out.per_comment_id,20);
2426     hr_utility.set_location('..assignment_sequence       : ' ||
2427                              p_emp_api_out.assignment_sequence,20);
2428     hr_utility.set_location('..assignment_number         : ' ||
2429                              p_emp_api_out.assignment_number,20);
2430   END IF;
2431 
2432   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
2433 
2434 EXCEPTION
2435   WHEN Others THEN
2436   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
2437   RAISE;
2438 
2439 END Create_EmpIn_HRMS;
2440 
2441 
2442 -- =============================================================================
2443 -- ~ HR_DataPump_Per_XtraInfo:
2444 -- =============================================================================
2445 PROCEDURE HR_DataPump_Per_XtraInfo
2446          (p_business_group_id IN Number
2447          ,p_person_id         IN Number
2448          ,p_party_id          IN Number
2449          ,p_effective_date    IN Date
2450          ,p_batch_id          IN Number
2451          ,p_user_sequence     IN Number
2452          ,p_link_value        IN Number
2453          ,p_xtra_info_key     IN Varchar2
2454          ,p_person_user_key   IN Varchar2
2455          ) AS
2456 
2457   -- Existing OSS Person Details
2458   CURSOR csr_OSS_pe (c_person_id         IN Number
2459                     ,c_information_type  IN Varchar2) IS
2460   SELECT pei.pei_information1
2461         ,pei.pei_information2
2462         ,pei.pei_information3
2463         ,pei.pei_information4
2464         ,pei.pei_information5
2465         ,pei.object_version_number
2466         ,pei.person_extra_info_id
2467     FROM per_people_extra_info pei
2468    WHERE pei.person_id        = c_person_id
2469      AND pei.information_type = c_information_type;
2470 
2471   l_OSS_pe             csr_oss_pe%ROWTYPE;
2472 
2473   -- Get Party Number
2474   CURSOR hz_pe (c_party_id IN Number) IS
2475   SELECT hzp.party_number
2476     FROM hz_parties hzp
2477    WHERE hzp.party_id = c_party_id;
2478 
2479    -- OSS Person Record
2480   TYPE oss_per_rec IS RECORD
2481    ( person_id_type      Varchar2(150)
2482     ,api_person_id       Varchar2(150)
2483     ,person_number       Varchar2(150)
2484     ,system_type         Varchar2(150)
2485     );
2486 
2487   TYPE csr_oss_t  IS REF CURSOR;
2488 
2489   SQLstmt                 Varchar2(2000);
2490   csr_igs                 csr_oss_t;
2491   l_oss_per_details       oss_per_rec;
2492   l_oss_person_details    per_people_extra_info.information_type%TYPE;
2493   l_person_extra_info_rec per_people_extra_info%ROWTYPE;
2494   --
2495   l_proc_name CONSTANT  Varchar2(150) := g_pkg ||'HR_DataPump_Per_XtraInfo';
2496   --
2497 
2498 BEGIN
2499   hr_utility.set_location('Entering: ' || l_proc_name, 10);
2500 
2501   SAVEPOINT oss_per_dtls;
2502 
2503   l_oss_person_details    := 'PQP_OSS_PERSON_DETAILS';
2504   l_person_extra_info_rec := NULL;
2505 
2506   --
2507   SQLstmt:=
2508   '   SELECT igp.person_id_type  ' ||
2509   '         ,igp.api_person_id   ' ||
2510   '         ,igp.person_number   ' ||
2511   '         ,ipt.system_type     ' ||
2512   '     FROM igs_pe_person_v igp ' ||
2513   '         ,igs_pe_typ_instances_all pti ' ||
2514   '         ,igs_pe_person_types      ipt ' ||
2515   '    WHERE igp.person_id = :c_party_id  ' ||
2516   '      AND pti.person_type_code = ipt.person_type_code ' ||
2517   '      AND pti.person_id = igp.person_id ' ||
2518   '      AND ipt.system_type IN ('||'''STUDENT'''||',' ||
2519                                 '''FACULTY'''||','||'''OTHER''' ||')' ;
2520 
2521   -- Create the OSS Person EIT information
2522   hr_utility.set_location(' Creating: PQP_OSS_PERSON_DETAILS', 20);
2523 
2524   l_person_extra_info_rec.information_type         := l_oss_person_details;
2525   l_person_extra_info_rec.pei_information_category := l_oss_person_details;
2526 
2527   -- =====================================================================
2528   -- OSS Person Type -(R)      = PEI_INFORMATION1
2529   -- OSS Person Number -(R)    = PEI_INFORMATION2
2530   -- Alternate Id Type         = PEI_INFORMATION3
2531   -- Alternate Id No           = PEI_INFORMATION4
2532   -- Synchronize OSS Data -(R) = PEI_INFORMATION5
2533   -- =====================================================================
2534 
2535   OPEN csr_igs FOR SQLstmt Using p_party_id;
2536   FETCH csr_igs INTO l_oss_per_details;
2537   CLOSE csr_igs;
2538 
2539   hr_utility.set_location(' After Dyn SQL Ref Cursor', 30);
2540 
2541   l_person_extra_info_rec.pei_information1  := NVL(l_oss_per_details.system_type
2542                                                   ,'STUDENT');
2543   l_person_extra_info_rec.pei_information2  := l_oss_per_details.person_number;
2544 
2545   -- If person_number is NULL
2546   IF l_oss_per_details.person_number IS NULL THEN
2547 
2548      OPEN hz_pe(c_party_id => p_party_id);
2549      FETCH hz_pe INTO l_oss_per_details.person_number;
2550      CLOSE hz_pe;
2551 
2552      l_person_extra_info_rec.pei_information2:=l_oss_per_details.person_number;
2553   END IF;
2554 
2555   -- The Alternate ID and Type is not required
2556   --l_person_extra_info_rec.pei_information3  := l_oss_per_details.person_id_type;
2557   --l_person_extra_info_rec.pei_information4  := l_oss_per_details.api_person_id;
2558   l_person_extra_info_rec.pei_information5  := 'Y';
2559 
2560   -- Check if Extra_information for Person already exists
2561   OPEN  csr_OSS_pe (c_person_id        => p_person_id
2562                    ,c_information_type => l_oss_person_details);
2563   FETCH csr_OSS_pe INTO l_OSS_pe;
2564 
2565   IF csr_OSS_pe%NOTFOUND THEN
2566 
2567      hrdpp_create_person_extra_info.insert_batch_lines
2568      (p_batch_id                   => p_batch_id
2569      ,p_user_sequence              => p_user_sequence
2570      ,p_link_value                 => p_link_value
2571      ,p_information_type           => l_person_extra_info_rec.information_type
2572      ,p_pei_information_category   =>
2573                               l_person_extra_info_rec.pei_information_category
2574      ,p_pei_information1           => l_person_extra_info_rec.pei_information1
2575      ,p_pei_information2           => l_person_extra_info_rec.pei_information2
2576      ,p_pei_information3           => l_person_extra_info_rec.pei_information3
2577      ,p_pei_information4           => l_person_extra_info_rec.pei_information4
2578      ,p_pei_information5           => l_person_extra_info_rec.pei_information5
2579      ,p_pei_information6           => l_person_extra_info_rec.pei_information6
2580      ,p_pei_information7           => l_person_extra_info_rec.pei_information7
2581      ,p_pei_information8           => l_person_extra_info_rec.pei_information8
2582      ,p_pei_information9           => l_person_extra_info_rec.pei_information9
2583      ,p_pei_information10          => l_person_extra_info_rec.pei_information10
2584      ,p_pei_information11          => l_person_extra_info_rec.pei_information11
2585      ,p_pei_information12          => l_person_extra_info_rec.pei_information12
2586      ,p_pei_information13          => l_person_extra_info_rec.pei_information13
2587      ,p_pei_information14          => l_person_extra_info_rec.pei_information14
2588      ,p_pei_information15          => l_person_extra_info_rec.pei_information15
2589      ,p_pei_information16          => l_person_extra_info_rec.pei_information16
2590      ,p_pei_information17          => l_person_extra_info_rec.pei_information17
2591      ,p_pei_information18          => l_person_extra_info_rec.pei_information18
2592      ,p_pei_information19          => l_person_extra_info_rec.pei_information19
2593      ,p_pei_information20          => l_person_extra_info_rec.pei_information20
2594      ,p_pei_information21          => l_person_extra_info_rec.pei_information21
2595      ,p_pei_information22          => l_person_extra_info_rec.pei_information22
2596      ,p_pei_information23          => l_person_extra_info_rec.pei_information23
2597      ,p_pei_information24          => l_person_extra_info_rec.pei_information24
2598      ,p_pei_information25          => l_person_extra_info_rec.pei_information25
2599      ,p_pei_information26          => l_person_extra_info_rec.pei_information26
2600      ,p_pei_information27          => l_person_extra_info_rec.pei_information27
2601      ,p_pei_information28          => l_person_extra_info_rec.pei_information28
2602      ,p_pei_information29          => l_person_extra_info_rec.pei_information29
2603      ,p_pei_information30          => l_person_extra_info_rec.pei_information30
2604      ,p_person_extra_info_user_key => p_xtra_info_key
2605      ,p_person_user_key            => p_person_user_key
2606      );
2607 
2608   ELSE
2609 
2610      -- Insert User_Key for People Extra Information ID
2611      hr_pump_utils.add_user_key
2612      (p_user_key_value => p_xtra_info_key
2613      ,p_unique_key_id  =>
2614       l_person_extra_info_rec.person_extra_info_id
2615       );
2616 
2617      hrdpp_update_person_extra_info.insert_batch_lines
2618      (p_batch_id                   => p_batch_id
2619      ,p_user_sequence              => p_user_sequence
2620      ,p_link_value                 => p_link_value
2621      ,p_pei_information_category   =>
2622          l_person_extra_info_rec.pei_information_category
2623      ,p_pei_information1           => l_person_extra_info_rec.pei_information1
2624      ,p_pei_information2           => l_person_extra_info_rec.pei_information2
2625      ,p_pei_information3           => l_person_extra_info_rec.pei_information3
2626      ,p_pei_information4           => l_person_extra_info_rec.pei_information4
2627      ,p_pei_information5           => l_person_extra_info_rec.pei_information5
2628      ,p_pei_information6           => l_person_extra_info_rec.pei_information6
2629      ,p_pei_information7           => l_person_extra_info_rec.pei_information7
2630      ,p_pei_information8           => l_person_extra_info_rec.pei_information8
2631      ,p_pei_information9           => l_person_extra_info_rec.pei_information9
2632      ,p_pei_information10          => l_person_extra_info_rec.pei_information10
2633      ,p_pei_information11          => l_person_extra_info_rec.pei_information11
2634      ,p_pei_information12          => l_person_extra_info_rec.pei_information12
2635      ,p_pei_information13          => l_person_extra_info_rec.pei_information13
2636      ,p_pei_information14          => l_person_extra_info_rec.pei_information14
2637      ,p_pei_information15          => l_person_extra_info_rec.pei_information15
2638      ,p_pei_information16          => l_person_extra_info_rec.pei_information16
2639      ,p_pei_information17          => l_person_extra_info_rec.pei_information17
2640      ,p_pei_information18          => l_person_extra_info_rec.pei_information18
2641      ,p_pei_information19          => l_person_extra_info_rec.pei_information19
2642      ,p_pei_information20          => l_person_extra_info_rec.pei_information20
2643      ,p_pei_information21          => l_person_extra_info_rec.pei_information21
2644      ,p_pei_information22          => l_person_extra_info_rec.pei_information22
2645      ,p_pei_information23          => l_person_extra_info_rec.pei_information23
2646      ,p_pei_information24          => l_person_extra_info_rec.pei_information24
2647      ,p_pei_information25          => l_person_extra_info_rec.pei_information25
2648      ,p_pei_information26          => l_person_extra_info_rec.pei_information26
2649      ,p_pei_information27          => l_person_extra_info_rec.pei_information27
2650      ,p_pei_information28          => l_person_extra_info_rec.pei_information28
2651      ,p_pei_information29          => l_person_extra_info_rec.pei_information29
2652      ,p_pei_information30          => l_person_extra_info_rec.pei_information30
2653      ,p_person_extra_info_user_key => p_xtra_info_key
2654      );
2655 
2656   END IF;
2657   hr_utility.set_location(' After Cursor :csr_OSS_pe', 40);
2658   CLOSE csr_OSS_pe;
2659 
2660   hr_utility.set_location('Leaving: ' || l_proc_name, 50);
2661 
2662 EXCEPTION
2663   WHEN Others THEN
2664        hr_utility.set_location('Leaving: ' || l_proc_name, 60);
2665        ROLLBACK TO oss_per_dtls;
2666 
2667 END HR_DataPump_Per_XtraInfo;
2668 
2669 
2670 -- =============================================================================
2671 -- ~ HR_DataPump:
2672 --
2673 -- NOTE : p_data_pump_batch_line_id is used as link_value_id in the procedure
2674 --        as in future we may have to have it as batch_line_ids concatenated
2675 --        string
2676 -- =============================================================================
2677 PROCEDURE HR_DataPump
2678           (p_data_pump_batch_line_id IN Varchar2
2679           ,p_batch_id                IN Number
2680           ,p_contact_name            IN Varchar
2681           ,p_dp_mode                 IN Varchar
2682           ,p_adjusted_svc_date       IN Date
2683           ) AS
2684 
2685   -- Cursor gets the link_value for the record. It is the value 1 added to the
2686   -- maximum value of Link_Value for that batch_id
2687   CURSOR csr_get_link_value (c_batch_id Number) IS
2688   SELECT Max(link_value) + 1
2689     FROM hr_pump_batch_lines
2690    WHERE batch_id = c_batch_id;
2691 
2692   -- Cursor to get the Assignment details of duplicate person
2693   CURSOR csr_asg (c_person_id IN Number
2694                  ,c_business_group_id IN Number
2695                  ,c_effective_date IN Date) IS
2696   SELECT paf.assignment_id,
2697          ppf.object_version_number
2698     FROM per_all_assignments_f paf
2699         ,per_all_people_f      ppf
2700    WHERE paf.person_id = c_person_id
2701      AND paf.business_group_id = c_business_group_id
2702      AND paf.person_id = ppf.person_id
2703      AND c_effective_date BETWEEN ppf.effective_start_date
2704                               AND ppf.effective_end_date
2705      AND c_effective_date BETWEEN paf.effective_start_date
2706                               AND paf.effective_end_date;
2707 
2708   -- Cursor to get Contact Details for a person if it already exists
2709   CURSOR csr_get_cont_dtls(c_person_id         IN Number
2710                           ,c_business_group_id IN Number
2711                           ,c_effective_date    IN Date) IS
2712   SELECT *
2713     FROM per_contact_relationships
2714    WHERE person_id         = c_person_id
2715      AND business_group_id = c_business_group_id
2716      AND c_effective_date BETWEEN date_start
2717                               AND NVL(date_end, c_effective_date);
2718 
2719 
2720   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'HR_DataPump';
2721   l_person_user_key        Varchar2(240);
2722   l_assignment_user_key    Varchar2(240);
2723   l_address_user_key       Varchar2(240);
2724   l_contact_key            Varchar2(240);
2725   l_xtra_info_key          Varchar2(240);
2726   l_temp                   Varchar2(240);
2727 
2728   l_cur_per_rec            csr_per%ROWTYPE;
2729   l_datetrack_update_mode  Varchar2(50);
2730   l_dt_correction          Boolean;
2731   l_dt_update              Boolean;
2732   l_dt_upd_override        Boolean;
2733   l_upd_chg_ins            Boolean;
2734 
2735   l_cont_object_version_num
2736                            per_contact_relationships.object_version_number%TYPE;
2737   l_cur_add_rec             per_addresses%ROWTYPE;
2738   l_cont_rec                per_contact_relationships%ROWTYPE;
2739   l_pay_basis_name          per_pay_bases.NAME%TYPE;
2740   l_organization_name       hr_all_organization_units.NAME%TYPE;
2741   l_location_code           hr_locations_all.location_code%TYPE;
2742   l_payroll_name            pay_payrolls_f.payroll_name%TYPE;
2743   l_job_name                per_jobs.NAME%TYPE;
2744   l_position_name           per_positions.NAME%TYPE;
2745   l_grade_name              per_grades.NAME%TYPE;
2746   l_user_person_type        per_person_types.user_person_type%TYPE;
2747   l_user_sequence           Number := 1;
2748   l_link_value              Number;
2749 
2750 BEGIN
2751   hr_utility.set_location('Entering: ' || l_proc_name, 10);
2752 
2753   -- Creating User Keys for Person, Address, Assugnment and Contact
2754   l_temp := To_Char(Sysdate,'J')||
2755             To_Char(Sysdate,'HH24MISS')||
2756             Dbms_Utility.get_Hash_Value(l_per_rec.last_name||
2757                                         l_per_rec.sex||
2758                                         l_per_rec.first_name,0,1000);
2759 
2760   l_person_user_key     := 'HROSS~PER~'||l_temp;
2761   l_address_user_key    := 'HROSS~ADD~'||l_temp;
2762   l_assignment_user_key := 'HROSS~ASG~'||l_temp;
2763   l_contact_key         := 'HROSS~CNT~'||l_temp;
2764   l_xtra_info_key       := 'HROSS~XTR~'||l_temp;
2765 
2766 
2767   OPEN  csr_per_type(l_per_rec.person_type_id
2768                     ,l_per_rec.business_group_id);
2769   FETCH csr_per_type INTO l_user_person_type;
2770   CLOSE csr_per_type;
2771   hr_utility.set_location('..l_user_person_type: ' || l_user_person_type, 20);
2772 
2773   -- Get the Link value for this record
2774   OPEN  csr_get_link_value (p_batch_id);
2775   FETCH csr_get_link_value INTO l_link_value;
2776   CLOSE csr_get_link_value;
2777 
2778   -- If first record is being entered then link_value returned from cursor
2779   -- will be null, hence we set it to 1
2780   IF l_link_value IS NULL THEN
2781      l_link_value := 1;
2782   END IF;
2783 
2784   IF p_dp_mode = 'INSERT' THEN
2785      Hrdpp_Create_Employee.Insert_Batch_Lines
2786      (p_batch_id                     => p_batch_id
2787      ,p_user_sequence                => l_user_sequence
2788      ,p_link_value                   => l_link_value
2789      ,p_hire_date                    => l_per_rec.START_DATE
2790      ,p_last_name                    => l_per_rec.last_name
2791      ,p_sex                          => l_per_rec.sex
2792      --,p_per_comments                 => l_per_rec.comments
2793      ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
2794      ,p_date_of_birth                => l_per_rec.date_of_birth
2795      ,p_email_address                => l_per_rec.email_address
2796      ,p_employee_number              => l_per_rec.employee_number
2797      ,p_expense_check_send_to_addres => l_per_rec.expense_check_send_to_address
2798      ,p_first_name                   => l_per_rec.first_name
2799      ,p_known_as                     => l_per_rec.known_as
2800      ,p_marital_status               => l_per_rec.marital_status
2801      ,p_middle_names                 => l_per_rec.middle_names
2802      ,p_nationality                  => l_per_rec.nationality
2803      ,p_national_identifier          => l_per_rec.national_identifier
2804      ,p_previous_last_name           => l_per_rec.previous_last_name
2805      ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
2806      ,p_title                        => l_per_rec.title
2807      --,p_work_telephone               => p_telephone_no1
2808      ,p_attribute_category           => l_per_rec.attribute_category
2809      ,p_attribute1                   => l_per_rec.attribute1
2810      ,p_attribute2                   => l_per_rec.attribute2
2811      ,p_attribute3                   => l_per_rec.attribute3
2812      ,p_attribute4                   => l_per_rec.attribute4
2813      ,p_attribute5                   => l_per_rec.attribute5
2814      ,p_attribute6                   => l_per_rec.attribute6
2815      ,p_attribute7                   => l_per_rec.attribute7
2816      ,p_attribute8                   => l_per_rec.attribute8
2817      ,p_attribute9                   => l_per_rec.attribute9
2818      ,p_attribute10                  => l_per_rec.attribute10
2819      ,p_attribute11                  => l_per_rec.attribute11
2820      ,p_attribute12                  => l_per_rec.attribute12
2821      ,p_attribute13                  => l_per_rec.attribute13
2822      ,p_attribute14                  => l_per_rec.attribute14
2823      ,p_attribute15                  => l_per_rec.attribute15
2824      ,p_attribute16                  => l_per_rec.attribute16
2825      ,p_attribute17                  => l_per_rec.attribute17
2826      ,p_attribute18                  => l_per_rec.attribute18
2827      ,p_attribute19                  => l_per_rec.attribute19
2828      ,p_attribute20                  => l_per_rec.attribute20
2829      ,p_attribute21                  => l_per_rec.attribute21
2830      ,p_attribute22                  => l_per_rec.attribute22
2831      ,p_attribute23                  => l_per_rec.attribute23
2832      ,p_attribute24                  => l_per_rec.attribute24
2833      ,p_attribute25                  => l_per_rec.attribute25
2834      ,p_attribute26                  => l_per_rec.attribute26
2835      ,p_attribute27                  => l_per_rec.attribute27
2836      ,p_attribute28                  => l_per_rec.attribute28
2837      ,p_attribute29                  => l_per_rec.attribute29
2838      ,p_attribute30                  => l_per_rec.attribute30
2839      ,p_per_information_category     => l_per_rec.per_information_category
2840      ,p_per_information1             => l_per_rec.per_information1
2841      ,p_per_information2             => l_per_rec.per_information2
2842      ,p_per_information3             => l_per_rec.per_information3
2843      ,p_per_information4             => l_per_rec.per_information4
2844      ,p_per_information5             => l_per_rec.per_information5
2845      ,p_per_information6             => l_per_rec.per_information6
2846      ,p_per_information7             => l_per_rec.per_information7
2847      ,p_per_information8             => l_per_rec.per_information8
2848      ,p_per_information9             => l_per_rec.per_information9
2849      ,p_per_information10            => l_per_rec.per_information10
2850      ,p_per_information11            => l_per_rec.per_information11
2851      ,p_per_information12            => l_per_rec.per_information12
2852      ,p_per_information13            => l_per_rec.per_information13
2853      ,p_per_information14            => l_per_rec.per_information14
2854      ,p_per_information15            => l_per_rec.per_information15
2855      ,p_per_information16            => l_per_rec.per_information16
2856      ,p_per_information17            => l_per_rec.per_information17
2857      ,p_per_information18            => l_per_rec.per_information18
2858      ,p_per_information19            => l_per_rec.per_information19
2859      ,p_per_information20            => l_per_rec.per_information20
2860      ,p_per_information21            => l_per_rec.per_information21
2861      ,p_per_information22            => l_per_rec.per_information22
2862      ,p_per_information23            => l_per_rec.per_information23
2863      ,p_per_information24            => l_per_rec.per_information24
2864      ,p_per_information25            => l_per_rec.per_information25
2865      ,p_per_information26            => l_per_rec.per_information26
2866      ,p_per_information27            => l_per_rec.per_information27
2867      ,p_per_information28            => l_per_rec.per_information28
2868      ,p_per_information29            => l_per_rec.per_information29
2869      ,p_per_information30            => l_per_rec.per_information30
2870      ,p_date_of_death                => l_per_rec.date_of_death
2871      ,p_background_check_status      => l_per_rec.background_check_status
2872      ,p_background_date_check        => l_per_rec.background_date_check
2873      ,p_blood_type                   => l_per_rec.blood_type
2874      ,p_fast_path_employee           => l_per_rec.fast_path_employee
2875      ,p_fte_capacity                 => l_per_rec.fte_capacity
2876      ,p_honors                       => l_per_rec.honors
2877      ,p_internal_location            => l_per_rec.internal_location
2878      ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
2879      ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
2880      ,p_mailstop                     => l_per_rec.mailstop
2881      ,p_office_number                => l_per_rec.office_number
2882      ,p_on_military_service          => l_per_rec.on_military_service
2883      ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
2884      ,p_projected_start_date         => l_per_rec.projected_start_date
2885      ,p_resume_exists                => l_per_rec.resume_exists
2886      ,p_resume_last_updated          => l_per_rec.resume_last_updated
2887      ,p_second_passport_exists       => l_per_rec.second_passport_exists
2888      ,p_student_status               => l_per_rec.student_status
2889      ,p_work_schedule                => l_per_rec.work_schedule
2890      ,p_suffix                       => l_per_rec.suffix
2891      ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
2892      ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
2893      ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
2894      ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
2895      ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
2896      ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
2897      ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
2898      ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
2899      ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
2900      ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
2901      ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
2902      ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
2903      ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
2904      --,p_adjusted_svc_date            => p_adjusted_svc_date
2905      ,p_town_of_birth                => l_per_rec.town_of_birth
2906      ,p_region_of_birth              => l_per_rec.region_of_birth
2907      ,p_country_of_birth             => l_per_rec.country_of_birth
2908      ,p_global_person_id             => l_per_rec.global_person_id
2909      ,p_party_id                     => l_per_rec.party_id
2910      ,p_correspondence_language      => l_per_rec.correspondence_language
2911      ,p_benefit_group                => l_per_rec.benefit_group_id
2912      ,p_person_user_key              => l_person_user_key
2913      ,p_assignment_user_key          => l_assignment_user_key
2914      ,p_user_person_type             => l_user_person_type
2915      ,p_language_code                => Userenv('lang')
2916      ,p_vendor_name                  => NULL
2917      );
2918 
2919      l_user_sequence := l_user_sequence + 1;
2920 
2921      hr_utility.set_location('..Inserted into Hrdpp_Create_Employee', 30);
2922 
2923   ELSIF p_dp_mode = 'UPDATE' THEN
2924 
2925      -- Cursor to get the Latest Details of Person in System
2926      OPEN  csr_per(c_person_id         => l_per_rec.person_id
2927                   ,c_business_group_id => l_per_rec.business_group_id
2928                   ,c_effective_date    => l_per_rec.START_DATE);
2929      FETCH csr_per INTO l_cur_per_rec;
2930      CLOSE csr_per;
2931 
2932      Dt_Api.Find_DT_Upd_Modes
2933      (p_effective_date        => l_per_rec.START_DATE
2934      ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
2935      ,p_base_key_column       => 'PERSON_ID'
2936      ,p_base_key_value        => l_cur_per_rec.person_id
2937      ,p_correction            => l_dt_correction
2938      ,p_update                => l_dt_update
2939      ,p_update_override       => l_dt_upd_override
2940      ,p_update_change_insert  => l_upd_chg_ins
2941       );
2942 
2943      IF NOT(l_dt_update AND
2944             l_dt_upd_override AND
2945             l_upd_chg_ins) THEN
2946 
2947         l_datetrack_update_mode := 'CORRECTION';
2948 
2949      ELSIF l_dt_update THEN
2950 
2951         l_datetrack_update_mode := 'UPDATE';
2952 
2953      ELSIF l_dt_upd_override OR
2954            l_upd_chg_ins THEN
2955            -- Need to check if person type in future is EMP, APL or CWK ,
2956 	   -- if yes then raise error
2957             NULL;
2958      END IF;
2959      -- If User hasn't entered the Employee Number, then get Employee Number
2960      -- for entered duplicate person id
2961      IF l_per_rec.employee_number = NULL THEN
2962 
2963         OPEN  csr_get_employee_num(c_person_id => l_per_rec.person_id);
2964         FETCH csr_get_employee_num INTO l_per_rec.employee_number;
2965         CLOSE csr_get_employee_num;
2966 
2967      END IF;
2968 
2969      -- Insert the Person User Key with Person Id in DP User Keys Table
2970      -- This will be required when DP Engine is run
2971      hr_pump_utils.add_user_key(p_user_key_value => l_person_user_key
2972                                ,p_unique_key_id  => l_per_rec.person_id
2973                                );
2974 
2975      Hrdpp_Hire_Into_Job.insert_batch_lines
2976      (p_batch_id                     => p_batch_id
2977      ,p_user_sequence                => l_user_sequence
2978      ,p_link_value                   => l_link_value
2979      ,p_effective_date               => l_per_rec.START_DATE
2980      ,p_object_version_number        => l_cur_per_rec.object_version_number
2981      ,p_employee_number              => l_per_rec.employee_number
2982      ,p_datetrack_update_mode        => l_datetrack_update_mode
2983      ,p_national_identifier          => l_per_rec.national_identifier
2984      ,p_per_information7             => NULL
2985      ,p_person_user_key              => l_person_user_key
2986      ,p_assignment_user_key          => l_assignment_user_key
2987      ,p_user_person_type             => l_user_person_type
2988      ,p_language_code                => Userenv('LANG')
2989      );
2990 
2991      l_user_sequence := l_user_sequence + 1;
2992 
2993      Hrdpp_Update_Person.insert_batch_lines
2994      (p_batch_id                     => p_batch_id
2995      ,p_user_sequence                => l_user_sequence
2996      ,p_link_value                   => l_link_value
2997      ,p_effective_date               => l_per_rec.START_DATE
2998      ,p_datetrack_update_mode        => l_datetrack_update_mode
2999      ,p_party_id                     => l_per_rec.party_id
3000      ,p_employee_number              => l_per_rec.employee_number
3001      ,p_last_name                    => NVL(l_per_rec.last_name
3002                                            ,l_cur_per_rec.last_name)
3003      ,p_first_name                   => NVL(l_per_rec.first_name
3004                                            ,l_cur_per_rec.first_name)
3005      ,p_date_of_birth                => NVL(l_per_rec.date_of_birth
3006                                            ,l_cur_per_rec.date_of_birth)
3007      ,p_marital_status               => NVL(l_per_rec.marital_status
3008                                            ,l_cur_per_rec.marital_status)
3009      ,p_middle_names                 => NVL(l_per_rec.middle_names
3010                                            ,l_cur_per_rec.middle_names)
3011      ,p_sex                          => NVL(l_per_rec.sex
3012                                            ,l_cur_per_rec.sex)
3013      ,p_title                        => NVL(l_per_rec.title
3014                                            ,l_cur_per_rec.title)
3015      ,p_nationality                  => NVL(l_per_rec.nationality
3016                                            ,l_cur_per_rec.nationality)
3017      ,p_previous_last_name           => NVL(l_per_rec.previous_last_name
3018                                            ,l_cur_per_rec.previous_last_name)
3019      ,p_national_identifier          => NVL(l_per_rec.national_identifier
3020                                            ,l_cur_per_rec.national_identifier)
3021      ,p_known_as                     => NVL(l_per_rec.known_as
3022                                            ,l_cur_per_rec.known_as)
3023      ,p_email_address                => NVL(l_per_rec.email_address
3024                                            ,l_cur_per_rec.email_address)
3025      ,p_registered_disabled_flag     => NVL(l_per_rec.registered_disabled_flag
3026                                         ,l_cur_per_rec.registered_disabled_flag)
3027      ,p_date_employee_data_verified  =>NVL(l_per_rec.date_employee_data_verified
3028                                      ,l_cur_per_rec.date_employee_data_verified)
3029     ,p_expense_check_send_to_addres=>NVL(l_per_rec.expense_check_send_to_address
3030                                    ,l_cur_per_rec.expense_check_send_to_address)
3031      ,p_per_information_category     => l_per_rec.per_information_category
3032      ,p_per_information1             => l_per_rec.per_information1
3033      ,p_per_information2             => l_per_rec.per_information2
3034      ,p_per_information3             => l_per_rec.per_information3
3035      ,p_per_information4             => l_per_rec.per_information4
3036      ,p_per_information5             => l_per_rec.per_information5
3037      ,p_per_information6             => l_per_rec.per_information6
3038      ,p_per_information7             => l_per_rec.per_information7
3039      ,p_per_information8             => l_per_rec.per_information8
3040      ,p_per_information9             => l_per_rec.per_information9
3041      ,p_per_information10            => l_per_rec.per_information10
3042      ,p_per_information11            => l_per_rec.per_information11
3043      ,p_per_information12            => l_per_rec.per_information12
3044      ,p_per_information13            => l_per_rec.per_information13
3045      ,p_per_information14            => l_per_rec.per_information14
3046      ,p_per_information15            => l_per_rec.per_information15
3047      ,p_per_information16            => l_per_rec.per_information16
3048      ,p_per_information17            => l_per_rec.per_information17
3049      ,p_per_information18            => l_per_rec.per_information18
3050      ,p_per_information19            => l_per_rec.per_information19
3051      ,p_per_information20            => l_per_rec.per_information20
3052      ,p_per_information21            => l_per_rec.per_information21
3053      ,p_per_information22            => l_per_rec.per_information22
3054      ,p_per_information23            => l_per_rec.per_information23
3055      ,p_per_information24            => l_per_rec.per_information24
3056      ,p_per_information25            => l_per_rec.per_information25
3057      ,p_per_information26            => l_per_rec.per_information26
3058      ,p_per_information27            => l_per_rec.per_information27
3059      ,p_per_information28            => l_per_rec.per_information28
3060      ,p_per_information29            => l_per_rec.per_information29
3061      ,p_per_information30            => l_per_rec.per_information30
3062      -- Person DF
3063      ,p_attribute_category           => l_per_rec.attribute_category
3064      ,p_attribute1                   => l_per_rec.attribute1
3065      ,p_attribute2                   => l_per_rec.attribute2
3066      ,p_attribute3                   => l_per_rec.attribute3
3067      ,p_attribute4                   => l_per_rec.attribute4
3068      ,p_attribute5                   => l_per_rec.attribute5
3069      ,p_attribute6                   => l_per_rec.attribute6
3070      ,p_attribute7                   => l_per_rec.attribute7
3071      ,p_attribute8                   => l_per_rec.attribute8
3072      ,p_attribute9                   => l_per_rec.attribute9
3073      ,p_attribute10                  => l_per_rec.attribute10
3074      ,p_attribute11                  => l_per_rec.attribute11
3075      ,p_attribute12                  => l_per_rec.attribute12
3076      ,p_attribute13                  => l_per_rec.attribute13
3077      ,p_attribute14                  => l_per_rec.attribute14
3078      ,p_attribute15                  => l_per_rec.attribute15
3079      ,p_attribute16                  => l_per_rec.attribute16
3080      ,p_attribute17                  => l_per_rec.attribute17
3081      ,p_attribute18                  => l_per_rec.attribute18
3082      ,p_attribute19                  => l_per_rec.attribute19
3083      ,p_attribute20                  => l_per_rec.attribute20
3084      ,p_attribute21                  => l_per_rec.attribute21
3085      ,p_attribute22                  => l_per_rec.attribute22
3086      ,p_attribute23                  => l_per_rec.attribute23
3087      ,p_attribute24                  => l_per_rec.attribute24
3088      ,p_attribute25                  => l_per_rec.attribute25
3089      ,p_attribute26                  => l_per_rec.attribute26
3090      ,p_attribute27                  => l_per_rec.attribute27
3091      ,p_attribute28                  => l_per_rec.attribute28
3092      ,p_attribute29                  => l_per_rec.attribute29
3093      ,p_attribute30                  => l_per_rec.attribute30
3094    --,p_vendor_id                    => l_per_rec.vendor_id
3095    --,p_work_telephone               => l_per_rec.vendor_id
3096      ,p_date_of_death                => NVL(l_per_rec.date_of_death
3097                                            ,l_cur_per_rec.date_of_death)
3098      ,p_background_check_status      => NVL(l_per_rec.background_check_status
3099                                         ,l_cur_per_rec.background_check_status)
3100      ,p_background_date_check        => NVL(l_per_rec.background_date_check
3101                                            ,l_cur_per_rec.background_date_check)
3102      ,p_blood_type                   => NVL(l_per_rec.blood_type
3103                                            ,l_cur_per_rec.blood_type)
3104      ,p_correspondence_language      => NVL(l_per_rec.correspondence_language
3105                                         ,l_cur_per_rec.correspondence_language)
3106    --,p_fast_path_employee           IN  Varchar2 DEFAULT Hr_Api.g_Varchar2
3107      ,p_fte_capacity                 => NVL(l_per_rec.fte_capacity
3108                                            ,l_cur_per_rec.fte_capacity)
3109      ,p_hold_applicant_date_until    => NVL(l_per_rec.hold_applicant_date_until
3110                                        ,l_cur_per_rec.hold_applicant_date_until)
3111      ,p_honors                       => NVL(l_per_rec.honors
3112                                            ,l_cur_per_rec.honors)
3113      ,p_internal_location            => NVL(l_per_rec.internal_location
3114                                            ,l_cur_per_rec.internal_location)
3115      ,p_last_medical_test_by         => NVL(l_per_rec.last_medical_test_by
3116                                            ,l_cur_per_rec.last_medical_test_by)
3117      ,p_last_medical_test_date       => NVL(l_per_rec.last_medical_test_date
3118                                           ,l_cur_per_rec.last_medical_test_date)
3119      ,p_mailstop                     => NVL(l_per_rec.mailstop
3120                                            ,l_cur_per_rec.mailstop)
3121      ,p_office_number                => NVL(l_per_rec.office_number
3122                                            ,l_cur_per_rec.office_number)
3123      ,p_on_military_service          => NVL(l_per_rec.on_military_service
3124                                            ,l_cur_per_rec.on_military_service)
3125      ,p_pre_name_adjunct             => NVL(l_per_rec.pre_name_adjunct
3126                                            ,l_cur_per_rec.pre_name_adjunct)
3127      ,p_projected_start_date         => NVL(l_per_rec.projected_start_date
3128                                            ,l_cur_per_rec.projected_start_date)
3129      ,p_rehire_authorizor            => NVL(l_per_rec.rehire_authorizor
3130                                            ,l_cur_per_rec.rehire_authorizor)
3131      ,p_rehire_recommendation        => NVL(l_per_rec.rehire_recommendation
3132                                            ,l_cur_per_rec.rehire_recommendation)
3133      ,p_resume_exists                => NVL(l_per_rec.resume_exists
3134                                            ,l_cur_per_rec.resume_exists)
3135      ,p_resume_last_updated          => NVL(l_per_rec.resume_last_updated
3136                                            ,l_cur_per_rec.resume_last_updated)
3137      ,p_second_passport_exists       => NVL(l_per_rec.second_passport_exists
3138                                           ,l_cur_per_rec.second_passport_exists)
3139      ,p_student_status               => NVL(l_per_rec.student_status
3140                                            ,l_cur_per_rec.student_status)
3141      ,p_work_schedule                => NVL(l_per_rec.work_schedule
3142                                            ,l_cur_per_rec.work_schedule)
3143      ,p_rehire_reason                => NVL(l_per_rec.rehire_reason
3144                                            ,l_cur_per_rec.rehire_reason)
3145      ,p_suffix                       => NVL(l_per_rec.suffix
3146                                            ,l_cur_per_rec.suffix)
3147      ,p_benefit_group                => NVL(l_per_rec.benefit_group_id
3148                                            ,l_cur_per_rec.benefit_group_id)
3149      ,p_receipt_of_death_cert_date   => NVL(l_per_rec.receipt_of_death_cert_date
3150                                       ,l_cur_per_rec.receipt_of_death_cert_date)
3151      ,p_coord_ben_med_pln_no         => NVL(l_per_rec.coord_ben_med_pln_no
3152                                            ,l_cur_per_rec.coord_ben_med_pln_no)
3153      ,p_coord_ben_no_cvg_flag        => NVL(l_per_rec.coord_ben_no_cvg_flag
3154                                            ,l_cur_per_rec.coord_ben_no_cvg_flag)
3155      ,p_coord_ben_med_ext_er         => NVL(l_per_rec.coord_ben_med_ext_er
3156                                            ,l_cur_per_rec.coord_ben_med_ext_er)
3157      ,p_coord_ben_med_pl_name        => NVL(l_per_rec.coord_ben_med_pl_name
3158                                            ,l_cur_per_rec.coord_ben_med_pl_name)
3159      ,p_coord_ben_med_insr_crr_name  =>NVL(l_per_rec.coord_ben_med_insr_crr_name
3160                                      ,l_cur_per_rec.coord_ben_med_insr_crr_name)
3161      ,p_coord_ben_med_insr_crr_ident=>NVL(l_per_rec.coord_ben_med_insr_crr_ident
3162                                     ,l_cur_per_rec.coord_ben_med_insr_crr_ident)
3163      ,p_coord_ben_med_cvg_strt_dt    => NVL(l_per_rec.coord_ben_med_cvg_strt_dt
3164                                        ,l_cur_per_rec.coord_ben_med_cvg_strt_dt)
3165      ,p_coord_ben_med_cvg_end_dt     => NVL(l_per_rec.coord_ben_med_cvg_end_dt
3166                                         ,l_cur_per_rec.coord_ben_med_cvg_end_dt)
3167      ,p_uses_tobacco_flag            => NVL(l_per_rec.uses_tobacco_flag
3168                                            ,l_cur_per_rec.uses_tobacco_flag)
3169      ,p_dpdnt_adoption_date          => NVL(l_per_rec.dpdnt_adoption_date
3170                                            ,l_cur_per_rec.dpdnt_adoption_date)
3171      ,p_dpdnt_vlntry_svce_flag       => NVL(l_per_rec.dpdnt_vlntry_svce_flag
3172                                          ,l_cur_per_rec.dpdnt_vlntry_svce_flag)
3173      ,p_original_date_of_hire        => NVL(l_per_rec.original_date_of_hire
3174                                           ,l_cur_per_rec.original_date_of_hire)
3175      ,p_adjusted_svc_date            => p_adjusted_svc_date
3176      ,p_town_of_birth                => NVL(l_per_rec.town_of_birth
3177                                            ,l_cur_per_rec.town_of_birth)
3178      ,p_region_of_birth              => NVL(l_per_rec.region_of_birth
3179                                            ,l_cur_per_rec.region_of_birth)
3180      ,p_country_of_birth             => NVL(l_per_rec.country_of_birth
3181                                            ,l_cur_per_rec.country_of_birth)
3182      ,p_global_person_id             => NVL(l_per_rec.global_person_id
3183                                            ,l_cur_per_rec.global_person_id)
3184      ,p_person_user_key              => l_person_user_key
3185      ,p_user_person_type             => l_user_person_type
3186      ,p_language_code                => Userenv('lang')
3187      ,p_vendor_name                  => NULL
3188      );
3189 
3190      l_user_sequence := l_user_sequence + 1;
3191 
3192   END IF;
3193 
3194   -- Open Cursor to check if Address with Employee Number Already exists
3195   OPEN  csr_ck_add_xsts(c_person_id         => l_per_rec.person_id
3196                        ,c_business_group_id => l_add_rec.business_group_id
3197                        ,c_effective_date    => l_per_rec.START_DATE
3198                        ,c_primary_flag      => NVL(l_add_rec.primary_flag,
3199 		                                   'Y'));
3200   FETCH csr_ck_add_xsts INTO l_cur_add_rec;
3201 
3202   -- Create Address if Address Doesn't exist or if it is being created for
3203   -- new Person
3204   IF csr_ck_add_xsts%FOUND AND p_dp_mode = 'UPDATE' AND
3205      l_add_rec.address_line1 IS NOT NULL THEN
3206 
3207      -- Set the p_pradd_ovlapval_override to TURE and create address if address
3208      -- already exists.But if address record has from_date same as effective
3209      -- date then update it
3210 
3211      IF Trunc(l_per_rec.START_DATE) =
3212         Trunc(l_cur_add_rec.date_from) THEN
3213 
3214         Hrdpp_Update_Person_Address.Insert_Batch_Lines
3215         (p_batch_id                       => p_batch_id
3216         ,p_user_sequence                  => l_user_sequence
3217         ,p_link_value                     => l_link_value
3218         ,p_effective_date                 => l_per_rec.START_DATE
3219         ,p_validate_county                => TRUE
3220         ,p_primary_flag                   => NVL(l_add_rec.primary_flag, 'Y')
3221         ,p_date_from                      => l_add_rec.date_from
3222         ,p_date_to                        => l_add_rec.date_to
3223         ,p_address_type                   => l_add_rec.address_type
3224         --,p_comments                       => p_adr_comments
3225         ,p_address_line1                  => l_add_rec.address_line1
3226         ,p_address_line2                  => l_add_rec.address_line2
3227         ,p_address_line3                  => l_add_rec.address_line3
3228         ,p_town_or_city                   => l_add_rec.town_or_city
3229         ,p_region_1                       => l_add_rec.region_1
3230         ,p_region_2                       => l_add_rec.region_2
3231         ,p_region_3                       => l_add_rec.region_3
3232         ,p_postal_code                    => l_add_rec.postal_code
3233         ,p_telephone_number_1             => l_add_rec.telephone_number_1
3234         ,p_telephone_number_2             => l_add_rec.telephone_number_2
3235         ,p_telephone_number_3             => l_add_rec.telephone_number_3
3236         ,p_addr_attribute_category        => l_add_rec.addr_attribute_category
3237         ,p_addr_attribute1                => l_add_rec.addr_attribute1
3238         ,p_addr_attribute2                => l_add_rec.addr_attribute2
3239         ,p_addr_attribute3                => l_add_rec.addr_attribute3
3240         ,p_addr_attribute4                => l_add_rec.addr_attribute4
3241         ,p_addr_attribute5                => l_add_rec.addr_attribute5
3242         ,p_addr_attribute6                => l_add_rec.addr_attribute6
3243         ,p_addr_attribute7                => l_add_rec.addr_attribute7
3244         ,p_addr_attribute8                => l_add_rec.addr_attribute8
3245         ,p_addr_attribute9                => l_add_rec.addr_attribute9
3246         ,p_addr_attribute10               => l_add_rec.addr_attribute10
3247         ,p_addr_attribute11               => l_add_rec.addr_attribute11
3248         ,p_addr_attribute12               => l_add_rec.addr_attribute12
3249         ,p_addr_attribute13               => l_add_rec.addr_attribute13
3250         ,p_addr_attribute14               => l_add_rec.addr_attribute14
3251         ,p_addr_attribute15               => l_add_rec.addr_attribute15
3252         ,p_addr_attribute16               => l_add_rec.addr_attribute16
3253         ,p_addr_attribute17               => l_add_rec.addr_attribute17
3254         ,p_addr_attribute18               => l_add_rec.addr_attribute18
3255         ,p_addr_attribute19               => l_add_rec.addr_attribute19
3256         ,p_addr_attribute20               => l_add_rec.addr_attribute20
3257         ,p_add_information13              => l_add_rec.add_information13
3258         ,p_add_information14              => l_add_rec.add_information14
3259         ,p_add_information15              => l_add_rec.add_information15
3260         ,p_add_information16              => l_add_rec.add_information16
3261         ,p_add_information17              => l_add_rec.add_information17
3262         ,p_add_information18              => l_add_rec.add_information18
3263         ,p_add_information19              => l_add_rec.add_information19
3264         ,p_add_information20              => l_add_rec.add_information20
3265         ,p_party_id                       => l_add_rec.party_id
3266         ,p_address_user_key               => l_address_user_key
3267         ,p_country                        => l_add_rec.country
3268         );
3269 
3270         l_user_sequence := l_user_sequence + 1;
3271 
3272       ELSIF Trunc(l_per_rec.START_DATE) >
3273             Trunc(l_cur_add_rec.date_from) THEN
3274 
3275       -- Create a person with p_pradd_ovlapval flag set to TRUE
3276 
3277         Hrdpp_Create_Person_Address.Insert_Batch_Lines
3278         (p_batch_id                       => p_batch_id
3279         ,p_user_sequence                  => l_user_sequence
3280         ,p_link_value                     => l_link_value
3281         ,p_effective_date                 => l_per_rec.START_DATE
3282         ,p_pradd_ovlapval_override        => TRUE
3283         ,p_validate_county                => TRUE
3284         ,p_primary_flag                   => NVL(l_add_rec.primary_flag, 'Y')
3285         ,p_style                          => l_add_rec.style
3286         ,p_date_from                      => l_add_rec.date_from
3287         ,p_date_to                        => l_add_rec.date_to
3288         ,p_address_type                   => l_add_rec.address_type
3289         --,p_comments                       => p_adr_comments
3290         ,p_address_line1                  => l_add_rec.address_line1
3291         ,p_address_line2                  => l_add_rec.address_line2
3292         ,p_address_line3                  => l_add_rec.address_line3
3293         ,p_town_or_city                   => l_add_rec.town_or_city
3294         ,p_region_1                       => l_add_rec.region_1
3295         ,p_region_2                       => l_add_rec.region_2
3296         ,p_region_3                       => l_add_rec.region_3
3297         ,p_postal_code                    => l_add_rec.postal_code
3298         ,p_telephone_number_1             => l_add_rec.telephone_number_1
3299         ,p_telephone_number_2             => l_add_rec.telephone_number_2
3300         ,p_telephone_number_3             => l_add_rec.telephone_number_3
3301         ,p_addr_attribute_category        => l_add_rec.addr_attribute_category
3302         ,p_addr_attribute1                => l_add_rec.addr_attribute1
3303         ,p_addr_attribute2                => l_add_rec.addr_attribute2
3304         ,p_addr_attribute3                => l_add_rec.addr_attribute3
3305         ,p_addr_attribute4                => l_add_rec.addr_attribute4
3306         ,p_addr_attribute5                => l_add_rec.addr_attribute5
3307         ,p_addr_attribute6                => l_add_rec.addr_attribute6
3308         ,p_addr_attribute7                => l_add_rec.addr_attribute7
3309         ,p_addr_attribute8                => l_add_rec.addr_attribute8
3310         ,p_addr_attribute9                => l_add_rec.addr_attribute9
3311         ,p_addr_attribute10               => l_add_rec.addr_attribute10
3312         ,p_addr_attribute11               => l_add_rec.addr_attribute11
3313         ,p_addr_attribute12               => l_add_rec.addr_attribute12
3314         ,p_addr_attribute13               => l_add_rec.addr_attribute13
3315         ,p_addr_attribute14               => l_add_rec.addr_attribute14
3316         ,p_addr_attribute15               => l_add_rec.addr_attribute15
3317         ,p_addr_attribute16               => l_add_rec.addr_attribute16
3318         ,p_addr_attribute17               => l_add_rec.addr_attribute17
3319         ,p_addr_attribute18               => l_add_rec.addr_attribute18
3320         ,p_addr_attribute19               => l_add_rec.addr_attribute19
3321         ,p_addr_attribute20               => l_add_rec.addr_attribute20
3322         ,p_add_information13              => l_add_rec.add_information13
3323         ,p_add_information14              => l_add_rec.add_information14
3324         ,p_add_information15              => l_add_rec.add_information15
3325         ,p_add_information16              => l_add_rec.add_information16
3326         ,p_add_information17              => l_add_rec.add_information17
3327         ,p_add_information18              => l_add_rec.add_information18
3328         ,p_add_information19              => l_add_rec.add_information19
3329         ,p_add_information20              => l_add_rec.add_information20
3330         ,p_party_id                       => l_add_rec.party_id
3331         ,p_address_user_key               => l_address_user_key
3332         ,p_person_user_key                => l_person_user_key
3333         ,p_country                        => l_add_rec.country
3334         );
3335 
3336         l_user_sequence := l_user_sequence + 1;
3337 
3338      END IF;
3339    END IF;
3340 
3341    -- Create Address If it was not found updated when From_Date was same as
3342    -- effective date. Else in rest all cases where address has been entered
3343    -- Create Person Address
3344 
3345    IF (l_add_rec.style IS NOT NULL AND
3346       csr_ck_add_xsts%NOTFOUND AND p_dp_mode = 'UPDATE') OR
3347       (l_add_rec.style IS NOT NULL AND p_dp_mode = 'INSERT')THEN
3348 
3349       Hrdpp_Create_Person_Address.Insert_Batch_Lines
3350       (p_batch_id                       => p_batch_id
3351       ,p_user_sequence                  => l_user_sequence
3352       ,p_link_value                     => l_link_value
3353       ,p_effective_date                 => l_per_rec.START_DATE
3354       ,p_pradd_ovlapval_override        => FALSE
3355       ,p_validate_county                => TRUE
3356       ,p_primary_flag                   => NVL(l_add_rec.primary_flag, 'Y')
3357       ,p_style                          => l_add_rec.style
3358       ,p_date_from                      => l_add_rec.date_from
3359       ,p_date_to                        => l_add_rec.date_to
3360       ,p_address_type                   => l_add_rec.address_type
3361       --,p_comments                       => p_adr_comments
3362       ,p_address_line1                  => l_add_rec.address_line1
3363       ,p_address_line2                  => l_add_rec.address_line2
3364       ,p_address_line3                  => l_add_rec.address_line3
3365       ,p_town_or_city                   => l_add_rec.town_or_city
3366       ,p_region_1                       => l_add_rec.region_1
3367       ,p_region_2                       => l_add_rec.region_2
3368       ,p_region_3                       => l_add_rec.region_3
3369       ,p_postal_code                    => l_add_rec.postal_code
3370       ,p_telephone_number_1             => l_add_rec.telephone_number_1
3371       ,p_telephone_number_2             => l_add_rec.telephone_number_2
3372       ,p_telephone_number_3             => l_add_rec.telephone_number_3
3373       ,p_addr_attribute_category        => l_add_rec.addr_attribute_category
3374       ,p_addr_attribute1                => l_add_rec.addr_attribute1
3375       ,p_addr_attribute2                => l_add_rec.addr_attribute2
3376       ,p_addr_attribute3                => l_add_rec.addr_attribute3
3377       ,p_addr_attribute4                => l_add_rec.addr_attribute4
3378       ,p_addr_attribute5                => l_add_rec.addr_attribute5
3379       ,p_addr_attribute6                => l_add_rec.addr_attribute6
3380       ,p_addr_attribute7                => l_add_rec.addr_attribute7
3381       ,p_addr_attribute8                => l_add_rec.addr_attribute8
3382       ,p_addr_attribute9                => l_add_rec.addr_attribute9
3383       ,p_addr_attribute10               => l_add_rec.addr_attribute10
3384       ,p_addr_attribute11               => l_add_rec.addr_attribute11
3385       ,p_addr_attribute12               => l_add_rec.addr_attribute12
3386       ,p_addr_attribute13               => l_add_rec.addr_attribute13
3387       ,p_addr_attribute14               => l_add_rec.addr_attribute14
3388       ,p_addr_attribute15               => l_add_rec.addr_attribute15
3389       ,p_addr_attribute16               => l_add_rec.addr_attribute16
3390       ,p_addr_attribute17               => l_add_rec.addr_attribute17
3391       ,p_addr_attribute18               => l_add_rec.addr_attribute18
3392       ,p_addr_attribute19               => l_add_rec.addr_attribute19
3393       ,p_addr_attribute20               => l_add_rec.addr_attribute20
3394       ,p_add_information13              => l_add_rec.add_information13
3395       ,p_add_information14              => l_add_rec.add_information14
3396       ,p_add_information15              => l_add_rec.add_information15
3397       ,p_add_information16              => l_add_rec.add_information16
3398       ,p_add_information17              => l_add_rec.add_information17
3399       ,p_add_information18              => l_add_rec.add_information18
3400       ,p_add_information19              => l_add_rec.add_information19
3401       ,p_add_information20              => l_add_rec.add_information20
3402       ,p_party_id                       => l_add_rec.party_id
3403       ,p_address_user_key               => l_address_user_key
3404       ,p_person_user_key                => l_person_user_key
3405       ,p_country                        => l_add_rec.country
3406       );
3407 
3408       l_user_sequence := l_user_sequence + 1;
3409 
3410       hr_utility.set_location('.Inserted into Hrdpp_Create_Person_Address', 40);
3411 
3412      END IF;
3413      CLOSE csr_ck_add_xsts ;
3414 
3415 
3416      -- If existing person then find datetrack update mode, else it will be
3417      -- 'CORRECTION'
3418 
3419      l_datetrack_update_mode := 'CORRECTION';
3420 
3421 --     IF p_dp_mode = 'UPDATE' THEN
3422 --
3423 --
3424 --        OPEN  csr_asg (c_effective_date    => l_per_rec.start_date
3425 --                      ,c_person_id         => l_per_rec.person_id
3426 --                      ,c_business_group_id => l_per_rec.business_group_id
3427 --                      );
3428 --        FETCH csr_asg INTO l_asg_rec.assignment_id,
3429 --                           l_asg_rec.object_version_number;
3430 --        IF csr_asg%NOTFOUND THEN
3431 --           CLOSE csr_asg;
3432 --           hr_utility.raise_error;
3433 --        END IF;
3434 --        CLOSE csr_asg;
3435 
3436 --        hr_utility.set_location(' l_cur_asg_rec: '||
3437 --                                  l_asg_rec.assignment_id, 6);
3438 
3439 --        Dt_Api.Find_DT_Upd_Modes
3440 --        (p_effective_date        => l_per_rec.start_date
3441 --        ,p_base_table_name       => 'PER_ALL_ASSIGNMENTS_F'
3442 --        ,p_base_key_column       => 'ASSIGNMENT_ID'
3443 --        ,p_base_key_value        => l_asg_rec.assignment_id
3444 --        ,p_correction            => l_dt_correction
3445 --        ,p_update                => l_dt_update
3446 --        ,p_update_override       => l_dt_upd_override
3447 --        ,p_update_change_insert  => l_upd_chg_ins
3448 --        );
3449 
3450 --        IF l_dt_update THEN
3451 --           l_datetrack_update_mode := 'UPDATE';
3452 --        ELSIF l_dt_upd_override OR
3453 --           l_upd_chg_ins THEN
3454            -- Need to check if person type in future is EMP, APL or CWK , if yes
3455            -- then raise error
3456 --           l_datetrack_update_mode := 'UPDATE';
3457 --           hr_utility.set_location(' l_dt_upd_override or' ||
3458 --                                   ' l_upd_chg_ins ', 20);
3459 --        ELSE
3460 --           l_datetrack_update_mode := 'CORRECTION';
3461 --        END IF;
3462 --        hr_utility.set_location(' l_datetrack_update_mode: ' ||
3463 --                                  l_datetrack_update_mode, 20);
3464 
3465 --     ELSE
3466 --       l_datetrack_update_mode := 'CORRECTION';
3467 --     END IF;
3468 
3469      Hrdpp_Update_Emp_Asg.Insert_Batch_Lines
3470      (p_batch_id                      => p_batch_id
3471      ,p_user_sequence                 => l_user_sequence
3472      ,p_link_value                    => l_link_value
3473      ,p_effective_date                => l_per_rec.START_DATE
3474      ,p_datetrack_update_mode         => l_datetrack_update_mode --'CORRECTION'
3475      ,p_change_reason                 => l_asg_rec.change_reason
3476      --,p_comments                      => l_asg_rec.asg_comments
3477      ,p_date_probation_end            => l_asg_rec.date_probation_end
3478      ,p_frequency                     => l_asg_rec.frequency
3479      ,p_internal_address_line         => l_asg_rec.internal_address_line
3480      ,p_manager_flag                  => l_asg_rec.manager_flag
3481      ,p_normal_hours                  => l_asg_rec.normal_hours
3482      ,p_perf_review_period            => l_asg_rec.perf_review_period
3483      ,p_perf_review_period_frequency  => l_asg_rec.perf_review_period_frequency
3484      ,p_probation_period              => l_asg_rec.probation_period
3485      ,p_probation_unit                => l_asg_rec.probation_unit
3486      ,p_sal_review_period             => l_asg_rec.sal_review_period
3487      ,p_sal_review_period_frequency   => l_asg_rec.sal_review_period_frequency
3488      ,p_source_type                   => l_asg_rec.source_type
3489      ,p_time_normal_finish            => l_asg_rec.time_normal_finish
3490      ,p_time_normal_start             => l_asg_rec.time_normal_start
3491      ,p_bargaining_unit_code          => l_asg_rec.bargaining_unit_code
3492      ,p_labour_union_member_flag      => l_asg_rec.labour_union_member_flag
3493      ,p_hourly_salaried_code          => l_asg_rec.hourly_salaried_code
3494      ,p_ass_attribute_category        => l_asg_rec.ass_attribute_category
3495      ,p_ass_attribute1                => l_asg_rec.ass_attribute1
3496      ,p_ass_attribute2                => l_asg_rec.ass_attribute2
3497      ,p_ass_attribute3                => l_asg_rec.ass_attribute3
3498      ,p_ass_attribute4                => l_asg_rec.ass_attribute4
3499      ,p_ass_attribute5                => l_asg_rec.ass_attribute5
3500      ,p_ass_attribute6                => l_asg_rec.ass_attribute6
3501      ,p_ass_attribute7                => l_asg_rec.ass_attribute7
3502      ,p_ass_attribute8                => l_asg_rec.ass_attribute8
3503      ,p_ass_attribute9                => l_asg_rec.ass_attribute9
3504      ,p_ass_attribute10               => l_asg_rec.ass_attribute10
3505      ,p_ass_attribute11               => l_asg_rec.ass_attribute11
3506      ,p_ass_attribute12               => l_asg_rec.ass_attribute12
3507      ,p_ass_attribute13               => l_asg_rec.ass_attribute13
3508      ,p_ass_attribute14               => l_asg_rec.ass_attribute14
3509      ,p_ass_attribute15               => l_asg_rec.ass_attribute15
3510      ,p_ass_attribute16               => l_asg_rec.ass_attribute16
3511      ,p_ass_attribute17               => l_asg_rec.ass_attribute17
3512      ,p_ass_attribute18               => l_asg_rec.ass_attribute18
3513      ,p_ass_attribute19               => l_asg_rec.ass_attribute19
3514      ,p_ass_attribute20               => l_asg_rec.ass_attribute20
3515      ,p_ass_attribute21               => l_asg_rec.ass_attribute21
3516      ,p_ass_attribute22               => l_asg_rec.ass_attribute22
3517      ,p_ass_attribute23               => l_asg_rec.ass_attribute23
3518      ,p_ass_attribute24               => l_asg_rec.ass_attribute24
3519      ,p_ass_attribute25               => l_asg_rec.ass_attribute25
3520      ,p_ass_attribute26               => l_asg_rec.ass_attribute26
3521      ,p_ass_attribute27               => l_asg_rec.ass_attribute27
3522      ,p_ass_attribute28               => l_asg_rec.ass_attribute28
3523      ,p_ass_attribute29               => l_asg_rec.ass_attribute29
3524      ,p_ass_attribute30               => l_asg_rec.ass_attribute30
3525      --,p_title                         => l_asg_rec.title
3526      ,p_segment1                      => l_hr_soft_rec.segment1
3527      ,p_segment2                      => l_hr_soft_rec.segment2
3528      ,p_segment3                      => l_hr_soft_rec.segment3
3529      ,p_segment4                      => l_hr_soft_rec.segment4
3530      ,p_segment5                      => l_hr_soft_rec.segment5
3531      ,p_segment6                      => l_hr_soft_rec.segment6
3532      ,p_segment7                      => l_hr_soft_rec.segment7
3533      ,p_segment8                      => l_hr_soft_rec.segment8
3534      ,p_segment9                      => l_hr_soft_rec.segment9
3535      ,p_cagr_grade_def_id             => NULL
3536      ,p_assignment_user_key           => l_assignment_user_key
3537      ,p_con_seg_user_name             => NULL
3538      );
3539 
3540      l_user_sequence := l_user_sequence + 1;
3541 
3542      hr_utility.set_location('..Inserted into Hrdpp_Update_Emp_Asg', 50);
3543 
3544 
3545      OPEN  csr_grade(l_asg_rec.grade_id
3546                     ,l_asg_rec.business_group_id
3547                     ,l_per_rec.START_DATE);
3548      FETCH csr_grade INTO l_grade_name;
3549      IF csr_grade%NOTFOUND THEN
3550         hr_utility.set_location('..Grade Name not found Id: ' ||
3551 	                         l_asg_rec.grade_id, 60);
3552      END IF;
3553      CLOSE csr_grade;
3554 
3555      OPEN  csr_position (l_asg_rec.position_id
3556                         ,l_asg_rec.business_group_id
3557                         ,l_per_rec.START_DATE);
3558      FETCH csr_position INTO l_position_name;
3559      IF csr_position%NOTFOUND THEN
3560         hr_utility.set_location('..Position Name not found Id: ' ||
3561                                 l_asg_rec.position_id, 70);
3562      END IF;
3563      CLOSE csr_position;
3564 
3565      OPEN  csr_job(l_asg_rec.job_id
3566                   ,l_asg_rec.business_group_id
3567                   ,l_per_rec.START_DATE);
3568      FETCH csr_job INTO l_job_name;
3569      IF csr_job%NOTFOUND THEN
3570         hr_utility.set_location('..Job Name not found Id: ' ||
3571                                 l_asg_rec.job_id, 80);
3572      END IF;
3573      CLOSE csr_job;
3574 
3575      OPEN  csr_payroll(l_asg_rec.payroll_id
3576                       ,l_asg_rec.business_group_id
3577                       ,l_per_rec.START_DATE);
3578      FETCH csr_payroll INTO l_payroll_name;
3579      IF csr_payroll%NOTFOUND THEN
3580         hr_utility.set_location('..Payroll Name not found Id: ' ||
3581                                 l_asg_rec.payroll_id, 90);
3582      END IF;
3583      CLOSE csr_payroll;
3584 
3585      OPEN  csr_location(l_asg_rec.location_id
3586                        ,l_asg_rec.business_group_id);
3587      FETCH csr_location INTO l_location_code;
3588      IF csr_location%NOTFOUND THEN
3589         hr_utility.set_location('..Location Code not found, Id: ' ||
3590                                 l_asg_rec.location_id, 100);
3591      END IF;
3592      CLOSE csr_location;
3593 
3594      OPEN  csr_organization(l_asg_rec.organization_id
3595                            ,l_asg_rec.business_group_id
3596                            ,l_per_rec.START_DATE);
3597      FETCH csr_organization INTO l_organization_name;
3598      IF csr_organization%NOTFOUND THEN
3599         hr_utility.set_location('..Org Name not found, Id: ' ||
3600                                 l_asg_rec.organization_id, 110);
3601      END IF;
3602      CLOSE csr_organization;
3603 
3604      OPEN  csr_paybasis(l_asg_rec.pay_basis_id
3605                        ,l_asg_rec.business_group_id);
3606      FETCH csr_paybasis INTO l_pay_basis_name;
3607      IF csr_paybasis%NOTFOUND THEN
3608         hr_utility.set_location('..Org Name not found, Id: ' ||
3609                                 l_asg_rec.pay_basis_id, 120);
3610      END IF;
3611      CLOSE csr_paybasis;
3612 
3613      Hrdpp_Update_Emp_Asg_Criteria.Insert_Batch_Lines
3614      (p_batch_id                => p_batch_id
3615      ,p_user_sequence           => l_user_sequence
3616      ,p_link_value              => l_link_value
3617      ,p_effective_date          => l_per_rec.START_DATE
3618      ,p_datetrack_update_mode   => l_datetrack_update_mode --'CORRECTION'
3619      ,p_segment1                => l_ppl_grp_rec.segment1
3620      ,p_segment2                => l_ppl_grp_rec.segment2
3621      ,p_segment3                => l_ppl_grp_rec.segment3
3622      ,p_segment4                => l_ppl_grp_rec.segment4
3623      ,p_segment5                => l_ppl_grp_rec.segment5
3624      ,p_segment6                => l_ppl_grp_rec.segment6
3625      ,p_segment7                => l_ppl_grp_rec.segment7
3626      ,p_segment8                => l_ppl_grp_rec.segment8
3627      ,p_segment9                => l_ppl_grp_rec.segment9
3628      ,p_segment10               => l_ppl_grp_rec.segment10
3629      ,p_segment11               => l_ppl_grp_rec.segment11
3630      ,p_segment12               => l_ppl_grp_rec.segment12
3631      ,p_segment13               => l_ppl_grp_rec.segment13
3632      ,p_segment14               => l_ppl_grp_rec.segment14
3633      ,p_segment15               => l_ppl_grp_rec.segment15
3634      ,p_segment16               => l_ppl_grp_rec.segment16
3635      ,p_segment17               => l_ppl_grp_rec.segment17
3636      ,p_segment18               => l_ppl_grp_rec.segment18
3637      ,p_segment19               => l_ppl_grp_rec.segment19
3638      ,p_segment20               => l_ppl_grp_rec.segment20
3639      ,p_segment21               => l_ppl_grp_rec.segment21
3640      ,p_segment22               => l_ppl_grp_rec.segment22
3641      ,p_segment23               => l_ppl_grp_rec.segment23
3642      ,p_segment24               => l_ppl_grp_rec.segment24
3643      ,p_segment25               => l_ppl_grp_rec.segment25
3644      ,p_segment26               => l_ppl_grp_rec.segment26
3645      ,p_segment27               => l_ppl_grp_rec.segment27
3646      ,p_segment28               => l_ppl_grp_rec.segment28
3647      ,p_segment29               => l_ppl_grp_rec.segment29
3648      ,p_segment30               => l_ppl_grp_rec.segment30
3649      ,p_special_ceiling_step_id => NULL
3650      ,p_people_group_id         => NULL
3651      ,p_assignment_user_key     => l_assignment_user_key
3652      ,p_grade_name              => l_grade_name
3653      ,p_position_name           => l_position_name
3654      ,p_job_name                => l_job_name
3655      ,p_payroll_name            => l_payroll_name
3656      ,p_location_code           => l_location_code
3657      ,p_organization_name       => l_organization_name
3658      ,p_pay_basis_name          => l_pay_basis_name
3659      ,p_language_code           => Userenv('LANG')
3660      ,p_con_seg_user_name       => NULL
3661      );
3662 
3663      l_user_sequence := l_user_sequence + 1;
3664 
3665      hr_utility.set_location('..Inserted into' ||
3666                              ' Hrdpp_Update_Emp_Asg_Criteria', 130);
3667 
3668   OPEN  csr_get_cont_dtls(c_person_id         => l_per_rec.person_id
3669                         ,c_business_group_id => l_add_rec.business_group_id
3670                         ,c_effective_date    => l_per_rec.START_DATE);
3671   FETCH csr_get_cont_dtls INTO l_cont_rec;
3672 
3673   -- Create Contact if Contact Doesn't exist or if it is being
3674   -- created for new Person. Also call the API only if l_cntct_rec.contact_type
3675   -- is not null
3676   IF (csr_get_cont_dtls%NOTFOUND OR p_dp_mode = 'INSERT') AND
3677      l_cntct_rec.contact_type IS NOT NULL THEN
3678 
3679      Hrdpp_Create_Contact.Insert_Batch_Lines
3680      (p_batch_id             => p_batch_id
3681      ,p_user_sequence        => l_user_sequence
3682      ,p_link_value           => l_link_value
3683      ,p_start_date           => l_per_rec.START_DATE
3684      ,p_contact_type         => l_cntct_rec.contact_type
3685      ,p_primary_contact_flag => l_cntct_rec.primary_contact_flag
3686      ,p_personal_flag        => l_cntct_rec.personal_flag
3687      ,p_last_name            => p_contact_name
3688      ,p_per_person_user_key  => l_contact_key
3689      ,p_person_user_key      => l_person_user_key
3690      ,p_language_code        => Userenv('LANG')
3691      );
3692 
3693      l_user_sequence := l_user_sequence + 1;
3694 
3695   ELSIF p_dp_mode = 'UPDATE' AND
3696      l_cntct_rec.contact_type IS NOT NULL THEN
3697 
3698      hr_pump_utils.add_user_key(p_user_key_value => l_contact_key
3699                                ,p_unique_key_id  => l_cont_rec.contact_person_id
3700                                );
3701 
3702      Hrdpp_Update_Contact_Relations.Insert_Batch_Lines
3703      (p_batch_id              => p_batch_id
3704      ,p_user_sequence         => l_user_sequence
3705      ,p_link_value            => l_link_value
3706      ,p_effective_date        => l_per_rec.START_DATE
3707      ,p_contact_type          => l_cntct_rec.contact_type
3708      ,p_primary_contact_flag  => l_cntct_rec.primary_contact_flag
3709      ,p_personal_flag         => l_cntct_rec.personal_flag
3710      ,p_object_version_number => l_cont_rec.object_version_number
3711      ,p_contact_user_key      => l_contact_key --l_person_user_key
3712      ,p_contactee_user_key    => l_person_user_key
3713      );
3714 
3715      l_user_sequence := l_user_sequence + 1;
3716 
3717   END IF;
3718   CLOSE csr_get_cont_dtls;
3719 
3720   hr_utility.set_location('..Inserted into Hrdpp_Create_Contact', 140);
3721 
3722   -- Call to People Extra Information Procedure
3723   HR_DataPump_Per_XtraInfo
3724          (p_business_group_id => l_per_rec.business_group_id
3725          ,p_person_id         => l_per_rec.person_id
3726          ,p_party_id          => l_per_rec.party_id
3727          ,p_effective_date    => l_per_rec.START_DATE
3728          ,p_batch_id          => p_batch_id
3729          ,p_user_sequence     => l_user_sequence
3730          ,p_link_value        => l_link_value
3731          ,p_xtra_info_key     => l_xtra_info_key
3732          ,p_person_user_key   => l_person_user_key
3733          );
3734 
3735   l_user_sequence := l_user_sequence + 1;
3736 
3737   hr_utility.set_location('..Called HR_DataPump_Per_XtraInfo', 150);
3738 
3739   hr_utility.set_location('Leaving: ' || l_proc_name, 160);
3740 
3741 EXCEPTION
3742   WHEN Others THEN
3743        IF csr_asg%ISOPEN THEN
3744           CLOSE csr_asg;
3745        END IF;
3746 
3747        IF csr_get_link_value%ISOPEN THEN
3748           CLOSE csr_get_link_value;
3749        END IF;
3750 
3751        IF csr_per%ISOPEN THEN
3752           CLOSE csr_per;
3753        END IF;
3754 
3755        IF csr_per_type%ISOPEN THEN
3756           CLOSE csr_per_type;
3757        END IF;
3758 
3759        IF csr_get_employee_num%ISOPEN THEN
3760           CLOSE csr_get_employee_num;
3761        END IF;
3762 
3763        IF csr_ck_add_xsts%ISOPEN THEN
3764           CLOSE csr_ck_add_xsts;
3765        END IF;
3766 
3767        IF csr_get_cont_dtls%ISOPEN THEN
3768           CLOSE csr_get_cont_dtls;
3769        END IF;
3770 
3771        hr_utility.set_location('Leaving: ' || l_proc_name, 170);
3772 
3773   RAISE;
3774 
3775 END HR_DataPump;
3776 
3777 
3778 -- =============================================================================
3779 -- ~ HR_DataPumpErr:
3780 -- =============================================================================
3781 PROCEDURE HR_DataPumpErr
3782           (p_data_pump_batch_line_id IN Varchar2
3783           ,p_batch_id                IN Number
3784           ,p_contact_name            IN Varchar
3785 --          ,p_dp_mode                 IN Varchar
3786           ,p_adjusted_svc_date       IN Date
3787           )
3788 AS
3789 
3790   -- Cursor gets the mode in which data was entered intially in
3791   -- DP interface tables
3792   CURSOR csr_get_dp_mode (c_batch_id   IN Number
3793                          ,c_link_value IN Number) IS
3794   SELECT 'CREATE'
3795     FROM hr_api_modules
3796    WHERE module_name    = 'CREATE_EMPLOYEE'
3797      AND module_package = 'HR_EMPLOYEE_API'
3798      AND api_module_id IN (SELECT api_module_id
3799                              FROM hr_pump_batch_lines
3800                             WHERE batch_id   = c_batch_id
3801                               AND link_value = c_link_value);
3802 
3803   -- Cursor to get all the api_ids which have LINE_STATUS in status 'C' or 'U'
3804   CURSOR csr_get_api_names (c_batch_id   IN Number
3805                            ,c_link_value IN Number) IS
3806   SELECT module_name
3807     FROM hr_pump_batch_lines hpbl, hr_api_modules ham
3808    WHERE batch_id    = c_batch_id
3809      AND link_value  = c_link_value
3810      AND line_status IN ('U', 'E')
3811      AND hpbl.api_module_id = ham.api_module_id;
3812 
3813 -- Not Required, Delete Later
3814 --  -- Cursor to check if Address was End Dated or Updated
3815 --  CURSOR csr_chk_add_end_dated (c_batch_id   IN Number
3816 --                               ,c_link_value IN Number) IS
3817 --  SELECT 'END DATED'
3818 --  FROM dual
3819 --  WHERE
3820 --      'UPDATE_PERSON_ADDRESS' IN
3821 --      (SELECT module_name
3822 --         FROM hr_pump_batch_lines hpbl, hr_api_modules ham
3823 --        WHERE batch_id           = c_batch_id
3824 --          AND link_value         = c_link_value
3825 --          AND hpbl.api_module_id = ham.api_module_id
3826 --          AND line_status     IN ('U', 'E'))
3827 --  AND 'CREATE_PERSON_ADDRESS' IN
3828 --      (SELECT module_name
3829 --         FROM hr_pump_batch_lines hpbl, hr_api_modules ham
3830 --        WHERE batch_id           = c_batch_id
3831 --          AND link_value         = c_link_value
3832 --          AND hpbl.api_module_id = ham.api_module_id
3833 --          AND line_status     IN ('U', 'E'));
3834 
3835   -- Cursor to get previous data from hrdpv_hire_into_job
3836   CURSOR csr_get_hire_job_data (c_batch_id   IN Number
3837                                ,c_link_value IN Number) IS
3838   SELECT *
3839     FROM hrdpv_hire_into_job
3840    WHERE batch_id   = c_batch_id
3841      AND link_value = c_link_value;
3842 
3843   l_dp_hire_job_rec      hrdpv_hire_into_job%ROWTYPE;
3844 
3845   -- Cursor to get previous data from hrdpv_create_employee
3846   CURSOR csr_get_create_emp_data (c_batch_id   IN Number
3847                                  ,c_link_value IN Number) IS
3848   SELECT *
3849     FROM hrdpv_create_employee
3850    WHERE batch_id   = c_batch_id
3851      AND link_value = c_link_value;
3852 
3853   l_dp_crt_emp_rec       hrdpv_create_employee%ROWTYPE;
3854 
3855   -- Cursor to get previous data from hrdpv_update_person
3856   CURSOR csr_get_update_per_data (c_batch_id   IN Number
3857                                  ,c_link_value IN Number) IS
3858   SELECT *
3859     FROM hrdpv_update_person
3860    WHERE batch_id   = c_batch_id
3861      AND link_value = c_link_value;
3862 
3863   l_dp_upd_per_rec       hrdpv_update_person%ROWTYPE;
3864 
3865   -- Cursor to get previous data from hrdpv_update_person_address
3866   CURSOR csr_get_update_add_data (c_batch_id   IN Number
3867                                  ,c_link_value IN Number) IS
3868   SELECT *
3869     FROM hrdpv_update_person_address
3870    WHERE batch_id   = c_batch_id
3871      AND link_value = c_link_value;
3872 
3873   l_dp_upd_add_rec       hrdpv_update_person_address%ROWTYPE;
3874 
3875   -- Cursor to get previous data from hrdpv_create_person_address
3876   CURSOR csr_get_create_add_data (c_batch_id   IN Number
3877                                  ,c_link_value IN Number) IS
3878   SELECT *
3879     FROM hrdpv_create_person_address
3880    WHERE batch_id   = c_batch_id
3881      AND link_value = c_link_value;
3882 
3883   l_dp_crt_add_rec       hrdpv_create_person_address%ROWTYPE;
3884 
3885   -- Cursor to get previous data from hrdpv_update_emp_asg
3886   CURSOR csr_get_upd_asg_data (c_batch_id   IN Number
3887                               ,c_link_value IN Number) IS
3888   SELECT *
3889     FROM hrdpv_update_emp_asg
3890    WHERE batch_id   = c_batch_id
3891      AND link_value = c_link_value;
3892 
3893   l_dp_upd_asg_rec       hrdpv_update_emp_asg%ROWTYPE;
3894 
3895   -- Cursor to get previous data from hrdpv_update_emp_asg_criteria
3896   CURSOR csr_get_upd_asg_crt_data (c_batch_id   IN Number
3897                                    ,c_link_value IN Number) IS
3898   SELECT *
3899     FROM hrdpv_update_emp_asg_criteria
3900    WHERE batch_id   = c_batch_id
3901      AND link_value = c_link_value;
3902 
3903   l_dp_upd_asg_crt_rec   hrdpv_update_emp_asg_criteria%ROWTYPE;
3904 
3905   -- Cursor to get previous data from hrdpv_create_contact
3906   CURSOR csr_get_create_cnt_data (c_batch_id   IN Number
3907                                  ,c_link_value IN Number) IS
3908   SELECT *
3909     FROM hrdpv_create_contact
3910    WHERE batch_id   = c_batch_id
3911      AND link_value = c_link_value;
3912 
3913   l_dp_crt_cnt_rec       hrdpv_create_contact%ROWTYPE;
3914 
3915   -- Cursor to get previous data from hrdpv_update_contact_relations
3916   CURSOR csr_get_update_cnt_data (c_batch_id   IN Number
3917                                  ,c_link_value IN Number) IS
3918   SELECT *
3919     FROM hrdpv_update_contact_relations
3920    WHERE batch_id   = c_batch_id
3921      AND link_value = c_link_value;
3922 
3923   l_dp_upd_cnt_rec      hrdpv_update_contact_relations%ROWTYPE;
3924 
3925   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'HR_DataPumpErr';
3926 
3927   l_dp_mode                  Varchar2(10);
3928   l_if_end_dated             Varchar2(20);
3929   l_api_name                 hr_api_modules.module_name%TYPE;
3930   l_user_person_type         per_person_types.user_person_type%TYPE;
3931   l_pay_basis_name           per_pay_bases.NAME%TYPE;
3932   l_organization_name        hr_all_organization_units.NAME%TYPE;
3933   l_location_code            hr_locations_all.location_code%TYPE;
3934   l_payroll_name             pay_payrolls_f.payroll_name%TYPE;
3935   l_job_name                 per_jobs.NAME%TYPE;
3936   l_position_name            per_positions.NAME%TYPE;
3937   l_grade_name               per_grades.NAME%TYPE;
3938 
3939   l_pradd_ovlapval_override  Boolean;
3940 
3941 BEGIN
3942   hr_utility.set_location('Entering: ' || l_proc_name, 10);
3943 
3944   -- Check if operation being corrected was insert or update because of
3945   -- duplicate person id based on the API_MODULE_ID in hr_pump_batch_lines
3946   -- and then set dp_mode flag respectively
3947 
3948   OPEN csr_get_dp_mode (c_batch_id   => p_batch_id
3949                        ,c_link_value => p_data_pump_batch_line_id
3950                        );
3951   FETCH csr_get_dp_mode INTO l_dp_mode;
3952   CLOSE csr_get_dp_mode;
3953 
3954   IF l_dp_mode = NULL THEN
3955      l_dp_mode := 'UPDATE';
3956   END IF;
3957 
3958   -- Cursor to get the User Person Type
3959   OPEN  csr_per_type(l_per_rec.person_type_id
3960                     ,l_per_rec.business_group_id);
3961   FETCH csr_per_type INTO l_user_person_type;
3962   CLOSE csr_per_type;
3963 
3964   -- If User hasn't entered the Employee Number, then get Employee Number
3965   -- for entered duplicate person id
3966   IF l_per_rec.employee_number = NULL THEN
3967      OPEN  csr_get_employee_num(c_person_id => l_per_rec.person_id);
3968      FETCH csr_get_employee_num INTO l_per_rec.employee_number;
3969      CLOSE csr_get_employee_num;
3970   END IF;
3971 
3972   -- Call a cursor to get all the API_MODULE_IDs for the respective batch_id
3973   -- where LINE_STATUS is either in 'E' (error) or in 'U' (unprocessed) mode
3974 
3975   OPEN csr_get_api_names (c_batch_id   => p_batch_id
3976                          ,c_link_value => p_data_pump_batch_line_id
3977                          );
3978 
3979   -- For all the API_MODULE_IDs hence obtained run the cursor and call
3980   -- corresponding HR Data Pump Insert_Batch_Lines APIs. Before calling the
3981   -- Insert_Batch_Lines call the cursor to get the previous values in DP
3982   -- Interface Tables
3983   --
3984   -- NOTE : We will be calling the same "INSERT_BATCH_LINES" for updation
3985   --        as internally "INSERT_BATCH_LINES" deletes the previous entry
3986   --        for corresponding Batch_line_Id and makes a fresh entry.
3987   --        Hence, in the cursor we will temporarily store some of the data
3988   --        which we will require in newly created entry in HR_PUMP_BATCH_LINES
3989 
3990 
3991   LOOP
3992 
3993     FETCH csr_get_api_names INTO l_api_name;
3994     EXIT WHEN csr_get_api_names%NOTFOUND;
3995 
3996 
3997     -- Call if API_ID is 'Hire_Into_Job'
3998     IF l_api_name = 'HIRE_INTO_JOB' THEN
3999 
4000        -- Call a cursor to get the current data in DP Interface Tables
4001        OPEN  csr_get_hire_job_data (c_batch_id   => p_batch_id
4002                                    ,c_link_value => p_data_pump_batch_line_id);
4003        FETCH csr_get_hire_job_data INTO l_dp_hire_job_rec;
4004        CLOSE csr_get_hire_job_data;
4005 
4006        -- Call Insert_Batch_lines
4007        Hrdpp_Hire_Into_Job.insert_batch_lines
4008        (p_batch_id                => p_batch_id
4009        --l_dp_batch_line_id_hire
4010        ,p_data_pump_batch_line_id => l_dp_hire_job_rec.batch_line_id
4011        ,p_user_sequence           => l_dp_hire_job_rec.user_sequence
4012        ,p_link_value              => p_data_pump_batch_line_id
4013        ,p_effective_date          => l_per_rec.start_date
4014        ,p_object_version_number   => l_dp_hire_job_rec.p_object_version_number
4015        ,p_datetrack_update_mode   => l_dp_hire_job_rec.p_datetrack_update_mode
4016        ,p_employee_number         => l_per_rec.employee_number
4017        ,p_national_identifier     => l_per_rec.national_identifier
4018        ,p_per_information7        => NULL
4019        ,p_person_user_key         => l_dp_hire_job_rec.p_person_user_key
4020        ,p_user_person_type        => l_user_person_type
4021        ,p_assignment_user_key     => l_dp_hire_job_rec.p_assignment_user_key
4022        ,p_language_code           => Userenv('LANG')
4023        );
4024 
4025     END IF;
4026 
4027     -- Call if API_ID is 'Create_Employee'
4028     IF l_api_name = 'CREATE_EMPLOYEE' THEN
4029 
4030        OPEN  csr_get_create_emp_data(c_batch_id   => p_batch_id
4031                                     ,c_link_value => p_data_pump_batch_line_id
4032                                     );
4033        FETCH csr_get_create_emp_data INTO l_dp_crt_emp_rec;
4034        CLOSE csr_get_create_emp_data;
4035 
4036        Hrdpp_Create_Employee.Insert_Batch_Lines
4037        (p_batch_id                     => p_batch_id
4038        --l_dp_batch_line_id_emp
4039        ,p_data_pump_batch_line_id      => l_dp_crt_emp_rec.batch_line_id
4040        ,p_user_sequence                => l_dp_crt_emp_rec.user_sequence
4041        ,p_link_value                   => p_data_pump_batch_line_id
4042        ,p_hire_date                    => l_per_rec.start_date
4043        ,p_last_name                    => l_per_rec.last_name
4044        ,p_sex                          => l_per_rec.sex
4045        --,p_per_comments                 => l_per_rec.comments
4046        ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
4047        ,p_date_of_birth                => l_per_rec.date_of_birth
4048        ,p_email_address                => l_per_rec.email_address
4049        ,p_employee_number              => l_per_rec.employee_number
4050        ,p_expense_check_send_to_addres =>l_per_rec.expense_check_send_to_address
4051        ,p_first_name                   => l_per_rec.first_name
4052        ,p_known_as                     => l_per_rec.known_as
4053        ,p_marital_status               => l_per_rec.marital_status
4054        ,p_middle_names                 => l_per_rec.middle_names
4055        ,p_nationality                  => l_per_rec.nationality
4056        ,p_national_identifier          => l_per_rec.national_identifier
4057        ,p_previous_last_name           => l_per_rec.previous_last_name
4058        ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
4059        ,p_title                        => l_per_rec.title
4060        --,p_work_telephone               => p_telephone_no1
4061        ,p_attribute_category           => l_per_rec.attribute_category
4062        ,p_attribute1                   => l_per_rec.attribute1
4063        ,p_attribute2                   => l_per_rec.attribute2
4064        ,p_attribute3                   => l_per_rec.attribute3
4065        ,p_attribute4                   => l_per_rec.attribute4
4066        ,p_attribute5                   => l_per_rec.attribute5
4067        ,p_attribute6                   => l_per_rec.attribute6
4068        ,p_attribute7                   => l_per_rec.attribute7
4069        ,p_attribute8                   => l_per_rec.attribute8
4070        ,p_attribute9                   => l_per_rec.attribute9
4071        ,p_attribute10                  => l_per_rec.attribute10
4072        ,p_attribute11                  => l_per_rec.attribute11
4073        ,p_attribute12                  => l_per_rec.attribute12
4074        ,p_attribute13                  => l_per_rec.attribute13
4075        ,p_attribute14                  => l_per_rec.attribute14
4076        ,p_attribute15                  => l_per_rec.attribute15
4077        ,p_attribute16                  => l_per_rec.attribute16
4078        ,p_attribute17                  => l_per_rec.attribute17
4079        ,p_attribute18                  => l_per_rec.attribute18
4080        ,p_attribute19                  => l_per_rec.attribute19
4081        ,p_attribute20                  => l_per_rec.attribute20
4082        ,p_attribute21                  => l_per_rec.attribute21
4083        ,p_attribute22                  => l_per_rec.attribute22
4084        ,p_attribute23                  => l_per_rec.attribute23
4085        ,p_attribute24                  => l_per_rec.attribute24
4086        ,p_attribute25                  => l_per_rec.attribute25
4087        ,p_attribute26                  => l_per_rec.attribute26
4088        ,p_attribute27                  => l_per_rec.attribute27
4089        ,p_attribute28                  => l_per_rec.attribute28
4090        ,p_attribute29                  => l_per_rec.attribute29
4091        ,p_attribute30                  => l_per_rec.attribute30
4092        ,p_per_information_category     => l_per_rec.per_information_category
4093        ,p_per_information1             => l_per_rec.per_information1
4094        ,p_per_information2             => l_per_rec.per_information2
4095        ,p_per_information3             => l_per_rec.per_information3
4096        ,p_per_information4             => l_per_rec.per_information4
4097        ,p_per_information5             => l_per_rec.per_information5
4098        ,p_per_information6             => l_per_rec.per_information6
4099        ,p_per_information7             => l_per_rec.per_information7
4100        ,p_per_information8             => l_per_rec.per_information8
4101        ,p_per_information9             => l_per_rec.per_information9
4102        ,p_per_information10            => l_per_rec.per_information10
4103        ,p_per_information11            => l_per_rec.per_information11
4104        ,p_per_information12            => l_per_rec.per_information12
4105        ,p_per_information13            => l_per_rec.per_information13
4106        ,p_per_information14            => l_per_rec.per_information14
4107        ,p_per_information15            => l_per_rec.per_information15
4108        ,p_per_information16            => l_per_rec.per_information16
4109        ,p_per_information17            => l_per_rec.per_information17
4110        ,p_per_information18            => l_per_rec.per_information18
4111        ,p_per_information19            => l_per_rec.per_information19
4112        ,p_per_information20            => l_per_rec.per_information20
4113        ,p_per_information21            => l_per_rec.per_information21
4114        ,p_per_information22            => l_per_rec.per_information22
4115        ,p_per_information23            => l_per_rec.per_information23
4116        ,p_per_information24            => l_per_rec.per_information24
4117        ,p_per_information25            => l_per_rec.per_information25
4118        ,p_per_information26            => l_per_rec.per_information26
4119        ,p_per_information27            => l_per_rec.per_information27
4120        ,p_per_information28            => l_per_rec.per_information28
4121        ,p_per_information29            => l_per_rec.per_information29
4122        ,p_per_information30            => l_per_rec.per_information30
4123        ,p_date_of_death                => l_per_rec.date_of_death
4124        ,p_background_check_status      => l_per_rec.background_check_status
4125        ,p_background_date_check        => l_per_rec.background_date_check
4126        ,p_blood_type                   => l_per_rec.blood_type
4127        ,p_fast_path_employee           => l_per_rec.fast_path_employee
4128        ,p_fte_capacity                 => l_per_rec.fte_capacity
4129        ,p_honors                       => l_per_rec.honors
4130        ,p_internal_location            => l_per_rec.internal_location
4131        ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
4132        ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
4133        ,p_mailstop                     => l_per_rec.mailstop
4134        ,p_office_number                => l_per_rec.office_number
4135        ,p_on_military_service          => l_per_rec.on_military_service
4136        ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
4137        ,p_projected_start_date         => l_per_rec.projected_start_date
4138        ,p_resume_exists                => l_per_rec.resume_exists
4139        ,p_resume_last_updated          => l_per_rec.resume_last_updated
4140        ,p_second_passport_exists       => l_per_rec.second_passport_exists
4141        ,p_student_status               => l_per_rec.student_status
4142        ,p_work_schedule                => l_per_rec.work_schedule
4143        ,p_suffix                       => l_per_rec.suffix
4144        ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
4145        ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
4146        ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
4147        ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
4148        ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
4149        ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
4150        ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
4151        ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
4152        ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
4153        ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
4154        ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
4155        ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
4156        ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
4157        --,p_adjusted_svc_date            => p_adjusted_svc_date
4158        ,p_town_of_birth                => l_per_rec.town_of_birth
4159        ,p_region_of_birth              => l_per_rec.region_of_birth
4160        ,p_country_of_birth             => l_per_rec.country_of_birth
4161        ,p_global_person_id             => l_per_rec.global_person_id
4162        ,p_party_id                     => l_per_rec.party_id
4163        ,p_correspondence_language      => l_per_rec.correspondence_language
4164        ,p_benefit_group                => l_per_rec.benefit_group_id
4165        ,p_person_user_key              => l_dp_crt_emp_rec.p_person_user_key
4166        ,p_assignment_user_key          => l_dp_crt_emp_rec.p_assignment_user_key
4167        ,p_user_person_type             => l_user_person_type
4168        ,p_language_code                => Userenv('lang')
4169        ,p_vendor_name                  => NULL
4170        );
4171     END IF;
4172 
4173     -- Call if API_ID is 'Update_Person'
4174     IF l_api_name = 'UPDATE_PERSON' THEN
4175 
4176        OPEN  csr_get_update_per_data(c_batch_id   => p_batch_id
4177                                     ,c_link_value => p_data_pump_batch_line_id
4178                                     );
4179        FETCH csr_get_update_per_data INTO l_dp_upd_per_rec;
4180        CLOSE csr_get_update_per_data;
4181 
4182      Hrdpp_Update_Person.insert_batch_lines
4183      (p_batch_id                     => p_batch_id
4184      ,p_data_pump_batch_line_id      => l_dp_upd_per_rec.batch_line_id
4185      ,p_user_sequence                => l_dp_upd_per_rec.user_sequence
4186      ,p_link_value                   => p_data_pump_batch_line_id
4187      ,p_effective_date               => l_per_rec.start_date
4188      ,p_datetrack_update_mode        => l_dp_upd_per_rec.p_datetrack_update_mode
4189      ,p_party_id                     => l_per_rec.party_id
4190      ,p_employee_number              => l_per_rec.employee_number
4191      ,p_last_name                    => l_per_rec.last_name
4192      ,p_first_name                   => l_per_rec.first_name
4193      ,p_date_of_birth                => l_per_rec.date_of_birth
4194      ,p_marital_status               => l_per_rec.marital_status
4195      ,p_middle_names                 => l_per_rec.middle_names
4196      ,p_sex                          => l_per_rec.sex
4197      ,p_title                        => l_per_rec.title
4198      ,p_nationality                  => l_per_rec.nationality
4199      ,p_previous_last_name           => l_per_rec.previous_last_name
4200      ,p_known_as                     => l_per_rec.known_as
4201      ,p_email_address                => l_per_rec.email_address
4202      ,p_registered_disabled_flag     => l_per_rec.registered_disabled_flag
4203      ,p_date_employee_data_verified  => l_per_rec.date_employee_data_verified
4204      ,p_expense_check_send_to_addres => l_per_rec.expense_check_send_to_address
4205 
4206       -- Person DDF
4207      ,p_per_information_category     => l_per_rec.per_information_category
4208      ,p_per_information1             => l_per_rec.per_information1
4209      ,p_per_information2             => l_per_rec.per_information2
4210      ,p_per_information3             => l_per_rec.per_information3
4211      ,p_per_information4             => l_per_rec.per_information4
4212      ,p_per_information5             => l_per_rec.per_information5
4213      ,p_per_information6             => l_per_rec.per_information6
4214      ,p_per_information7             => l_per_rec.per_information7
4215      ,p_per_information8             => l_per_rec.per_information8
4216      ,p_per_information9             => l_per_rec.per_information9
4217      ,p_per_information10            => l_per_rec.per_information10
4218      ,p_per_information11            => l_per_rec.per_information11
4219      ,p_per_information12            => l_per_rec.per_information12
4220      ,p_per_information13            => l_per_rec.per_information13
4221      ,p_per_information14            => l_per_rec.per_information14
4222      ,p_per_information15            => l_per_rec.per_information15
4223      ,p_per_information16            => l_per_rec.per_information16
4224      ,p_per_information17            => l_per_rec.per_information17
4225      ,p_per_information18            => l_per_rec.per_information18
4226      ,p_per_information19            => l_per_rec.per_information19
4227      ,p_per_information20            => l_per_rec.per_information20
4228      ,p_per_information21            => l_per_rec.per_information21
4229      ,p_per_information22            => l_per_rec.per_information22
4230      ,p_per_information23            => l_per_rec.per_information23
4231      ,p_per_information24            => l_per_rec.per_information24
4232      ,p_per_information25            => l_per_rec.per_information25
4233      ,p_per_information26            => l_per_rec.per_information26
4234      ,p_per_information27            => l_per_rec.per_information27
4235      ,p_per_information28            => l_per_rec.per_information28
4236      ,p_per_information29            => l_per_rec.per_information29
4237      ,p_per_information30            => l_per_rec.per_information30
4238 
4239      -- Person DF
4240      ,p_attribute_category           => l_per_rec.attribute_category
4241      ,p_attribute1                   => l_per_rec.attribute1
4242      ,p_attribute2                   => l_per_rec.attribute2
4243      ,p_attribute3                   => l_per_rec.attribute3
4244      ,p_attribute4                   => l_per_rec.attribute4
4245      ,p_attribute5                   => l_per_rec.attribute5
4246      ,p_attribute6                   => l_per_rec.attribute6
4247      ,p_attribute7                   => l_per_rec.attribute7
4248      ,p_attribute8                   => l_per_rec.attribute8
4249      ,p_attribute9                   => l_per_rec.attribute9
4250      ,p_attribute10                  => l_per_rec.attribute10
4251      ,p_attribute11                  => l_per_rec.attribute11
4252      ,p_attribute12                  => l_per_rec.attribute12
4253      ,p_attribute13                  => l_per_rec.attribute13
4254      ,p_attribute14                  => l_per_rec.attribute14
4255      ,p_attribute15                  => l_per_rec.attribute15
4256      ,p_attribute16                  => l_per_rec.attribute16
4257      ,p_attribute17                  => l_per_rec.attribute17
4258      ,p_attribute18                  => l_per_rec.attribute18
4259      ,p_attribute19                  => l_per_rec.attribute19
4260      ,p_attribute20                  => l_per_rec.attribute20
4261      ,p_attribute21                  => l_per_rec.attribute21
4262      ,p_attribute22                  => l_per_rec.attribute22
4263      ,p_attribute23                  => l_per_rec.attribute23
4264      ,p_attribute24                  => l_per_rec.attribute24
4265      ,p_attribute25                  => l_per_rec.attribute25
4266      ,p_attribute26                  => l_per_rec.attribute26
4267      ,p_attribute27                  => l_per_rec.attribute27
4268      ,p_attribute28                  => l_per_rec.attribute28
4269      ,p_attribute29                  => l_per_rec.attribute29
4270      ,p_attribute30                  => l_per_rec.attribute30
4271 
4272    --,p_vendor_id                    => l_per_rec.vendor_id
4273    --,p_work_telephone               => l_per_rec.vendor_id
4274      ,p_date_of_death                => l_per_rec.date_of_death
4275      ,p_background_check_status      => l_per_rec.background_check_status
4276      ,p_background_date_check        => l_per_rec.background_date_check
4277      ,p_blood_type                   => l_per_rec.blood_type
4278      ,p_correspondence_language      => l_per_rec.correspondence_language
4279    --,p_fast_path_employee           IN  Varchar2 DEFAULT Hr_Api.g_Varchar2
4280      ,p_fte_capacity                 => l_per_rec.fte_capacity
4281      ,p_hold_applicant_date_until    => l_per_rec.hold_applicant_date_until
4282      ,p_honors                       => l_per_rec.honors
4283      ,p_internal_location            => l_per_rec.internal_location
4284      ,p_last_medical_test_by         => l_per_rec.last_medical_test_by
4285      ,p_last_medical_test_date       => l_per_rec.last_medical_test_date
4286      ,p_mailstop                     => l_per_rec.mailstop
4287      ,p_office_number                => l_per_rec.office_number
4288      ,p_on_military_service          => l_per_rec.on_military_service
4289      ,p_pre_name_adjunct             => l_per_rec.pre_name_adjunct
4290      ,p_projected_start_date         => l_per_rec.projected_start_date
4291      ,p_rehire_authorizor            => l_per_rec.rehire_authorizor
4292      ,p_rehire_recommendation        => l_per_rec.rehire_recommendation
4293      ,p_resume_exists                => l_per_rec.resume_exists
4294      ,p_resume_last_updated          => l_per_rec.resume_last_updated
4295      ,p_second_passport_exists       => l_per_rec.second_passport_exists
4296      ,p_student_status               => l_per_rec.student_status
4297      ,p_work_schedule                => l_per_rec.work_schedule
4298      ,p_rehire_reason                => l_per_rec.rehire_reason
4299      ,p_suffix                       => l_per_rec.suffix
4300      ,p_benefit_group                => l_per_rec.benefit_group_id
4301      ,p_receipt_of_death_cert_date   => l_per_rec.receipt_of_death_cert_date
4302      ,p_coord_ben_med_pln_no         => l_per_rec.coord_ben_med_pln_no
4303      ,p_coord_ben_no_cvg_flag        => l_per_rec.coord_ben_no_cvg_flag
4304      ,p_coord_ben_med_ext_er         => l_per_rec.coord_ben_med_ext_er
4305      ,p_coord_ben_med_pl_name        => l_per_rec.coord_ben_med_pl_name
4306      ,p_coord_ben_med_insr_crr_name  => l_per_rec.coord_ben_med_insr_crr_name
4307      ,p_coord_ben_med_insr_crr_ident => l_per_rec.coord_ben_med_insr_crr_ident
4308      ,p_coord_ben_med_cvg_strt_dt    => l_per_rec.coord_ben_med_cvg_strt_dt
4309      ,p_coord_ben_med_cvg_end_dt     => l_per_rec.coord_ben_med_cvg_end_dt
4310      ,p_uses_tobacco_flag            => l_per_rec.uses_tobacco_flag
4311      ,p_dpdnt_adoption_date          => l_per_rec.dpdnt_adoption_date
4312      ,p_dpdnt_vlntry_svce_flag       => l_per_rec.dpdnt_vlntry_svce_flag
4313      ,p_original_date_of_hire        => l_per_rec.original_date_of_hire
4314      ,p_adjusted_svc_date            => p_adjusted_svc_date
4315      ,p_town_of_birth                => l_per_rec.town_of_birth
4316      ,p_region_of_birth              => l_per_rec.region_of_birth
4317      ,p_country_of_birth             => l_per_rec.country_of_birth
4318      ,p_global_person_id             => l_per_rec.global_person_id
4319      ,p_person_user_key              => l_dp_upd_per_rec.p_person_user_key
4320      ,p_user_person_type             => l_dp_upd_per_rec.p_user_person_type
4321      ,p_language_code                => Userenv('lang')
4322      ,p_vendor_name                  => NULL
4323      );
4324 
4325     END IF;
4326 
4327     -- Call if API_ID is 'Update_Address'
4328     IF l_api_name = 'UPDATE_PERSON_ADDRESS' THEN
4329        OPEN  csr_get_update_add_data(c_batch_id   => p_batch_id
4330                                     ,c_link_value => p_data_pump_batch_line_id
4331                                     );
4332        FETCH csr_get_update_add_data INTO l_dp_upd_add_rec;
4333        CLOSE csr_get_update_add_data;
4334 
4335 -- Code has been commented as the Logic for Address has changed, hence we no
4336 -- longer require the below logic, will be removed later
4337 
4338 --       -- Check if while updating address we end dated the address and then
4339 --       -- created a new address or simply updated the address. To find that
4340 --       -- out, we will check if for the said batch_id and link_value
4341 --       -- we have both Update and Create Address. If that is the case then
4342 --       -- that implies that address was end dated and then new one was created
4343 --       -- else it was simply updated.
4344 --       -- Incase address was updated to end date then, we will use
4345 --       -- "l_dp_upd_add_rec" else we will use "l_add_rec"
4346 
4347 --       OPEN  csr_chk_add_end_dated (c_batch_id   => p_batch_id
4348 --                                   ,c_link_value => p_data_pump_batch_line_id
4349 --                                   );
4350 --       FETCH csr_chk_add_end_dated INTO l_if_end_dated;
4351 --       CLOSE csr_chk_add_end_dated;
4352 
4353 --       IF l_if_end_dated = 'END DATED' THEN
4354 
4355 --          -- Don't do anything since in that case only date_to field was
4356 --          -- updated, which can't be wrong. Rest of the data was previous
4357 --          -- address data which can't be wrong and anyways user is not allowed
4358 --          -- to update that.
4359 --          NULL;
4360 
4361 --       ELSE
4362 
4363           Hrdpp_Update_Person_Address.Insert_Batch_Lines
4364           (p_batch_id                => p_batch_id
4365            --l_dp_batch_line_id_up_add
4366           ,p_data_pump_batch_line_id => l_dp_upd_add_rec.batch_line_id
4367           ,p_user_sequence           => l_dp_upd_add_rec.user_sequence
4368           ,p_link_value              => p_data_pump_batch_line_id
4369           ,p_effective_date          => l_per_rec.start_date
4370           ,p_validate_county         => FALSE
4371           ,p_primary_flag            => l_add_rec.primary_flag
4372           ,p_date_from               => l_add_rec.date_from
4373           ,p_date_to                 => l_add_rec.date_to
4374           ,p_address_type            => l_add_rec.address_type
4375           --,p_comments              => p_adr_comments
4376           ,p_address_line1           => l_add_rec.address_line1
4377           ,p_address_line2           => l_add_rec.address_line2
4378           ,p_address_line3           => l_add_rec.address_line3
4379           ,p_town_or_city            => l_add_rec.town_or_city
4380           ,p_region_1                => l_add_rec.region_1
4381           ,p_region_2                => l_add_rec.region_2
4382           ,p_region_3                => l_add_rec.region_3
4383           ,p_postal_code             => l_add_rec.postal_code
4384           ,p_telephone_number_1      => l_add_rec.telephone_number_1
4385           ,p_telephone_number_2      => l_add_rec.telephone_number_2
4386           ,p_telephone_number_3      => l_add_rec.telephone_number_3
4387           ,p_addr_attribute_category => l_add_rec.addr_attribute_category
4388           ,p_addr_attribute1         => l_add_rec.addr_attribute1
4389           ,p_addr_attribute2         => l_add_rec.addr_attribute2
4390           ,p_addr_attribute3         => l_add_rec.addr_attribute3
4391           ,p_addr_attribute4         => l_add_rec.addr_attribute4
4392           ,p_addr_attribute5         => l_add_rec.addr_attribute5
4393           ,p_addr_attribute6         => l_add_rec.addr_attribute6
4394           ,p_addr_attribute7         => l_add_rec.addr_attribute7
4395           ,p_addr_attribute8         => l_add_rec.addr_attribute8
4396           ,p_addr_attribute9         => l_add_rec.addr_attribute9
4397           ,p_addr_attribute10        => l_add_rec.addr_attribute10
4398           ,p_addr_attribute11        => l_add_rec.addr_attribute11
4399           ,p_addr_attribute12        => l_add_rec.addr_attribute12
4400           ,p_addr_attribute13        => l_add_rec.addr_attribute13
4401           ,p_addr_attribute14        => l_add_rec.addr_attribute14
4402           ,p_addr_attribute15        => l_add_rec.addr_attribute15
4403           ,p_addr_attribute16        => l_add_rec.addr_attribute16
4404           ,p_addr_attribute17        => l_add_rec.addr_attribute17
4405           ,p_addr_attribute18        => l_add_rec.addr_attribute18
4406           ,p_addr_attribute19        => l_add_rec.addr_attribute19
4407           ,p_addr_attribute20        => l_add_rec.addr_attribute20
4408           ,p_add_information13       => l_add_rec.add_information13
4409           ,p_add_information14       => l_add_rec.add_information14
4410           ,p_add_information15       => l_add_rec.add_information15
4411           ,p_add_information16       => l_add_rec.add_information16
4412           ,p_add_information17       => l_add_rec.add_information17
4413           ,p_add_information18       => l_add_rec.add_information18
4414           ,p_add_information19       => l_add_rec.add_information19
4415           ,p_add_information20       => l_add_rec.add_information20
4416           ,p_party_id                => l_add_rec.party_id
4417           ,p_address_user_key        => l_dp_upd_add_rec.p_address_user_key
4418           ,p_country                 => l_add_rec.country
4419           );
4420 --       END IF;
4421     END IF;
4422 
4423     -- Call if API_ID is 'Create_Address'
4424     IF l_api_name = 'CREATE_PERSON_ADDRESS' THEN
4425 
4426        OPEN  csr_get_create_add_data(c_batch_id   => p_batch_id
4427                                     ,c_link_value => p_data_pump_batch_line_id
4428                                     );
4429        FETCH csr_get_create_add_data INTO l_dp_crt_add_rec;
4430        CLOSE csr_get_create_add_data;
4431 
4432        -- Convert String value of p_pradd_ovlapval_override to Boolean
4433        IF l_dp_crt_add_rec.p_pradd_ovlapval_override = 'FALSE' THEN
4434           l_pradd_ovlapval_override := FALSE;
4435        ELSE
4436           l_pradd_ovlapval_override := FALSE;
4437        END IF;
4438 
4439        Hrdpp_Create_Person_Address.Insert_Batch_Lines
4440        (p_batch_id                       => p_batch_id
4441        --l_dp_batch_line_id_cr_add
4442        ,p_data_pump_batch_line_id        => l_dp_crt_add_rec.batch_line_id
4443        ,p_user_sequence                  => l_dp_crt_add_rec.user_sequence
4444        ,p_link_value                     => p_data_pump_batch_line_id
4445        ,p_effective_date                 => l_per_rec.start_date
4446        ,p_pradd_ovlapval_override        => l_pradd_ovlapval_override
4447        ,p_validate_county                => FALSE
4448        ,p_primary_flag                   => l_add_rec.primary_flag
4449        ,p_style                          => l_add_rec.style
4450        ,p_date_from                      => l_add_rec.date_from
4451        ,p_date_to                        => l_add_rec.date_to
4452        ,p_address_type                   => l_add_rec.address_type
4453        --,p_comments                       => p_adr_comments
4454        ,p_address_line1                  => l_add_rec.address_line1
4455        ,p_address_line2                  => l_add_rec.address_line2
4456        ,p_address_line3                  => l_add_rec.address_line3
4457        ,p_town_or_city                   => l_add_rec.town_or_city
4458        ,p_region_1                       => l_add_rec.region_1
4459        ,p_region_2                       => l_add_rec.region_2
4460        ,p_region_3                       => l_add_rec.region_3
4461        ,p_postal_code                    => l_add_rec.postal_code
4462        ,p_telephone_number_1             => l_add_rec.telephone_number_1
4463        ,p_telephone_number_2             => l_add_rec.telephone_number_2
4464        ,p_telephone_number_3             => l_add_rec.telephone_number_3
4465        ,p_addr_attribute_category        => l_add_rec.addr_attribute_category
4466        ,p_addr_attribute1                => l_add_rec.addr_attribute1
4467        ,p_addr_attribute2                => l_add_rec.addr_attribute2
4468        ,p_addr_attribute3                => l_add_rec.addr_attribute3
4469        ,p_addr_attribute4                => l_add_rec.addr_attribute4
4470        ,p_addr_attribute5                => l_add_rec.addr_attribute5
4471        ,p_addr_attribute6                => l_add_rec.addr_attribute6
4472        ,p_addr_attribute7                => l_add_rec.addr_attribute7
4473        ,p_addr_attribute8                => l_add_rec.addr_attribute8
4474        ,p_addr_attribute9                => l_add_rec.addr_attribute9
4475        ,p_addr_attribute10               => l_add_rec.addr_attribute10
4476        ,p_addr_attribute11               => l_add_rec.addr_attribute11
4477        ,p_addr_attribute12               => l_add_rec.addr_attribute12
4478        ,p_addr_attribute13               => l_add_rec.addr_attribute13
4479        ,p_addr_attribute14               => l_add_rec.addr_attribute14
4480        ,p_addr_attribute15               => l_add_rec.addr_attribute15
4481        ,p_addr_attribute16               => l_add_rec.addr_attribute16
4482        ,p_addr_attribute17               => l_add_rec.addr_attribute17
4483        ,p_addr_attribute18               => l_add_rec.addr_attribute18
4484        ,p_addr_attribute19               => l_add_rec.addr_attribute19
4485        ,p_addr_attribute20               => l_add_rec.addr_attribute20
4486        ,p_add_information13              => l_add_rec.add_information13
4487        ,p_add_information14              => l_add_rec.add_information14
4488        ,p_add_information15              => l_add_rec.add_information15
4489        ,p_add_information16              => l_add_rec.add_information16
4490        ,p_add_information17              => l_add_rec.add_information17
4491        ,p_add_information18              => l_add_rec.add_information18
4492        ,p_add_information19              => l_add_rec.add_information19
4493        ,p_add_information20              => l_add_rec.add_information20
4494        ,p_party_id                       => l_add_rec.party_id
4495        ,p_address_user_key               => l_dp_crt_add_rec.p_address_user_key
4496        ,p_person_user_key                => l_dp_crt_add_rec.p_person_user_key
4497        ,p_country                        => l_add_rec.country
4498        );
4499 
4500     END IF;
4501 
4502     -- Call if API_ID is 'Update_Emp_Asg'
4503     IF l_api_name = 'UPDATE_EMP_ASG' THEN
4504 
4505        OPEN  csr_get_upd_asg_data(c_batch_id   => p_batch_id
4506                                  ,c_link_value => p_data_pump_batch_line_id
4507                                  );
4508        FETCH csr_get_upd_asg_data INTO l_dp_upd_asg_rec;
4509        CLOSE csr_get_upd_asg_data;
4510 
4511        Hrdpp_Update_Emp_Asg.Insert_Batch_Lines
4512        (p_batch_id                      => p_batch_id
4513        -- l_dp_batch_line_id_asg
4514        ,p_data_pump_batch_line_id       => l_dp_upd_asg_rec.batch_line_id
4515        ,p_user_sequence                 => l_dp_upd_asg_rec.user_sequence
4516        ,p_link_value                    => p_data_pump_batch_line_id
4517        ,p_effective_date                => l_per_rec.start_date
4518        ,p_datetrack_update_mode     => l_dp_upd_asg_rec.p_datetrack_update_mode
4519        ,p_change_reason                 => l_asg_rec.change_reason
4520        --,p_comments                      => l_asg_rec.asg_comments
4521        ,p_date_probation_end            => l_asg_rec.date_probation_end
4522        ,p_frequency                     => l_asg_rec.frequency
4523        ,p_internal_address_line         => l_asg_rec.internal_address_line
4524        ,p_manager_flag                  => l_asg_rec.manager_flag
4525        ,p_normal_hours                  => l_asg_rec.normal_hours
4526        ,p_perf_review_period            => l_asg_rec.perf_review_period
4527        ,p_perf_review_period_frequency  =>l_asg_rec.perf_review_period_frequency
4528        ,p_probation_period              => l_asg_rec.probation_period
4529        ,p_probation_unit                => l_asg_rec.probation_unit
4530        ,p_sal_review_period             => l_asg_rec.sal_review_period
4531        ,p_sal_review_period_frequency   => l_asg_rec.sal_review_period_frequency
4532        ,p_source_type                   => l_asg_rec.source_type
4533        ,p_time_normal_finish            => l_asg_rec.time_normal_finish
4534        ,p_time_normal_start             => l_asg_rec.time_normal_start
4535        ,p_bargaining_unit_code          => l_asg_rec.bargaining_unit_code
4536        ,p_labour_union_member_flag      => l_asg_rec.labour_union_member_flag
4537        ,p_hourly_salaried_code          => l_asg_rec.hourly_salaried_code
4538        ,p_ass_attribute_category        => l_asg_rec.ass_attribute_category
4539        ,p_ass_attribute1                => l_asg_rec.ass_attribute1
4540        ,p_ass_attribute2                => l_asg_rec.ass_attribute2
4541        ,p_ass_attribute3                => l_asg_rec.ass_attribute3
4542        ,p_ass_attribute4                => l_asg_rec.ass_attribute4
4543        ,p_ass_attribute5                => l_asg_rec.ass_attribute5
4544        ,p_ass_attribute6                => l_asg_rec.ass_attribute6
4545        ,p_ass_attribute7                => l_asg_rec.ass_attribute7
4546        ,p_ass_attribute8                => l_asg_rec.ass_attribute8
4547        ,p_ass_attribute9                => l_asg_rec.ass_attribute9
4548        ,p_ass_attribute10               => l_asg_rec.ass_attribute10
4549        ,p_ass_attribute11               => l_asg_rec.ass_attribute11
4550        ,p_ass_attribute12               => l_asg_rec.ass_attribute12
4551        ,p_ass_attribute13               => l_asg_rec.ass_attribute13
4552        ,p_ass_attribute14               => l_asg_rec.ass_attribute14
4553        ,p_ass_attribute15               => l_asg_rec.ass_attribute15
4554        ,p_ass_attribute16               => l_asg_rec.ass_attribute16
4555        ,p_ass_attribute17               => l_asg_rec.ass_attribute17
4556        ,p_ass_attribute18               => l_asg_rec.ass_attribute18
4557        ,p_ass_attribute19               => l_asg_rec.ass_attribute19
4558        ,p_ass_attribute20               => l_asg_rec.ass_attribute20
4559        ,p_ass_attribute21               => l_asg_rec.ass_attribute21
4560        ,p_ass_attribute22               => l_asg_rec.ass_attribute22
4561        ,p_ass_attribute23               => l_asg_rec.ass_attribute23
4562        ,p_ass_attribute24               => l_asg_rec.ass_attribute24
4563        ,p_ass_attribute25               => l_asg_rec.ass_attribute25
4564        ,p_ass_attribute26               => l_asg_rec.ass_attribute26
4565        ,p_ass_attribute27               => l_asg_rec.ass_attribute27
4566        ,p_ass_attribute28               => l_asg_rec.ass_attribute28
4567        ,p_ass_attribute29               => l_asg_rec.ass_attribute29
4568        ,p_ass_attribute30               => l_asg_rec.ass_attribute30
4569        --,p_title                         => l_asg_rec.title
4570        ,p_segment1                      => l_hr_soft_rec.segment1
4571        ,p_segment2                      => l_hr_soft_rec.segment2
4572        ,p_segment3                      => l_hr_soft_rec.segment3
4573        ,p_segment4                      => l_hr_soft_rec.segment4
4574        ,p_segment5                      => l_hr_soft_rec.segment5
4575        ,p_segment6                      => l_hr_soft_rec.segment6
4576        ,p_segment7                      => l_hr_soft_rec.segment7
4577        ,p_segment8                      => l_hr_soft_rec.segment8
4578        ,p_segment9                      => l_hr_soft_rec.segment9
4579        ,p_cagr_grade_def_id             => NULL
4580        ,p_assignment_user_key           =>l_dp_upd_asg_rec.p_assignment_user_key
4581        ,p_con_seg_user_name             => NULL
4582        );
4583 
4584     END IF;
4585 
4586     -- Call if API_ID is 'Update_Emp_Asg_Criteria'
4587     IF l_api_name = 'UPDATE_EMP_ASG_CRITERIA' THEN
4588 
4589        OPEN  csr_grade(l_asg_rec.grade_id
4590                       ,l_asg_rec.business_group_id
4591                       ,l_per_rec.START_DATE);
4592        FETCH csr_grade INTO l_grade_name;
4593        IF csr_grade%NOTFOUND THEN
4594           hr_utility.set_location('.. DP Error Grade Name not found Id: ' ||
4595 	                           l_asg_rec.grade_id, 20);
4596        END IF;
4597        CLOSE csr_grade;
4598 
4599        OPEN  csr_position (l_asg_rec.position_id
4600                           ,l_asg_rec.business_group_id
4601                           ,l_per_rec.START_DATE);
4602        FETCH csr_position INTO l_position_name;
4603        IF csr_position%NOTFOUND THEN
4604           hr_utility.set_location('.. DP Error Position Name not found Id: ' ||
4605 	                           l_asg_rec.position_id, 20);
4606        END IF;
4607        CLOSE csr_position;
4608 
4609        OPEN  csr_job(l_asg_rec.job_id
4610                     ,l_asg_rec.business_group_id
4611                     ,l_per_rec.START_DATE);
4612        FETCH csr_job INTO l_job_name;
4613        IF csr_job%NOTFOUND THEN
4614           hr_utility.set_location('.. DP Error Job Name not found Id: ' ||
4615                                   l_asg_rec.job_id, 20);
4616        END IF;
4617        CLOSE csr_job;
4618 
4619        OPEN  csr_payroll(l_asg_rec.payroll_id
4620                         ,l_asg_rec.business_group_id
4621                         ,l_per_rec.START_DATE);
4622        FETCH csr_payroll INTO l_payroll_name;
4623        IF csr_payroll%NOTFOUND THEN
4624           hr_utility.set_location('.. DP Error Payroll Name not found Id: ' ||
4625                                   l_asg_rec.payroll_id, 20);
4626        END IF;
4627        CLOSE csr_payroll;
4628 
4629        OPEN  csr_location(l_asg_rec.location_id
4630                          ,l_asg_rec.business_group_id);
4631        FETCH csr_location INTO l_location_code;
4632        IF csr_location%NOTFOUND THEN
4633           hr_utility.set_location('.. DP Error Location Code not found, Id: ' ||
4634                                   l_asg_rec.location_id, 20);
4635        END IF;
4636        CLOSE csr_location;
4637 
4638        OPEN  csr_organization(l_asg_rec.organization_id
4639                              ,l_asg_rec.business_group_id
4640                              ,l_per_rec.START_DATE);
4641        FETCH csr_organization INTO l_organization_name;
4642        IF csr_organization%NOTFOUND THEN
4643           hr_utility.set_location('.. DP Error Org Name not found, Id: ' ||
4644                                   l_asg_rec.organization_id, 20);
4645        END IF;
4646        CLOSE csr_organization;
4647 
4648        OPEN  csr_paybasis(l_asg_rec.pay_basis_id
4649                          ,l_asg_rec.business_group_id);
4650        FETCH csr_paybasis INTO l_pay_basis_name;
4651        IF csr_paybasis%NOTFOUND THEN
4652           hr_utility.set_location('.. DP Error Org Name not found, Id: ' ||
4653                                   l_asg_rec.pay_basis_id, 20);
4654        END IF;
4655        CLOSE csr_paybasis;
4656 
4657       -- Cursor to get the exisiting Data Pump Interface Table Va;ues for
4658       -- Update Emp Asg Criteria
4659       OPEN  csr_get_upd_asg_crt_data(c_batch_id   => p_batch_id
4660                                     ,c_link_value => p_data_pump_batch_line_id
4661                                     );
4662       FETCH csr_get_upd_asg_crt_data INTO l_dp_upd_asg_crt_rec;
4663       CLOSE csr_get_upd_asg_crt_data;
4664 
4665       Hrdpp_Update_Emp_Asg_Criteria.Insert_Batch_Lines
4666       (p_batch_id                => p_batch_id
4667       --l_dp_batch_line_id_asg_cri
4668       ,p_data_pump_batch_line_id => l_dp_upd_asg_crt_rec.batch_line_id
4669       ,p_user_sequence           => l_dp_upd_asg_crt_rec.user_sequence
4670       ,p_link_value              => p_data_pump_batch_line_id
4671       ,p_effective_date          => l_per_rec.start_date
4672       ,p_datetrack_update_mode   => l_dp_upd_asg_crt_rec.p_datetrack_update_mode
4673       ,p_segment1                => l_ppl_grp_rec.segment1
4674       ,p_segment2                => l_ppl_grp_rec.segment2
4675       ,p_segment3                => l_ppl_grp_rec.segment3
4676       ,p_segment4                => l_ppl_grp_rec.segment4
4677       ,p_segment5                => l_ppl_grp_rec.segment5
4678       ,p_segment6                => l_ppl_grp_rec.segment6
4679       ,p_segment7                => l_ppl_grp_rec.segment7
4680       ,p_segment8                => l_ppl_grp_rec.segment8
4681       ,p_segment9                => l_ppl_grp_rec.segment9
4682       ,p_segment10               => l_ppl_grp_rec.segment10
4683       ,p_segment11               => l_ppl_grp_rec.segment11
4684       ,p_segment12               => l_ppl_grp_rec.segment12
4685       ,p_segment13               => l_ppl_grp_rec.segment13
4686       ,p_segment14               => l_ppl_grp_rec.segment14
4687       ,p_segment15               => l_ppl_grp_rec.segment15
4688       ,p_segment16               => l_ppl_grp_rec.segment16
4689       ,p_segment17               => l_ppl_grp_rec.segment17
4690       ,p_segment18               => l_ppl_grp_rec.segment18
4691       ,p_segment19               => l_ppl_grp_rec.segment19
4692       ,p_segment20               => l_ppl_grp_rec.segment20
4693       ,p_segment21               => l_ppl_grp_rec.segment21
4694       ,p_segment22               => l_ppl_grp_rec.segment22
4695       ,p_segment23               => l_ppl_grp_rec.segment23
4696       ,p_segment24               => l_ppl_grp_rec.segment24
4697       ,p_segment25               => l_ppl_grp_rec.segment25
4698       ,p_segment26               => l_ppl_grp_rec.segment26
4699       ,p_segment27               => l_ppl_grp_rec.segment27
4700       ,p_segment28               => l_ppl_grp_rec.segment28
4701       ,p_segment29               => l_ppl_grp_rec.segment29
4702       ,p_segment30               => l_ppl_grp_rec.segment30
4703       ,p_special_ceiling_step_id => NULL
4704       ,p_people_group_id         => NULL
4705       ,p_assignment_user_key     => l_dp_upd_asg_crt_rec.p_assignment_user_key
4706       ,p_grade_name              => l_grade_name
4707       ,p_position_name           => l_position_name
4708       ,p_job_name                => l_job_name
4709       ,p_payroll_name            => l_payroll_name
4710       ,p_location_code           => l_location_code
4711       ,p_organization_name       => l_organization_name
4712       ,p_pay_basis_name          => l_pay_basis_name
4713       ,p_language_code           => Userenv('LANG')
4714       ,p_con_seg_user_name       => NULL
4715       );
4716 
4717     END IF;
4718 
4719     -- Call if API_ID is 'Create_Contact'
4720     IF l_api_name = 'CREATE_CONTACT' THEN
4721 
4722        OPEN  csr_get_create_cnt_data(c_batch_id   => p_batch_id
4723                                     ,c_link_value => p_data_pump_batch_line_id
4724                                     );
4725        FETCH csr_get_create_cnt_data INTO l_dp_crt_cnt_rec;
4726        CLOSE csr_get_create_cnt_data;
4727 
4728        Hrdpp_Create_Contact.insert_batch_lines
4729        (p_batch_id                => p_batch_id
4730        ,p_data_pump_batch_line_id => l_dp_crt_cnt_rec.batch_line_id
4731        ,p_user_sequence           => l_dp_crt_cnt_rec.user_sequence
4732        ,p_link_value              => p_data_pump_batch_line_id
4733        ,p_start_date              => l_per_rec.start_date
4734        ,p_contact_type            => l_cntct_rec.contact_type
4735        ,p_primary_contact_flag    => l_cntct_rec.primary_contact_flag
4736        ,p_personal_flag           => l_cntct_rec.personal_flag
4737        ,p_last_name               => p_contact_name
4738        ,p_per_person_user_key     => l_dp_crt_cnt_rec.p_per_person_user_key
4739        ,p_person_user_key         => l_dp_crt_cnt_rec.p_person_user_key
4740        ,p_language_code           => Userenv('LANG')
4741        );
4742 
4743     END IF;
4744 
4745     -- Call if API_ID is 'Update_Contact'
4746     IF l_api_name = 'UPDATE_CONTACT_RELATIONSHIP' THEN
4747 
4748        OPEN  csr_get_update_cnt_data(c_batch_id   => p_batch_id
4749                                      ,c_link_value => p_data_pump_batch_line_id
4750                                      );
4751        FETCH csr_get_update_cnt_data INTO l_dp_upd_cnt_rec;
4752        CLOSE csr_get_update_cnt_data;
4753 
4754        Hrdpp_Update_Contact_Relations.insert_batch_lines
4755        (p_batch_id                => p_batch_id
4756        ,p_data_pump_batch_line_id => l_dp_upd_cnt_rec.batch_line_id
4757        ,p_user_sequence           => l_dp_crt_cnt_rec.user_sequence
4758        ,p_link_value              => p_data_pump_batch_line_id
4759        ,p_effective_date          => l_per_rec.start_date
4760        ,p_contact_type            => l_cntct_rec.contact_type
4761        ,p_primary_contact_flag    => l_cntct_rec.primary_contact_flag
4762        ,p_personal_flag           => l_cntct_rec.personal_flag
4763        ,p_object_version_number   => l_dp_upd_cnt_rec.p_object_version_number
4764        ,p_contact_user_key        => l_dp_upd_cnt_rec.p_contact_user_key
4765        ,p_contactee_user_key      => l_dp_upd_cnt_rec.p_contactee_user_key
4766        );
4767 
4768     END IF;
4769 
4770   END LOOP;
4771 
4772   CLOSE csr_get_api_names;
4773 
4774   hr_utility.set_location('Leaving: ' || l_proc_name, 30);
4775 
4776 EXCEPTION
4777   WHEN Others THEN
4778     IF csr_get_api_names%ISOPEN THEN
4779       CLOSE csr_get_api_names;
4780     END IF;
4781   hr_utility.set_location('Leaving: ' || l_proc_name, 40);
4782   RAISE;
4783 
4784 END HR_DataPumpErr;
4785 
4786 
4787 -- =============================================================================
4788 -- ~ Create_Person_Contact:
4789 -- =============================================================================
4790 
4791 
4792 PROCEDURE Create_Person_Contact
4793          (p_effective_date   IN Date
4794          ,p_contact_name     IN Varchar2
4795       ,p_legislation_code IN Varchar2
4796          ,p_crt_cntct_out    OUT NOCOPY t_CreateContact_Api
4797 ) AS
4798 
4799   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Create_Person_Contact';
4800 
4801 BEGIN
4802   hr_utility.set_location('Entering: ' || l_proc_name, 10);
4803 
4804    Hr_Contact_Rel_Api.create_contact
4805    (p_start_date                => p_effective_date
4806    ,p_business_group_id         => l_cntct_rec.business_group_id
4807    ,p_person_id                 => l_cntct_rec.person_id
4808    ,p_contact_type              => l_cntct_rec.contact_type
4809    ,p_last_name                 => p_contact_name
4810    ,p_primary_contact_flag      => l_cntct_rec.primary_contact_flag
4811    ,p_personal_flag             => l_cntct_rec.personal_flag
4812    ,p_per_information_category  => p_legislation_code
4813    ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
4814    ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
4815    ,p_per_person_id             => p_crt_cntct_out.per_person_id
4816    ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
4817    ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
4818    ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
4819    ,p_full_name                 => p_crt_cntct_out.full_name
4820    ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
4821    ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
4822    ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
4823    );
4824 
4825   hr_utility.set_location('Leaving: ' || l_proc_name, 20);
4826 
4827 END Create_Person_Contact;
4828 
4829 -- =============================================================================
4830 -- ~ Update_Person_Contact:
4831 -- =============================================================================
4832 PROCEDURE Update_Person_Contact
4833          (p_effective_date   IN Date
4834          ,p_contact_name     IN Varchar2
4835       ,p_legislation_code IN Varchar2
4836          ,p_crt_cntct_out    OUT NOCOPY t_CreateContact_Api
4837 ) AS
4838 
4839   l_cont_object_version_num   Number;
4840   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Update_Person_Contact';
4841 
4842 BEGIN
4843   hr_utility.set_location('Entering: ' || l_proc_name, 10);
4844 
4845   OPEN  csr_ck_cont_xsts(c_person_id         => l_per_rec.person_id
4846                         ,c_business_group_id => l_add_rec.business_group_id
4847                         ,c_effective_date    => l_per_rec.START_DATE);
4848   FETCH csr_ck_cont_xsts INTO l_cont_object_version_num;
4849 
4850   -- Update the Contact only if Contact exists else create Contact
4851   IF csr_ck_cont_xsts%FOUND THEN
4852 
4853      -- Right now we are only creating the contact as decision to if we should
4854      -- actually be updating the Contact or every time be creating a new
4855      -- contact, irrespective of the fact if it is already existing duplicate
4856      -- person, hasn't been made
4857      Hr_Contact_Rel_Api.create_contact
4858      (p_start_date                => p_effective_date
4859      ,p_business_group_id         => l_cntct_rec.business_group_id
4860      ,p_person_id                 => l_cntct_rec.person_id
4861      ,p_contact_type              => l_cntct_rec.contact_type
4862      ,p_last_name                 => p_contact_name
4863      ,p_primary_contact_flag      => l_cntct_rec.primary_contact_flag
4864      ,p_personal_flag             => l_cntct_rec.personal_flag
4865      ,p_per_information_category  => p_legislation_code
4866      ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
4867      ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
4868      ,p_per_person_id             => p_crt_cntct_out.per_person_id
4869      ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
4870      ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
4871      ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
4872      ,p_full_name                 => p_crt_cntct_out.full_name
4873      ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
4874      ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
4875      ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
4876      );
4877 
4878   ELSE
4879 
4880      Hr_Contact_Rel_Api.create_contact
4881      (p_start_date                => p_effective_date
4882      ,p_business_group_id         => l_cntct_rec.business_group_id
4883      ,p_person_id                 => l_cntct_rec.person_id
4884      ,p_contact_type              => l_cntct_rec.contact_type
4885      ,p_last_name                 => p_contact_name
4886      ,p_primary_contact_flag      => l_cntct_rec.primary_contact_flag
4887      ,p_personal_flag             => l_cntct_rec.personal_flag
4888      ,p_per_information_category  => p_legislation_code
4889      ,p_contact_relationship_id   => p_crt_cntct_out.contact_relationship_id
4890      ,p_ctr_object_version_number => p_crt_cntct_out.ctr_object_version_number
4891      ,p_per_person_id             => p_crt_cntct_out.per_person_id
4892      ,p_per_object_version_number => p_crt_cntct_out.per_object_version_number
4893      ,p_per_effective_start_date  => p_crt_cntct_out.per_effective_start_date
4894      ,p_per_effective_end_date    => p_crt_cntct_out.per_effective_end_date
4895      ,p_full_name                 => p_crt_cntct_out.full_name
4896      ,p_per_comment_id            => p_crt_cntct_out.per_comment_id
4897      ,p_name_combination_warning  => p_crt_cntct_out.name_combination_warning
4898      ,p_orig_hire_warning         => p_crt_cntct_out.orig_hire_warning
4899      );
4900 
4901   END IF;
4902 
4903   hr_utility.set_location('Leaving: ' || l_proc_name, 20);
4904 
4905 END Update_Person_Contact;
4906 
4907 
4908 -- =============================================================================
4909 -- ~ Upd_OSS_Person:
4910 -- =============================================================================
4911 PROCEDURE Upd_OSS_Person
4912          (p_validate            IN Boolean
4913          ,p_effective_date      IN Date
4914          ,p_person_id           Number
4915          ,p_adjusted_svc_date   Date       DEFAULT NULL
4916          ,p_updper_api_out      OUT NOCOPY t_UpdEmp_Api
4917           ) AS
4918 
4919   l_cur_per_rec            csr_per%ROWTYPE;
4920   l_ptu_rec                chk_perType_usage%ROWTYPE;
4921   l_datetrack_update_mode  Varchar2(50);
4922   l_dt_correction          Boolean;
4923   l_dt_update              Boolean;
4924   l_dt_upd_override        Boolean;
4925   l_upd_chg_ins            Boolean;
4926   e_future_chgs_exists     Exception;
4927   l_error_msg              Varchar2(3000);
4928   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Upd_OSS_Person';
4929 
4930 BEGIN
4931   hr_utility.set_location('Entering: ' || l_proc_name, 10);
4932 
4933   OPEN  csr_per(c_person_id         => l_per_rec.person_id
4934                ,c_business_group_id => l_per_rec.business_group_id
4935                ,c_effective_date    => p_effective_date);
4936   FETCH csr_per INTO l_cur_per_rec;
4937   CLOSE csr_per;
4938 
4939   hr_utility.set_location(' l_cur_per_rec: ' || l_cur_per_rec.person_id, 20);
4940 
4941   Dt_Api.Find_DT_Upd_Modes
4942   (p_effective_date        => p_effective_date
4943   ,p_base_table_name       => 'PER_ALL_PEOPLE_F'
4944   ,p_base_key_column       => 'PERSON_ID'
4945   ,p_base_key_value        => l_cur_per_rec.person_id
4946   ,p_correction            => l_dt_correction
4947   ,p_update                => l_dt_update
4948   ,p_update_override       => l_dt_upd_override
4949   ,p_update_change_insert  => l_upd_chg_ins
4950    );
4951 
4952   IF l_dt_update THEN
4953      l_datetrack_update_mode := 'UPDATE';
4954   ELSIF l_dt_upd_override OR
4955         l_upd_chg_ins THEN
4956         -- Need to check if person type in future is EMP, APL or CWK , if yes
4957         -- then raise error
4958         OPEN chk_perType_usage
4959            (c_person_id         => l_cur_per_rec.person_id
4960            ,c_effective_date    => p_effective_date
4961            ,c_business_group_id => l_per_rec.business_group_id);
4962         FETCH chk_perType_usage INTO l_ptu_rec;
4963         IF chk_perType_usage%FOUND THEN
4964            Close chk_perType_usage;
4965            RAISE e_future_chgs_exists;
4966         END IF;
4967         Close chk_perType_usage;
4968   ELSE
4969      l_datetrack_update_mode := 'CORRECTION';
4970   END IF;
4971 
4972   hr_utility.set_location(' l_datetrack_update_mode: ' ||
4973                             l_datetrack_update_mode, 30);
4974   hr_utility.set_location(' employee_number: ' ||
4975                             l_cur_per_rec.employee_number, 30);
4976   hr_utility.set_location(' per ovn: ' ||
4977                             l_cur_per_rec.object_version_number, 30);
4978 
4979   -- Need to pass the employee number when updating the person
4980   l_per_rec.object_version_number := l_cur_per_rec.object_version_number;
4981 
4982   Hr_Person_Api.Update_Person
4983   (p_validate                     => p_validate
4984   ,p_effective_date               => p_effective_date
4985   ,p_datetrack_update_mode        => l_datetrack_update_mode
4986   ,p_person_id                    => l_cur_per_rec.person_id
4987   ,p_party_id                     => l_per_rec.party_id
4988   ,p_object_version_number        => l_cur_per_rec.object_version_number
4989   ,p_employee_number              => l_cur_per_rec.employee_number
4990   ,p_last_name                    => NVL(l_per_rec.last_name
4991                                         ,l_cur_per_rec.last_name)
4992   ,p_first_name                   => NVL(l_per_rec.first_name
4993                                         ,l_cur_per_rec.first_name)
4994   ,p_date_of_birth                => NVL(l_per_rec.date_of_birth
4995                                         ,l_cur_per_rec.date_of_birth)
4996   ,p_marital_status               => NVL(l_per_rec.marital_status
4997                                         ,l_cur_per_rec.marital_status)
4998   ,p_middle_names                 => NVL(l_per_rec.middle_names
4999                                         ,l_cur_per_rec.middle_names)
5000   ,p_sex                          => NVL(l_per_rec.sex
5001                                         ,l_cur_per_rec.sex)
5002   ,p_title                        => NVL(l_per_rec.title
5003                                         ,l_cur_per_rec.title)
5004   ,p_nationality                  => NVL(l_per_rec.nationality
5005                                         ,l_cur_per_rec.nationality)
5006   ,p_previous_last_name           => NVL(l_per_rec.previous_last_name
5007                                         ,l_cur_per_rec.previous_last_name)
5008   ,p_known_as                     => NVL(l_per_rec.known_as
5009                                         ,l_cur_per_rec.known_as)
5010   ,p_email_address                => NVL(l_per_rec.email_address
5011                                         ,l_cur_per_rec.email_address)
5012   ,p_registered_disabled_flag     => NVL(l_per_rec.registered_disabled_flag
5013                                         ,l_cur_per_rec.registered_disabled_flag)
5014   ,p_date_employee_data_verified  => NVL(l_per_rec.date_employee_data_verified
5015                                      ,l_cur_per_rec.date_employee_data_verified)
5016   ,p_expense_check_send_to_addres => NVL(l_per_rec.expense_check_send_to_address
5017                                    ,l_cur_per_rec.expense_check_send_to_address)
5018   ,p_per_information_category     => l_per_rec.per_information_category
5019   ,p_per_information1             => l_per_rec.per_information1
5020   ,p_per_information2             => l_per_rec.per_information2
5021   ,p_per_information3             => l_per_rec.per_information3
5022   ,p_per_information4             => l_per_rec.per_information4
5023   ,p_per_information5             => l_per_rec.per_information5
5024   ,p_per_information6             => l_per_rec.per_information6
5025   ,p_per_information7             => l_per_rec.per_information7
5026   ,p_per_information8             => l_per_rec.per_information8
5027   ,p_per_information9             => l_per_rec.per_information9
5028   ,p_per_information10            => l_per_rec.per_information10
5029   ,p_per_information11            => l_per_rec.per_information11
5030   ,p_per_information12            => l_per_rec.per_information12
5031   ,p_per_information13            => l_per_rec.per_information13
5032   ,p_per_information14            => l_per_rec.per_information14
5033   ,p_per_information15            => l_per_rec.per_information15
5034   ,p_per_information16            => l_per_rec.per_information16
5035   ,p_per_information17            => l_per_rec.per_information17
5036   ,p_per_information18            => l_per_rec.per_information18
5037   ,p_per_information19            => l_per_rec.per_information19
5038   ,p_per_information20            => l_per_rec.per_information20
5039   ,p_per_information21            => l_per_rec.per_information21
5040   ,p_per_information22            => l_per_rec.per_information22
5041   ,p_per_information23            => l_per_rec.per_information23
5042   ,p_per_information24            => l_per_rec.per_information24
5043   ,p_per_information25            => l_per_rec.per_information25
5044   ,p_per_information26            => l_per_rec.per_information26
5045   ,p_per_information27            => l_per_rec.per_information27
5046   ,p_per_information28            => l_per_rec.per_information28
5047   ,p_per_information29            => l_per_rec.per_information29
5048   ,p_per_information30            => l_per_rec.per_information30
5049   -- Person DF
5050   ,p_attribute_category           => l_per_rec.attribute_category
5051   ,p_attribute1                   => l_per_rec.attribute1
5052   ,p_attribute2                   => l_per_rec.attribute2
5053   ,p_attribute3                   => l_per_rec.attribute3
5054   ,p_attribute4                   => l_per_rec.attribute4
5055   ,p_attribute5                   => l_per_rec.attribute5
5056   ,p_attribute6                   => l_per_rec.attribute6
5057   ,p_attribute7                   => l_per_rec.attribute7
5058   ,p_attribute8                   => l_per_rec.attribute8
5059   ,p_attribute9                   => l_per_rec.attribute9
5060   ,p_attribute10                  => l_per_rec.attribute10
5061   ,p_attribute11                  => l_per_rec.attribute11
5062   ,p_attribute12                  => l_per_rec.attribute12
5063   ,p_attribute13                  => l_per_rec.attribute13
5064   ,p_attribute14                  => l_per_rec.attribute14
5065   ,p_attribute15                  => l_per_rec.attribute15
5066   ,p_attribute16                  => l_per_rec.attribute16
5067   ,p_attribute17                  => l_per_rec.attribute17
5068   ,p_attribute18                  => l_per_rec.attribute18
5069   ,p_attribute19                  => l_per_rec.attribute19
5070   ,p_attribute20                  => l_per_rec.attribute20
5071   ,p_attribute21                  => l_per_rec.attribute21
5072   ,p_attribute22                  => l_per_rec.attribute22
5073   ,p_attribute23                  => l_per_rec.attribute23
5074   ,p_attribute24                  => l_per_rec.attribute24
5075   ,p_attribute25                  => l_per_rec.attribute25
5076   ,p_attribute26                  => l_per_rec.attribute26
5077   ,p_attribute27                  => l_per_rec.attribute27
5078   ,p_attribute28                  => l_per_rec.attribute28
5079   ,p_attribute29                  => l_per_rec.attribute29
5080   ,p_attribute30                  => l_per_rec.attribute30
5081   ,p_date_of_death                => NVL(l_per_rec.date_of_death
5082                                         ,l_cur_per_rec.date_of_death)
5083   ,p_background_check_status      => NVL(l_per_rec.background_check_status
5084                                         ,l_cur_per_rec.background_check_status)
5085   ,p_background_date_check        => NVL(l_per_rec.background_date_check
5086                                         ,l_cur_per_rec.background_date_check)
5087   ,p_blood_type                   => NVL(l_per_rec.blood_type
5088                                         ,l_cur_per_rec.blood_type)
5089   ,p_correspondence_language      => NVL(l_per_rec.correspondence_language
5090                                         ,l_cur_per_rec.correspondence_language)
5091   ,p_fte_capacity                 => NVL(l_per_rec.fte_capacity
5092                                         ,l_cur_per_rec.fte_capacity)
5093   ,p_hold_applicant_date_until    => NVL(l_per_rec.hold_applicant_date_until
5094                                        ,l_cur_per_rec.hold_applicant_date_until)
5095   ,p_honors                       => NVL(l_per_rec.honors
5096                                         ,l_cur_per_rec.honors)
5097   ,p_internal_location            => NVL(l_per_rec.internal_location
5098                                         ,l_cur_per_rec.internal_location)
5099   ,p_last_medical_test_by         => NVL(l_per_rec.last_medical_test_by
5100                                         ,l_cur_per_rec.last_medical_test_by)
5101   ,p_last_medical_test_date       => NVL(l_per_rec.last_medical_test_date
5102                                         ,l_cur_per_rec.last_medical_test_date)
5103   ,p_mailstop                     => NVL(l_per_rec.mailstop
5104                                         ,l_cur_per_rec.mailstop)
5105   ,p_office_number                => NVL(l_per_rec.office_number
5106                                         ,l_cur_per_rec.office_number)
5107   ,p_on_military_service          => NVL(l_per_rec.on_military_service
5108                                         ,l_cur_per_rec.on_military_service)
5109   ,p_pre_name_adjunct             => NVL(l_per_rec.pre_name_adjunct
5110                                         ,l_cur_per_rec.pre_name_adjunct)
5111   ,p_projected_start_date         => NVL(l_per_rec.projected_start_date
5112                                         ,l_cur_per_rec.projected_start_date)
5113   ,p_rehire_authorizor            => NVL(l_per_rec.rehire_authorizor
5114                                         ,l_cur_per_rec.rehire_authorizor)
5115   ,p_rehire_recommendation        => NVL(l_per_rec.rehire_recommendation
5116                                         ,l_cur_per_rec.rehire_recommendation)
5117   ,p_resume_exists                => NVL(l_per_rec.resume_exists
5118                                         ,l_cur_per_rec.resume_exists )
5119   ,p_resume_last_updated          => NVL(l_per_rec.resume_last_updated
5120                                         ,l_cur_per_rec.resume_last_updated)
5121   ,p_second_passport_exists       => NVL(l_per_rec.second_passport_exists
5122                                         ,l_cur_per_rec.second_passport_exists)
5123   ,p_student_status               => NVL(l_per_rec.student_status
5124                                         ,l_cur_per_rec.student_status)
5125   ,p_work_schedule                => NVL(l_per_rec.work_schedule
5126                                         ,l_cur_per_rec.work_schedule)
5127   ,p_rehire_reason                => NVL(l_per_rec.rehire_reason
5128                                         ,l_cur_per_rec.rehire_reason)
5129   ,p_suffix                       => NVL(l_per_rec.suffix
5130                                         ,l_cur_per_rec.suffix)
5131   ,p_benefit_group_id             => NVL(l_per_rec.benefit_group_id
5132                                         ,l_cur_per_rec.benefit_group_id)
5133   ,p_receipt_of_death_cert_date   => NVL(l_per_rec.receipt_of_death_cert_date
5134                                       ,l_cur_per_rec.receipt_of_death_cert_date)
5135   ,p_coord_ben_med_pln_no         => NVL(l_per_rec.coord_ben_med_pln_no
5136                                         ,l_cur_per_rec.coord_ben_med_pln_no)
5137   ,p_coord_ben_no_cvg_flag        => NVL(l_per_rec.coord_ben_no_cvg_flag
5138                                         ,l_cur_per_rec.coord_ben_no_cvg_flag)
5139   ,p_coord_ben_med_ext_er         => NVL(l_per_rec.coord_ben_med_ext_er
5140                                         ,l_cur_per_rec.coord_ben_med_ext_er)
5141   ,p_coord_ben_med_pl_name        => NVL(l_per_rec.coord_ben_med_pl_name
5142                                         ,l_cur_per_rec.coord_ben_med_pl_name)
5143   ,p_coord_ben_med_insr_crr_name  => NVL(l_per_rec.coord_ben_med_insr_crr_name
5144                                      ,l_cur_per_rec.coord_ben_med_insr_crr_name)
5145   ,p_coord_ben_med_insr_crr_ident => NVL(l_per_rec.coord_ben_med_insr_crr_ident
5146                                     ,l_cur_per_rec.coord_ben_med_insr_crr_ident)
5147   ,p_coord_ben_med_cvg_strt_dt    => NVL(l_per_rec.coord_ben_med_cvg_strt_dt
5148                                      ,l_cur_per_rec.coord_ben_med_cvg_strt_dt)
5149   ,p_coord_ben_med_cvg_end_dt     => NVL(l_per_rec.coord_ben_med_cvg_end_dt
5150                                         ,l_cur_per_rec.coord_ben_med_cvg_end_dt)
5151   ,p_uses_tobacco_flag            => NVL(l_per_rec.uses_tobacco_flag
5152                                         ,l_cur_per_rec.uses_tobacco_flag)
5153   ,p_dpdnt_adoption_date          => NVL(l_per_rec.dpdnt_adoption_date
5154                                         ,l_cur_per_rec.dpdnt_adoption_date)
5155   ,p_dpdnt_vlntry_svce_flag       => NVL(l_per_rec.dpdnt_vlntry_svce_flag
5156                                         ,l_cur_per_rec.dpdnt_vlntry_svce_flag)
5157   ,p_original_date_of_hire        => NVL(l_per_rec.original_date_of_hire
5158                                         ,l_cur_per_rec.original_date_of_hire)
5159   --,p_adjusted_svc_date            => p_adjusted_svc_date
5160   ,p_town_of_birth                => NVL(l_per_rec.town_of_birth
5161                                         ,l_cur_per_rec.town_of_birth)
5162   ,p_region_of_birth              => NVL(l_per_rec.region_of_birth
5163                                         ,l_cur_per_rec.region_of_birth)
5164   ,p_country_of_birth             => NVL(l_per_rec.country_of_birth
5165                                         ,l_cur_per_rec.country_of_birth)
5166   ,p_global_person_id             => NVL(l_per_rec.global_person_id
5167                                         ,l_cur_per_rec.global_person_id)
5168    -- Out Variables
5169   ,p_effective_start_date         => p_updper_api_out.effective_start_date
5170   ,p_effective_end_date           => p_updper_api_out.effective_end_date
5171   ,p_full_name                    => p_updper_api_out.full_name
5172   ,p_comment_id                   => p_updper_api_out.comment_id
5173   ,p_name_combination_warning     => p_updper_api_out.name_combination_warning
5174   ,p_assign_payroll_warning       => p_updper_api_out.assign_payroll_warning
5175   ,p_orig_hire_warning            => p_updper_api_out.orig_hire_warning
5176   );
5177 
5178   IF g_debug_on THEN
5179     hr_utility.set_location('..effective_start_date : ' ||
5180                              p_updper_api_out.effective_start_date,40);
5181     hr_utility.set_location('..effective_end_date   : ' ||
5182                              p_updper_api_out.effective_end_date,40);
5183     hr_utility.set_location('..full_name            : ' ||
5184                              p_updper_api_out.full_name,40);
5185     hr_utility.set_location('Leaving: ' || l_proc_name, 40);
5186   END IF;
5187 
5188 EXCEPTION
5189   WHEN e_future_chgs_exists THEN
5190     l_error_msg := 'This person cannot be created in HRMS as a Student '||
5191                    'Employee due to future changes beyond the date: '||p_effective_date;
5192 
5193     hr_utility.set_location('..Future Update exists for the Student Employee', 60);
5194     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
5195     hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
5196     hr_utility.set_location('Leaving: ' || l_proc_name, 60);
5197     hr_utility.raise_error;
5198 
5199   WHEN Others THEN
5200   hr_utility.set_location('SQLERRM :' || SQLCODE,90);
5201   hr_utility.set_location('Leaving: ' || l_proc_name, 90);
5202   RAISE;
5203 
5204 END Upd_OSS_Person;
5205 
5206 -- =============================================================================
5207 -- ~ create_student_employee:
5208 -- =============================================================================
5209 PROCEDURE create_student_employee
5210          (p_last_name                    IN Varchar2
5211          ,p_middle_name                  IN Varchar2
5212          ,p_first_name                   IN Varchar2
5213          ,p_suffix                       IN Varchar2
5214          ,p_prefix                       IN Varchar2
5215          ,p_title                        IN Varchar2
5216          ,p_email_address                IN Varchar2
5217          ,p_preferred_name               IN Varchar2
5218          ,p_dup_person_id                IN Number
5219          ,p_dup_party_id                 IN Number
5220          ,p_marital_status               IN Varchar2
5221          ,p_sex                          IN Varchar2
5222          ,p_nationality                  IN Varchar2
5223          ,p_national_identifier          IN Varchar2
5224          ,p_date_of_birth                IN Date
5225          ,p_date_of_hire                 IN Date
5226          ,p_employee_number              IN Varchar2
5227          ,p_primary_flag                 IN Varchar2
5228          ,p_address_style                IN Varchar2
5229          ,p_address_line1                IN Varchar2
5230          ,p_address_line2                IN Varchar2
5231          ,p_address_line3                IN Varchar2
5232          ,p_region1                      IN Varchar2
5233          ,p_region2                      IN Varchar2
5234          ,p_region3                      IN Varchar2
5235          ,p_town_or_city                 IN Varchar2
5236          ,p_country                      IN Varchar2
5237          ,p_postal_code                  IN Varchar2
5238          ,p_telephone_no1                IN Varchar2
5239          ,p_telephone_no2                IN Varchar2
5240          ,p_telephone_no3                IN Varchar2
5241          ,p_address_date_from            IN Date
5242          ,p_address_date_to              IN Date
5243          ,p_phone_type                   IN Varchar2
5244          ,p_phone_number                 IN Varchar2
5245          ,p_phone_date_from              IN Date
5246          ,p_phone_date_to                IN Date
5247          ,p_contact_type                 IN Varchar2
5248          ,p_contact_name                 IN Varchar2
5249          ,p_primary_contact              IN Varchar2
5250          ,p_personal_flag                IN Varchar2
5251          ,p_contact_date_from            IN Date
5252          ,p_contact_date_to              IN Date
5253          ,p_assign_organization          IN Varchar2
5254          ,p_job                          IN Number
5255          ,p_grade                        IN Number
5256          ,p_internal_location            IN Varchar2
5257          ,p_assign_group                 IN Varchar2
5258          ,p_position                     IN Number
5259          ,p_payroll                      IN Number
5260          ,p_status                       IN Varchar2
5261          ,p_assignment_no                IN Varchar2
5262          ,p_assignment_category          IN Varchar2
5263          ,p_collective_agreement         IN Varchar2
5264          ,p_employee_category            IN Varchar2
5265          ,p_user_person_type             IN Number
5266          ,p_salary_basis                 IN Number
5267          ,p_gre                          IN Varchar2
5268          ,p_web_adi_identifier           IN Varchar2
5269          ,p_assign_eff_dt_from           IN Date
5270          ,p_assign_eff_dt_to             IN Date
5271          ,p_per_attribute_category       IN Varchar2
5272          ,p_per_attribute1               IN Varchar2
5273          ,p_per_attribute2               IN Varchar2
5274          ,p_per_attribute3               IN Varchar2
5275          ,p_per_attribute4               IN Varchar2
5276          ,p_per_attribute5               IN Varchar2
5277          ,p_per_attribute6               IN Varchar2
5278          ,p_per_attribute7               IN Varchar2
5279          ,p_per_attribute8               IN Varchar2
5280          ,p_per_attribute9               IN Varchar2
5281          ,p_per_attribute10              IN Varchar2
5282          ,p_per_attribute11              IN Varchar2
5283          ,p_per_attribute12              IN Varchar2
5284          ,p_per_attribute13              IN Varchar2
5285          ,p_per_attribute14              IN Varchar2
5286          ,p_per_attribute15              IN Varchar2
5287          ,p_per_attribute16              IN Varchar2
5288          ,p_per_attribute17              IN Varchar2
5289          ,p_per_attribute18              IN Varchar2
5290          ,p_per_attribute19              IN Varchar2
5291          ,p_per_attribute20              IN Varchar2
5292          ,p_per_attribute21              IN Varchar2
5293          ,p_per_attribute22              IN Varchar2
5294          ,p_per_attribute23              IN Varchar2
5295          ,p_per_attribute24              IN Varchar2
5296          ,p_per_attribute25              IN Varchar2
5297          ,p_per_attribute26              IN Varchar2
5298          ,p_per_attribute27              IN Varchar2
5299          ,p_per_attribute28              IN Varchar2
5300          ,p_per_attribute29              IN Varchar2
5301          ,p_per_attribute30              IN Varchar2
5302          ,p_per_information_category     IN Varchar2
5303          ,p_per_information1             IN Varchar2
5304          ,p_per_information2             IN Varchar2
5305          ,p_per_information3             IN Varchar2
5306          ,p_per_information4             IN Varchar2
5307          ,p_per_information5             IN Varchar2
5308          ,p_per_information6             IN Varchar2
5309          ,p_per_information7             IN Varchar2
5310          ,p_per_information8             IN Varchar2
5311          ,p_per_information9             IN Varchar2
5312          ,p_per_information10            IN Varchar2
5313          ,p_per_information11            IN Varchar2
5314          ,p_per_information12            IN Varchar2
5315          ,p_per_information13            IN Varchar2
5316          ,p_per_information14            IN Varchar2
5317          ,p_per_information15            IN Varchar2
5318          ,p_per_information16            IN Varchar2
5319          ,p_per_information17            IN Varchar2
5320          ,p_per_information18            IN Varchar2
5321          ,p_per_information19            IN Varchar2
5322          ,p_per_information20            IN Varchar2
5323          ,p_per_information21            IN Varchar2
5324          ,p_per_information22            IN Varchar2
5325          ,p_per_information23            IN Varchar2
5326          ,p_per_information24            IN Varchar2
5327          ,p_per_information25            IN Varchar2
5328          ,p_per_information26            IN Varchar2
5329          ,p_per_information27            IN Varchar2
5330          ,p_per_information28            IN Varchar2
5331          ,p_per_information29            IN Varchar2
5332          ,p_per_information30            IN Varchar2
5333          ,p_ass_attribute_category       IN Varchar2
5334          ,p_ass_attribute1               IN Varchar2
5335          ,p_ass_attribute2               IN Varchar2
5336          ,p_ass_attribute3               IN Varchar2
5337          ,p_ass_attribute4               IN Varchar2
5338          ,p_ass_attribute5               IN Varchar2
5339          ,p_ass_attribute6               IN Varchar2
5340          ,p_ass_attribute7               IN Varchar2
5341          ,p_ass_attribute8               IN Varchar2
5342          ,p_ass_attribute9               IN Varchar2
5343          ,p_ass_attribute10              IN Varchar2
5344          ,p_ass_attribute11              IN Varchar2
5345          ,p_ass_attribute12              IN Varchar2
5346          ,p_ass_attribute13              IN Varchar2
5347          ,p_ass_attribute14              IN Varchar2
5348          ,p_ass_attribute15              IN Varchar2
5349          ,p_ass_attribute16              IN Varchar2
5350          ,p_ass_attribute17              IN Varchar2
5351          ,p_ass_attribute18              IN Varchar2
5352          ,p_ass_attribute19              IN Varchar2
5353          ,p_ass_attribute20              IN Varchar2
5354          ,p_ass_attribute21              IN Varchar2
5355          ,p_ass_attribute22              IN Varchar2
5356          ,p_ass_attribute23              IN Varchar2
5357          ,p_ass_attribute24              IN Varchar2
5358          ,p_ass_attribute25              IN Varchar2
5359          ,p_ass_attribute26              IN Varchar2
5360          ,p_ass_attribute27              IN Varchar2
5361          ,p_ass_attribute28              IN Varchar2
5362          ,p_ass_attribute29              IN Varchar2
5363          ,p_ass_attribute30              IN Varchar2
5364          ,p_adr_attribute_category       IN Varchar2
5365          ,p_adr_attribute1               IN Varchar2
5366          ,p_adr_attribute2               IN Varchar2
5367          ,p_adr_attribute3               IN Varchar2
5368          ,p_adr_attribute4               IN Varchar2
5369          ,p_adr_attribute5               IN Varchar2
5370          ,p_adr_attribute6               IN Varchar2
5371          ,p_adr_attribute7               IN Varchar2
5372          ,p_adr_attribute8               IN Varchar2
5373          ,p_adr_attribute9               IN Varchar2
5374          ,p_adr_attribute10              IN Varchar2
5375          ,p_adr_attribute11              IN Varchar2
5376          ,p_adr_attribute12              IN Varchar2
5377          ,p_adr_attribute13              IN Varchar2
5378          ,p_adr_attribute14              IN Varchar2
5379          ,p_adr_attribute15              IN Varchar2
5380          ,p_adr_attribute16              IN Varchar2
5381          ,p_adr_attribute17              IN Varchar2
5382          ,p_adr_attribute18              IN Varchar2
5383          ,p_adr_attribute19              IN Varchar2
5384          ,p_adr_attribute20              IN Varchar2
5385          ,p_business_group_id            IN Number
5386          ,p_data_pump_flag               IN Varchar2
5387          ,p_add_information13            IN Varchar2
5388          ,p_add_information14            IN Varchar2
5389          ,p_add_information15            IN Varchar2
5390          ,p_add_information16            IN Varchar2
5391          ,p_add_information17            IN Varchar2
5392          ,p_add_information18            IN Varchar2
5393          ,p_add_information19            IN Varchar2
5394          ,p_add_information20            IN Varchar2
5395          ,p_concat_segments              IN Varchar2
5396          ,p_people_segment1              IN Varchar2
5397          ,p_people_segment2              IN Varchar2
5398          ,p_people_segment3              IN Varchar2
5399          ,p_people_segment4              IN Varchar2
5400          ,p_people_segment5              IN Varchar2
5401          ,p_people_segment6              IN Varchar2
5402          ,p_people_segment7              IN Varchar2
5403          ,p_people_segment8              IN Varchar2
5404          ,p_people_segment9              IN Varchar2
5405          ,p_people_segment10             IN Varchar2
5406          ,p_people_segment11             IN Varchar2
5407          ,p_people_segment12             IN Varchar2
5408          ,p_people_segment13             IN Varchar2
5409          ,p_people_segment14             IN Varchar2
5410          ,p_people_segment15             IN Varchar2
5411          ,p_people_segment16             IN Varchar2
5412          ,p_people_segment17             IN Varchar2
5413          ,p_people_segment18             IN Varchar2
5414          ,p_people_segment19             IN Varchar2
5415          ,p_people_segment20             IN Varchar2
5416          ,p_people_segment21             IN Varchar2
5417          ,p_people_segment22             IN Varchar2
5418          ,p_people_segment23             IN Varchar2
5419          ,p_people_segment24             IN Varchar2
5420          ,p_people_segment25             IN Varchar2
5421          ,p_people_segment26             IN Varchar2
5422          ,p_people_segment27             IN Varchar2
5423          ,p_people_segment28             IN Varchar2
5424          ,p_people_segment29             IN Varchar2
5425          ,p_people_segment30             IN Varchar2
5426          ,p_soft_segments                IN Varchar2
5427          ,p_soft_segment1                IN Varchar2
5428          ,p_soft_segment2                IN Varchar2
5429          ,p_soft_segment3                IN Varchar2
5430          ,p_soft_segment4                IN Varchar2
5431          ,p_soft_segment5                IN Varchar2
5432          ,p_soft_segment6                IN Varchar2
5433          ,p_soft_segment7                IN Varchar2
5434          ,p_soft_segment8                IN Varchar2
5435          ,p_soft_segment9                IN Varchar2
5436          ,p_soft_segment10               IN Varchar2
5437          ,p_soft_segment11               IN Varchar2
5438          ,p_soft_segment12               IN Varchar2
5439          ,p_soft_segment13               IN Varchar2
5440          ,p_soft_segment14               IN Varchar2
5441          ,p_soft_segment15               IN Varchar2
5442          ,p_soft_segment16               IN Varchar2
5443          ,p_soft_segment17               IN Varchar2
5444          ,p_soft_segment18               IN Varchar2
5445          ,p_soft_segment19               IN Varchar2
5446          ,p_soft_segment20               IN Varchar2
5447          ,p_soft_segment21               IN Varchar2
5448          ,p_soft_segment22               IN Varchar2
5449          ,p_soft_segment23               IN Varchar2
5450          ,p_soft_segment24               IN Varchar2
5451          ,p_soft_segment25               IN Varchar2
5452          ,p_soft_segment26               IN Varchar2
5453          ,p_soft_segment27               IN Varchar2
5454          ,p_soft_segment28               IN Varchar2
5455          ,p_soft_segment29               IN Varchar2
5456          ,p_soft_segment30               IN Varchar2
5457          ,p_business_group_name          IN Varchar2
5458          ,p_batch_id                     IN Number
5459          ,p_data_pump_batch_line_id      IN Varchar2
5460          ,p_per_comments                 IN Varchar2
5461          ,p_date_employee_data_verified  IN Date
5462          ,p_expense_check_send_to_addres IN Varchar2
5463          ,p_previous_last_name           IN Varchar2
5464          ,p_registered_disabled_flag     IN Varchar2
5465          ,p_vendor_id                    IN Number
5466          ,p_date_of_death                IN Date
5467          ,p_background_check_status      IN Varchar2
5468          ,p_background_date_check        IN Date
5469          ,p_blood_type                   IN Varchar2
5470          ,p_correspondence_language      IN Varchar2
5471          ,p_fast_path_employee           IN Varchar2
5472          ,p_fte_capacity                 IN Number
5473          ,p_honors                       IN Varchar2
5474          ,p_last_medical_test_by         IN Varchar2
5475          ,p_last_medical_test_date       IN Date
5476          ,p_mailstop                     IN Varchar2
5477          ,p_office_number                IN Varchar2
5478          ,p_on_military_service          IN Varchar2
5479          ,p_pre_name_adjunct             IN Varchar2
5480          ,p_projected_start_date         IN Date
5481          ,p_resume_exists                IN Varchar2
5482          ,p_resume_last_updated          IN Date
5483          ,p_second_passport_exists       IN Varchar2
5484          ,p_student_status               IN Varchar2
5485          ,p_work_schedule                IN Varchar2
5486          ,p_benefit_group_id             IN Number
5487          ,p_receipt_of_death_cert_date   IN Date
5488          ,p_coord_ben_med_pln_no         IN Varchar2
5489          ,p_coord_ben_no_cvg_flag        IN Varchar2
5490          ,p_coord_ben_med_ext_er         IN Varchar2
5491          ,p_coord_ben_med_pl_name        IN Varchar2
5492          ,p_coord_ben_med_insr_crr_name  IN Varchar2
5493          ,p_coord_ben_med_insr_crr_ident IN Varchar2
5494          ,p_coord_ben_med_cvg_strt_dt    IN Date
5495          ,p_coord_ben_med_cvg_end_dt     IN Date
5496          ,p_uses_tobacco_flag            IN Varchar2
5497          ,p_dpdnt_adoption_date          IN Date
5498          ,p_dpdnt_vlntry_svce_flag       IN Varchar2
5499          ,p_original_date_of_hire        IN Date
5500          ,p_adjusted_svc_date            IN Date
5501          ,p_town_of_birth                IN Varchar2
5502          ,p_region_of_birth              IN Varchar2
5503          ,p_country_of_birth             IN Varchar2
5504          ,p_global_person_id             IN Varchar2
5505          ,p_party_id                     IN Number
5506          ,p_supervisor_id                IN Number
5507          ,p_assignment_number            IN Varchar2
5508          ,p_change_reason                IN Varchar2
5509          ,p_asg_comments                 IN Varchar2
5510          ,p_date_probation_end           IN Date
5511          ,p_default_code_comb_id         IN Number
5512          ,p_frequency                    IN Varchar2
5513          ,p_internal_address_line        IN Varchar2
5514          ,p_manager_flag                 IN Varchar2
5515          ,p_normal_hours                 IN Number
5516          ,p_perf_review_period           IN Number
5517          ,p_perf_review_period_frequency IN Varchar2
5518          ,p_probation_period             IN Number
5519          ,p_probation_unit               IN Varchar2
5520          ,p_sal_review_period            IN Number
5521          ,p_sal_review_period_frequency  IN Varchar2
5522          ,p_set_of_books_id              IN Number
5523          ,p_source_type                  IN Varchar2
5524          ,p_time_normal_finish           IN Varchar2
5525          ,p_time_normal_start            IN Varchar2
5526          ,p_bargaining_unit_code         IN Varchar2
5527          ,p_labour_union_member_flag     IN Varchar2
5528          ,p_hourly_salaried_code         IN Varchar2
5529          ,p_pradd_ovlapval_override      IN Varchar2
5530          ,p_address_type                 IN Varchar2
5531          ,p_adr_comments                 IN Varchar2
5532          ,p_batch_name                   IN Varchar2
5533          ,p_location_id                  IN Number
5534          ,p_student_number               IN Varchar2
5535           ) AS
5536 
5537   -- Checking for EX-EMP as we should allow a person to be rehired, that implies
5538   -- that NI for EX-Employee may already exist
5539   CURSOR csr_chk_ni_exists (c_ni       Varchar2
5540                            ,c_bgid     Number
5541                            ,c_eff_date Date) IS
5542   SELECT 'Y'
5543     FROM per_people_f ppf, per_person_types ppt
5544    WHERE ppf.national_identifier = c_ni
5545      AND ppf.business_group_id   = c_bgid
5546      AND ppf.business_group_id   = ppt.business_group_id
5547      AND ppf.person_type_id      = ppt.person_type_id
5548      AND ppt.active_flag         = 'Y'
5549      AND c_eff_date BETWEEN ppf.effective_start_date
5550                         AND ppf.effective_end_date;
5551 
5552   -- Cursor to fetch duplicate assignment id using duplicate person id
5553   CURSOR  get_dup_asg_id (c_dup_per_id         Varchar2
5554                          ,c_business_group_id  Varchar2
5555                          ,c_eff_date           Date) IS
5556   SELECT paf.assignment_id
5557     FROM per_people_f ppf, per_assignments_f paf
5558    WHERE paf.person_id          = c_dup_per_id
5559      AND paf.person_id          = ppf.person_id
5560      AND paf.business_group_id  = c_business_group_id
5561      AND paf.business_group_id  = ppf.business_group_id
5562      AND c_eff_date BETWEEN paf.effective_start_date
5563                         AND paf.effective_end_date
5564      AND c_eff_date BETWEEN ppf.effective_start_date
5565                         AND ppf.effective_end_date;
5566 
5567 
5568 
5569   -- Dynamic Ref Cursor
5570   TYPE ref_cur_typ IS REF CURSOR;
5571   csr_get_unmasked_ni          ref_cur_typ;
5572   csr_get_party_id             ref_cur_typ;
5573 
5574   l_chk_per                chk_party%ROWTYPE;
5575   l_dff_ctx          fnd_descr_flex_contexts.descriptive_flex_context_code%TYPE;
5576   l_emp_api_out            t_hrEmpApi;
5577   l_asg_crit_out           t_AsgUpdCrit_Api;
5578   l_updper_api_out         t_UpdEmp_Api;
5579   l_crt_emp_api_out        t_CreateContact_Api;
5580   l_HireToJobapi_out       t_HrToJob_Api;
5581   l_effective_date         Date;
5582   l_national_identifier    per_people_f.national_identifier%TYPE;
5583   l_party_id               per_people_f.party_id%TYPE;
5584   l_ni_exists              Varchar2(10);
5585   l_dyn_sql_qry            Varchar(500);
5586   l_sql_qry                Varchar(500);
5587   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Create_Student_Employee';
5588 
5589   l_pp_error_code          Varchar2(50);
5590   l_passport_warning       Boolean;
5591   l_visa_error_code        Varchar2(50);
5592   l_visa_warning           Boolean;
5593   l_visit_error_code       Varchar2(50);
5594   l_visit_warning          Boolean;
5595 
5596   l_oss_error_code         Varchar2(50);
5597   l_ossDtls_warning        Boolean;
5598 
5599   l_student_number         Varchar2(100);
5600   l_dup_asg_id             Number;
5601   l_HireAppapi_out         t_HrApp_Api;
5602   l_error_message          Varchar2(2000);
5603   l_active_cwk             Boolean;
5604   e_active_cwk             Exception;
5605 
5606  --  Function to return correct format of people group segments (Bug 4160812)
5607  FUNCTION f_formatted_grp_seg_val(p_seg_name IN VARCHAR2,p_seg_val IN VARCHAR2)
5608    RETURN VARCHAR2
5609  IS
5610    l_format_type fnd_flex_value_sets.format_type%TYPE;
5611  BEGIN
5612    SELECT format_type  INTO l_format_type
5613     FROM FND_ID_FLEX_SEGMENTS_VL a, fnd_flex_value_sets b
5614    WHERE id_flex_num = (SELECT people_group_structure
5615                        FROM per_business_groups_perf
5616                        WHERE business_group_id = p_business_group_id)
5617    AND a.flex_value_set_id = b.flex_value_set_id
5618    AND 'p_people_'||lower(application_column_name) = p_seg_name;
5619 
5620    IF l_format_type in ('X','Y') THEN
5621       RETURN fnd_date.date_to_canonical(p_seg_val);
5622    ELSE
5623       RETURN p_seg_val;
5624    END IF;
5625  EXCEPTION WHEN others THEN
5626    RETURN p_seg_val;
5627  END;
5628 
5629 BEGIN
5630     SAVEPOINT create_student_employee;
5631     g_debug_on := hr_utility.debug_enabled;
5632 
5633     hr_utility.set_location('Entering: ' || l_proc_name, 10);
5634 
5635     l_per_rec        := NULL;
5636     l_hr_soft_rec    := NULL;
5637     l_add_rec        := NULL;
5638     l_ppl_grp_rec    := NULL;
5639     l_asg_rec        := NULL;
5640     l_effective_date := p_date_of_hire;
5641     l_dup_asg_id     := 0;
5642 
5643     -- Get Bus. Group Id in a pkg global variable
5644 
5645     IF (csr_bg_code%ISOPEN) THEN
5646         CLOSE csr_bg_code;
5647     END IF;
5648     OPEN  csr_bg_code (c_bg_grp_id => p_business_group_id);
5649     FETCH csr_bg_code
5650        INTO g_leg_code,
5651             g_emp_num_gen;
5652     CLOSE csr_bg_code;
5653 
5654   -- Check if NI is masked, If yes then get the actual NI from OSS/DP tables
5655   -- Right now the logic assumes that NI is for GB and US legislation only
5656   -- Later we will have a generic logic to identify the masking
5657 
5658     l_student_number := p_student_number;
5659     IF (substrb(p_national_identifier, 1, lengthb(p_national_identifier) - 4) =
5660             'XXX-XX-' OR
5661        substrb(p_national_identifier, 3, 2) = 'XX'  OR
5662        substrb(p_national_identifier, 1, lengthb(p_national_identifier) - 4) =
5663             'XXXXX') THEN
5664      -- Getting the National Identifier only if the student number and last
5665      -- 4 digits of the masked NI are same. This logic will fail if user
5666      -- changes NI or Student number. Hence it needs to be documneted
5667 
5668         hr_utility.set_location('Checking NI ', 20);
5669 
5670         IF p_web_adi_identifier <> 'DP ERROR' THEN
5671             l_dyn_sql_qry := 'SELECT api_person_id '        ||
5672                             'FROM   igs_pe_person_v '      ||
5673                             'WHERE  person_number = ''' || l_student_number
5674                                            || ''' ' ||
5675                            ' AND api_person_id LIKE ''%' ||
5676                            SUBSTRB(p_national_identifier,
5677                            LENGTHB(p_national_identifier) - 3, 4) || '''';
5678         ELSE
5679             l_dyn_sql_qry := 'SELECT p_national_identifier ' ||
5680                             ' FROM hrdpv_create_employee '  ||
5681                             ' WHERE batch_id = ' || p_batch_id  ||
5682                             ' AND link_value = ' || p_data_pump_batch_line_id ||
5683                             ' UNION SELECT p_national_identifier ' ||
5684                             ' FROM hrdpv_update_person '           ||
5685                             ' WHERE batch_id = ' || p_batch_id     ||
5686                             ' AND link_value = ' || p_data_pump_batch_line_id;
5687 
5688         END IF;
5689 
5690         IF (csr_get_unmasked_ni%ISOPEN) THEN
5691             CLOSE csr_get_unmasked_ni;
5692         END IF;
5693         OPEN  csr_get_unmasked_ni FOR l_dyn_sql_qry;
5694         FETCH csr_get_unmasked_ni INTO l_national_identifier;
5695         CLOSE csr_get_unmasked_ni;
5696     ELSE
5697         l_national_identifier := p_national_identifier;
5698     END IF;
5699 
5700   -- Check if NI entered already exists in the system, that implies that user is
5701   -- accidently trying to enter a duplicate. Throw an error for the same
5702   -- Essentially this over rides the Profile Value used to control the
5703   -- duplicate NI in system
5704 
5705     IF (csr_chk_ni_exists%ISOPEN) THEN -- {
5706         CLOSE csr_chk_ni_exists;
5707     END IF; -- }
5708     OPEN  csr_chk_ni_exists( c_ni       => l_national_identifier
5709                            , c_bgid     => p_business_group_id
5710                            , c_eff_date => p_date_of_hire);
5711 
5712     FETCH csr_chk_ni_exists INTO l_ni_exists;
5713     CLOSE csr_chk_ni_exists;
5714 
5715     IF l_ni_exists IS NOT NULL AND p_dup_person_id IS NULL THEN -- {
5716         hr_utility.set_message(8303, 'PQP_230171_OSS_NI_EXISTS');
5717         hr_utility.raise_error;
5718     END IF; -- }
5719 
5720   -- Get Party Id corresponding to Student Number. We are assuming that there
5721   -- will never be a case when student number is not entered
5722 
5723     IF (l_student_number IS NOT NULL) THEN -- {
5724         hr_utility.set_location('Student number is not null ', 30);
5725         l_sql_qry := 'SELECT ipe.person_id ' ||
5726                      ' FROM igs_pe_person_v ipe, hz_party_sites hps '        ||
5727                      ' WHERE hps.party_id (+)              = ipe.person_id ' ||
5728                      ' AND hps.identifying_address_flag(+) = ''Y'' '         ||
5729                      ' AND ipe.person_number = ''' ||
5730                                          l_student_number || '''';
5731 
5732         hr_utility.set_location('Dynamic query build ', 40);
5733 
5734         IF (csr_get_party_id%ISOPEN) THEN -- {
5735             CLOSE csr_get_party_id;
5736         END IF; -- }
5737         OPEN  csr_get_party_id FOR l_sql_qry;
5738         FETCH csr_get_party_id INTO l_party_id;
5739         CLOSE csr_get_party_id;
5740     END IF; -- }
5741 
5742     hr_utility.set_location('Start of filling person rec ', 50);
5743 
5744   -- ===========================================================================
5745   -- ~ Person Details
5746   -- ===========================================================================
5747     l_per_rec.business_group_id           := p_business_group_id;
5748     l_per_rec.party_id                    := l_party_id;
5749     l_per_rec.last_name                   := p_last_name;
5750     l_per_rec.middle_names                := p_middle_name;
5751     l_per_rec.first_name                  := p_first_name;
5752     l_per_rec.suffix                      := p_suffix;
5753     l_per_rec.pre_name_adjunct            := p_prefix;
5754     l_per_rec.title                       := p_title;
5755     l_per_rec.email_address               := p_email_address;
5756     l_per_rec.known_as                    := p_preferred_name;
5757     l_per_rec.marital_status              := p_marital_status;
5758     l_per_rec.sex                         := p_sex;
5759     l_per_rec.nationality                 := p_nationality;
5760     l_per_rec.national_identifier         := l_national_identifier;
5761     l_per_rec.date_of_birth               := p_date_of_birth;
5762     l_per_rec.start_date                  := p_date_of_hire;
5763     l_per_rec.employee_number             := p_employee_number;
5764     l_per_rec.person_type_id              := p_user_person_type;
5765     l_per_rec.date_employee_data_verified := p_date_employee_data_verified;
5766     l_per_rec.expense_check_send_to_address := p_expense_check_send_to_addres;
5767     l_per_rec.previous_last_name          := p_previous_last_name;
5768     l_per_rec.registered_disabled_flag    := p_registered_disabled_flag;
5769     l_per_rec.vendor_id                   := p_vendor_id;
5770     l_per_rec.date_of_death               := p_date_of_death;
5771     l_per_rec.background_check_status     := p_background_check_status;
5772     l_per_rec.background_date_check       := p_background_date_check;
5773     l_per_rec.blood_type                  := p_blood_type;
5774     l_per_rec.correspondence_language     := p_correspondence_language;
5775     l_per_rec.fast_path_employee          := p_fast_path_employee;
5776     l_per_rec.fte_capacity                := p_fte_capacity;
5777     l_per_rec.honors                      := p_honors;
5778     l_per_rec.last_medical_test_by        := p_last_medical_test_by;
5779     l_per_rec.last_medical_test_date      := p_last_medical_test_date;
5780     l_per_rec.mailstop                    := p_mailstop;
5781     l_per_rec.office_number               := p_office_number;
5782     l_per_rec.on_military_service         := NVL(p_on_military_service,'N');
5783 -- pre_name_adjunct is called as prefix in OSS and hence the correct value
5784 -- is picked from the parameter p_prefix and not p_pre_name_adjunct.
5785 --    l_per_rec.pre_name_adjunct            := p_pre_name_adjunct;
5786     l_per_rec.projected_start_date        := p_projected_start_date;
5787     l_per_rec.resume_exists               := NVL(p_resume_exists,'N');
5788     l_per_rec.resume_last_updated         := p_resume_last_updated;
5789     l_per_rec.second_passport_exists      := NVL(p_second_passport_exists,'N');
5790     l_per_rec.student_status              := p_student_status;
5791     l_per_rec.work_schedule               := p_work_schedule;
5792     l_per_rec.benefit_group_id            := p_benefit_group_id;
5793     l_per_rec.receipt_of_death_cert_date  := p_receipt_of_death_cert_date;
5794     l_per_rec.coord_ben_med_pln_no        := p_coord_ben_med_pln_no;
5795     l_per_rec.coord_ben_no_cvg_flag       := NVL(p_coord_ben_no_cvg_flag,'N');
5796     l_per_rec.coord_ben_med_ext_er        := p_coord_ben_med_ext_er;
5797     l_per_rec.coord_ben_med_pl_name       := p_coord_ben_med_pl_name;
5798     l_per_rec.coord_ben_med_insr_crr_name := p_coord_ben_med_insr_crr_name;
5799     l_per_rec.coord_ben_med_insr_crr_ident:= p_coord_ben_med_insr_crr_ident;
5800     l_per_rec.coord_ben_med_cvg_strt_dt   := p_coord_ben_med_cvg_strt_dt;
5801     l_per_rec.coord_ben_med_cvg_end_dt    := p_coord_ben_med_cvg_end_dt;
5802     l_per_rec.uses_tobacco_flag           := p_uses_tobacco_flag;
5803     l_per_rec.dpdnt_adoption_date         := p_dpdnt_adoption_date;
5804     l_per_rec.dpdnt_vlntry_svce_flag      := NVL(p_dpdnt_vlntry_svce_flag,'N');
5805     l_per_rec.original_date_of_hire       := p_original_date_of_hire;
5806     l_per_rec.town_of_birth               := p_town_of_birth;
5807     l_per_rec.region_of_birth             := p_region_of_birth;
5808     l_per_rec.country_of_birth            := p_country_of_birth;
5809     l_per_rec.global_person_id            := p_global_person_id;
5810 
5811     hr_utility.set_location('Person Details assigned to record : l_per_rec ',
5812                                                                    60);
5813 
5814     -- Person DF: Customer defined
5815 
5816     l_per_rec.attribute_category            := p_per_attribute_category;
5817     l_per_rec.attribute1                    := p_per_attribute1;
5818     l_per_rec.attribute2                    := p_per_attribute2;
5819     l_per_rec.attribute3                    := p_per_attribute3;
5820     l_per_rec.attribute4                    := p_per_attribute4;
5821     l_per_rec.attribute5                    := p_per_attribute5;
5822     l_per_rec.attribute6                    := p_per_attribute6;
5823     l_per_rec.attribute7                    := p_per_attribute7;
5824     l_per_rec.attribute8                    := p_per_attribute8;
5825     l_per_rec.attribute9                    := p_per_attribute9;
5826     l_per_rec.attribute10                   := p_per_attribute10;
5827     l_per_rec.attribute11                   := p_per_attribute11;
5828     l_per_rec.attribute12                   := p_per_attribute12;
5829     l_per_rec.attribute13                   := p_per_attribute13;
5830     l_per_rec.attribute14                   := p_per_attribute14;
5831     l_per_rec.attribute15                   := p_per_attribute15;
5832     l_per_rec.attribute16                   := p_per_attribute16;
5833     l_per_rec.attribute17                   := p_per_attribute17;
5834     l_per_rec.attribute18                   := p_per_attribute18;
5835     l_per_rec.attribute19                   := p_per_attribute19;
5836     l_per_rec.attribute20                   := p_per_attribute20;
5837     l_per_rec.attribute21                   := p_per_attribute21;
5838     l_per_rec.attribute22                   := p_per_attribute22;
5839     l_per_rec.attribute23                   := p_per_attribute23;
5840     l_per_rec.attribute24                   := p_per_attribute24;
5841     l_per_rec.attribute25                   := p_per_attribute25;
5842     l_per_rec.attribute26                   := p_per_attribute26;
5843     l_per_rec.attribute27                   := p_per_attribute27;
5844     l_per_rec.attribute28                   := p_per_attribute28;
5845     l_per_rec.attribute29                   := p_per_attribute29;
5846     l_per_rec.attribute30                   := p_per_attribute30;
5847 
5848     hr_utility.set_location('Person DF assigned to record :l_per_rec ', 70);
5849 
5850     -- Person DDF: Different for each legislation
5851 
5852     IF (csr_style%ISOPEN) THEN -- {
5853         CLOSE csr_style;
5854     END IF; -- }
5855     OPEN  csr_style (c_context_code => g_leg_code);
5856     FETCH csr_style INTO l_dff_ctx;
5857     IF csr_style%FOUND THEN
5858         l_per_rec.per_information_category  :=
5859                  NVL(p_per_information_category, g_leg_code);
5860     END IF;
5861     CLOSE csr_style;
5862 
5863     l_per_rec.per_information1              := p_per_information1;
5864     l_per_rec.per_information2              := p_per_information2;
5865     l_per_rec.per_information3              := p_per_information3;
5866     l_per_rec.per_information4              := p_per_information4;
5867     l_per_rec.per_information5              := p_per_information5;
5868     l_per_rec.per_information6              := p_per_information6;
5869     l_per_rec.per_information7              := p_per_information7;
5870     l_per_rec.per_information8              := p_per_information8;
5871     l_per_rec.per_information9              := p_per_information9;
5872     l_per_rec.per_information10             := p_per_information10;
5873     l_per_rec.per_information11             := p_per_information11;
5874     l_per_rec.per_information12             := p_per_information12;
5875     l_per_rec.per_information13             := p_per_information13;
5876     l_per_rec.per_information14             := p_per_information14;
5877     l_per_rec.per_information15             := p_per_information15;
5878     l_per_rec.per_information16             := p_per_information16;
5879     l_per_rec.per_information17             := p_per_information17;
5880     l_per_rec.per_information18             := p_per_information18;
5881     l_per_rec.per_information19             := p_per_information19;
5882     l_per_rec.per_information20             := p_per_information20;
5883     l_per_rec.per_information21             := p_per_information21;
5884     l_per_rec.per_information22             := p_per_information22;
5885     l_per_rec.per_information23             := p_per_information23;
5886     l_per_rec.per_information24             := p_per_information24;
5887     l_per_rec.per_information25             := p_per_information25;
5888     l_per_rec.per_information26             := p_per_information26;
5889     l_per_rec.per_information27             := p_per_information27;
5890     l_per_rec.per_information28             := p_per_information28;
5891     l_per_rec.per_information29             := p_per_information29;
5892     l_per_rec.per_information30             := p_per_information30;
5893 
5894     hr_utility.set_location('Person DDF assigned to record : l_per_rec ', 80);
5895 
5896     -- =======================================================================
5897     -- ~ Person Address Record
5898     -- =======================================================================
5899     l_add_rec.business_group_id             := p_business_group_id;
5900     l_add_rec.party_id                      := l_party_id;
5901     l_add_rec.address_type                  := p_address_type;
5902     l_add_rec.comments                      := p_adr_comments;
5903     l_add_rec.primary_flag                  := p_primary_flag;
5904     l_add_rec.style                         := p_address_style;
5905     l_add_rec.address_line1                 := p_address_line1;
5906     l_add_rec.address_line2                 := p_address_line2;
5907     l_add_rec.address_line3                 := p_address_line3;
5908     l_add_rec.region_1                      := p_region1;
5909     l_add_rec.region_2                      := p_region2;
5910     l_add_rec.region_3                      := p_region3;
5911     l_add_rec.town_or_city                  := p_town_or_city;
5912     l_add_rec.country                       := p_country;
5913     l_add_rec.postal_code                   := p_postal_code;
5914     l_add_rec.telephone_number_1            := p_telephone_no1;
5915     l_add_rec.telephone_number_2            := p_telephone_no2;
5916     l_add_rec.telephone_number_3            := p_telephone_no3;
5917     l_add_rec.date_from                     := p_address_date_from;
5918     l_add_rec.date_to                       := p_address_date_to;
5919     l_add_rec.add_information13             := p_add_information13;
5920     l_add_rec.add_information14             := p_add_information14;
5921     l_add_rec.add_information15             := p_add_information15;
5922     l_add_rec.add_information16             := p_add_information16;
5923     l_add_rec.add_information17             := p_add_information17;
5924     l_add_rec.add_information18             := p_add_information18;
5925     l_add_rec.add_information19             := p_add_information19;
5926     l_add_rec.add_information20             := p_add_information20;
5927 
5928     hr_utility.set_location('Address DDF assigned to record, Style: ' ||
5929                              p_address_style, 90);
5930     -- Address DF
5931 
5932     l_add_rec.addr_attribute_category       := p_adr_attribute_category;
5933     l_add_rec.addr_attribute1               := p_adr_attribute1;
5934     l_add_rec.addr_attribute2               := p_adr_attribute2;
5935     l_add_rec.addr_attribute3               := p_adr_attribute3;
5936     l_add_rec.addr_attribute4               := p_adr_attribute4;
5937     l_add_rec.addr_attribute5               := p_adr_attribute5;
5938     l_add_rec.addr_attribute6               := p_adr_attribute6;
5939     l_add_rec.addr_attribute7               := p_adr_attribute7;
5940     l_add_rec.addr_attribute8               := p_adr_attribute8;
5941     l_add_rec.addr_attribute9               := p_adr_attribute9;
5942     l_add_rec.addr_attribute10              := p_adr_attribute10;
5943     l_add_rec.addr_attribute11              := p_adr_attribute11;
5944     l_add_rec.addr_attribute12              := p_adr_attribute12;
5945     l_add_rec.addr_attribute13              := p_adr_attribute13;
5946     l_add_rec.addr_attribute14              := p_adr_attribute14;
5947     l_add_rec.addr_attribute15              := p_adr_attribute15;
5948     l_add_rec.addr_attribute16              := p_adr_attribute16;
5949     l_add_rec.addr_attribute17              := p_adr_attribute17;
5950     l_add_rec.addr_attribute18              := p_adr_attribute18;
5951     l_add_rec.addr_attribute19              := p_adr_attribute19;
5952     l_add_rec.addr_attribute20              := p_adr_attribute20;
5953 
5954     hr_utility.set_location('Address DF assigned to record, Style: ' ||
5955                              p_address_style, 100);
5956     -- ========================================================================
5957     -- ~ Person Primary Assignment
5958     -- ========================================================================
5959     l_asg_rec.business_group_id             := p_business_group_id;
5960     l_asg_rec.organization_id               := p_assign_organization;
5961     l_asg_rec.job_id                        := p_job;
5962     l_asg_rec.grade_id                      := p_grade;
5963     l_asg_rec.people_group_id               := p_assign_group;
5964     l_asg_rec.position_id                   := p_position;
5965     l_asg_rec.payroll_id                    := p_payroll;
5966     l_asg_rec.assignment_status_type_id     := p_status;
5967     l_asg_rec.assignment_number             := p_assignment_no;
5968     l_asg_rec.assignment_category           := p_assignment_category;
5969     l_asg_rec.collective_agreement_id       := p_collective_agreement;
5970     l_asg_rec.employee_category             := p_employee_category;
5971     l_asg_rec.pay_basis_id                  := p_salary_basis;
5972     l_asg_rec.effective_start_date          := p_assign_eff_dt_from;
5973     l_asg_rec.effective_end_date            := p_assign_eff_dt_to;
5974     l_asg_rec.supervisor_id                 := p_supervisor_id;
5975     l_asg_rec.assignment_number             := p_assignment_number;
5976     l_asg_rec.change_reason                 := p_change_reason;
5977     l_asg_rec.date_probation_end            := p_date_probation_end;
5978     l_asg_rec.default_code_comb_id          := p_default_code_comb_id;
5979     l_asg_rec.frequency                     := p_frequency;
5980     l_asg_rec.internal_address_line         := p_internal_address_line;
5981     l_asg_rec.manager_flag                  := p_manager_flag;
5982     l_asg_rec.normal_hours                  := p_normal_hours;
5983     l_asg_rec.perf_review_period            := p_perf_review_period;
5984     l_asg_rec.perf_review_period_frequency  := p_perf_review_period_frequency;
5985     l_asg_rec.probation_period              := p_probation_period;
5986     l_asg_rec.probation_unit                := p_probation_unit;
5987     l_asg_rec.sal_review_period             := p_sal_review_period;
5988     l_asg_rec.sal_review_period_frequency   := p_sal_review_period_frequency;
5989     l_asg_rec.set_of_books_id               := p_set_of_books_id;
5990     l_asg_rec.source_type                   := p_source_type;
5991     l_asg_rec.time_normal_finish            := p_time_normal_finish;
5992     l_asg_rec.time_normal_start             := p_time_normal_start;
5993     l_asg_rec.bargaining_unit_code          := p_bargaining_unit_code;
5994     l_asg_rec.labour_union_member_flag      := p_labour_union_member_flag;
5995     l_asg_rec.hourly_salaried_code          := p_hourly_salaried_code;
5996     l_asg_rec.location_id                   := p_location_id;
5997 
5998     hr_utility.set_location('Primary Assignment details assigned to ' ||
5999                              'record ', 110);
6000 
6001     -- Additional Assignment Details
6002 
6003     l_asg_rec.ass_attribute_category        := p_ass_attribute_category;
6004     l_asg_rec.ass_attribute1                := p_ass_attribute1;
6005     l_asg_rec.ass_attribute2                := p_ass_attribute2;
6006     l_asg_rec.ass_attribute3                := p_ass_attribute3;
6007     l_asg_rec.ass_attribute4                := p_ass_attribute4;
6008     l_asg_rec.ass_attribute5                := p_ass_attribute5;
6009     l_asg_rec.ass_attribute6                := p_ass_attribute6;
6010     l_asg_rec.ass_attribute7                := p_ass_attribute7;
6011     l_asg_rec.ass_attribute8                := p_ass_attribute8;
6012     l_asg_rec.ass_attribute9                := p_ass_attribute9;
6013     l_asg_rec.ass_attribute10               := p_ass_attribute10;
6014     l_asg_rec.ass_attribute11               := p_ass_attribute11;
6015     l_asg_rec.ass_attribute12               := p_ass_attribute12;
6016     l_asg_rec.ass_attribute13               := p_ass_attribute13;
6017     l_asg_rec.ass_attribute14               := p_ass_attribute14;
6018     l_asg_rec.ass_attribute15               := p_ass_attribute15;
6019     l_asg_rec.ass_attribute16               := p_ass_attribute16;
6020     l_asg_rec.ass_attribute17               := p_ass_attribute17;
6021     l_asg_rec.ass_attribute18               := p_ass_attribute18;
6022     l_asg_rec.ass_attribute19               := p_ass_attribute19;
6023     l_asg_rec.ass_attribute20               := p_ass_attribute20;
6024     l_asg_rec.ass_attribute21               := p_ass_attribute21;
6025     l_asg_rec.ass_attribute22               := p_ass_attribute22;
6026     l_asg_rec.ass_attribute23               := p_ass_attribute23;
6027     l_asg_rec.ass_attribute24               := p_ass_attribute24;
6028     l_asg_rec.ass_attribute25               := p_ass_attribute25;
6029     l_asg_rec.ass_attribute26               := p_ass_attribute26;
6030     l_asg_rec.ass_attribute27               := p_ass_attribute27;
6031     l_asg_rec.ass_attribute28               := p_ass_attribute28;
6032     l_asg_rec.ass_attribute29               := p_ass_attribute29;
6033     l_asg_rec.ass_attribute30               := p_ass_attribute30;
6034 
6035     hr_utility.set_location('Additional Assignment Details assigned to ' ||
6036                             'record ', 120);
6037     -- =======================================================================
6038     -- ~ Contact Details
6039     -- =======================================================================
6040     l_cntct_rec.business_group_id           := p_business_group_id;
6041     l_cntct_rec.contact_type                := p_contact_type;
6042     l_cntct_rec.primary_contact_flag        := p_primary_contact;
6043     l_cntct_rec.personal_flag               := p_personal_flag;
6044 
6045     hr_utility.set_location('Contact details assigned to record ', 130);
6046     -- ========================================================================
6047     -- ~ Person Phones
6048     -- ========================================================================
6049     l_phones_rec.phone_type                 := p_phone_type;
6050     l_phones_rec.phone_number               := p_phone_number;
6051     l_phones_rec.date_from                  := p_phone_date_from;
6052     l_phones_rec.date_to                    := p_phone_date_to;
6053     l_phones_rec.party_id                   := l_party_id;
6054     l_phones_rec.parent_table               := 'PER_ALL_PEOPLE_F';
6055 
6056     hr_utility.set_location('Phone Details assigned to record ', 140);
6057     -- ========================================================================
6058     -- ~ Soft Coding Keyflex field
6059     -- ========================================================================
6060     l_hr_soft_rec.concatenated_segments     := p_soft_segments;
6061     -- Due to issues in WebADI limitation, web-adi will pass p_gre
6062     l_hr_soft_rec.segment1                  := NVL(p_soft_segment1, p_gre);
6063     l_hr_soft_rec.segment2                  := p_soft_segment2;
6064     l_hr_soft_rec.segment3                  := p_soft_segment3;
6065     l_hr_soft_rec.segment4                  := p_soft_segment4;
6066     l_hr_soft_rec.segment5                  := p_soft_segment5;
6067     l_hr_soft_rec.segment6                  := p_soft_segment6;
6068     l_hr_soft_rec.segment7                  := p_soft_segment7;
6069     l_hr_soft_rec.segment8                  := p_soft_segment8;
6070     l_hr_soft_rec.segment9                  := p_soft_segment9;
6071     l_hr_soft_rec.segment10                 := p_soft_segment10;
6072     l_hr_soft_rec.segment11                 := p_soft_segment11;
6073     l_hr_soft_rec.segment12                 := p_soft_segment12;
6074     l_hr_soft_rec.segment13                 := p_soft_segment13;
6075     l_hr_soft_rec.segment14                 := p_soft_segment14;
6076     l_hr_soft_rec.segment15                 := p_soft_segment15;
6077     l_hr_soft_rec.segment16                 := p_soft_segment16;
6078     l_hr_soft_rec.segment17                 := p_soft_segment17;
6079     l_hr_soft_rec.segment18                 := p_soft_segment18;
6080     l_hr_soft_rec.segment19                 := p_soft_segment19;
6081     l_hr_soft_rec.segment20                 := p_soft_segment20;
6082     l_hr_soft_rec.segment21                 := p_soft_segment21;
6083     l_hr_soft_rec.segment22                 := p_soft_segment22;
6084     l_hr_soft_rec.segment23                 := p_soft_segment23;
6085     l_hr_soft_rec.segment24                 := p_soft_segment24;
6086     l_hr_soft_rec.segment25                 := p_soft_segment25;
6087     l_hr_soft_rec.segment26                 := p_soft_segment26;
6088     l_hr_soft_rec.segment27                 := p_soft_segment27;
6089     l_hr_soft_rec.segment28                 := p_soft_segment28;
6090     l_hr_soft_rec.segment29                 := p_soft_segment29;
6091     l_hr_soft_rec.segment30                 := p_soft_segment30;
6092 
6093     hr_utility.set_location('Soft Coding KFF segments assigned to record: ' ||
6094                                          'l_hr_soft_rec ', 150);
6095     -- ========================================================================
6096     -- ~ People Group Keyflex
6097     -- ========================================================================
6098     l_ppl_grp_rec.group_name               := p_concat_segments;
6099 
6100     /*********  commented for bug fix 4160812 *********************
6101     l_ppl_grp_rec.segment1                 := p_people_segment1;
6102     l_ppl_grp_rec.segment2                 := p_people_segment2;
6103     l_ppl_grp_rec.segment3                 := p_people_segment3;
6104     l_ppl_grp_rec.segment4                 := p_people_segment4;
6105     l_ppl_grp_rec.segment5                 := p_people_segment5;
6106     l_ppl_grp_rec.segment6                 := p_people_segment6;
6107     l_ppl_grp_rec.segment7                 := p_people_segment7;
6108     l_ppl_grp_rec.segment8                 := p_people_segment8;
6109     l_ppl_grp_rec.segment9                 := p_people_segment9;
6110     l_ppl_grp_rec.segment10                := p_people_segment10;
6111     l_ppl_grp_rec.segment11                := p_people_segment11;
6112     l_ppl_grp_rec.segment12                := p_people_segment12;
6113     l_ppl_grp_rec.segment13                := p_people_segment13;
6114     l_ppl_grp_rec.segment14                := p_people_segment14;
6115     l_ppl_grp_rec.segment15                := p_people_segment15;
6116     l_ppl_grp_rec.segment16                := p_people_segment16;
6117     l_ppl_grp_rec.segment17                := p_people_segment17;
6118     l_ppl_grp_rec.segment18                := p_people_segment18;
6119     l_ppl_grp_rec.segment19                := p_people_segment19;
6120     l_ppl_grp_rec.segment20                := p_people_segment20;
6121     l_ppl_grp_rec.segment21                := p_people_segment21;
6122     l_ppl_grp_rec.segment22                := p_people_segment22;
6123     l_ppl_grp_rec.segment23                := p_people_segment23;
6124     l_ppl_grp_rec.segment24                := p_people_segment24;
6125     l_ppl_grp_rec.segment25                := p_people_segment25;
6126     l_ppl_grp_rec.segment26                := p_people_segment26;
6127     l_ppl_grp_rec.segment27                := p_people_segment27;
6128     l_ppl_grp_rec.segment28                := p_people_segment28;
6129     l_ppl_grp_rec.segment29                := p_people_segment29;
6130     l_ppl_grp_rec.segment30                := p_people_segment30;
6131 
6132     *********  commented for bug fix 4160812 *********************/
6133 
6134     l_ppl_grp_rec.segment1  := f_formatted_grp_seg_val('p_people_segment1',p_people_segment1);
6135     l_ppl_grp_rec.segment2  := f_formatted_grp_seg_val('p_people_segment2', p_people_segment2);
6136     l_ppl_grp_rec.segment3  := f_formatted_grp_seg_val('p_people_segment3', p_people_segment3);
6137     l_ppl_grp_rec.segment4  := f_formatted_grp_seg_val('p_people_segment4', p_people_segment4);
6138     l_ppl_grp_rec.segment5  := f_formatted_grp_seg_val('p_people_segment5', p_people_segment5);
6139     l_ppl_grp_rec.segment6  := f_formatted_grp_seg_val('p_people_segment6', p_people_segment6);
6140     l_ppl_grp_rec.segment7  := f_formatted_grp_seg_val('p_people_segment7', p_people_segment7);
6141     l_ppl_grp_rec.segment8  := f_formatted_grp_seg_val('p_people_segment8', p_people_segment8);
6142     l_ppl_grp_rec.segment9  := f_formatted_grp_seg_val('p_people_segment9', p_people_segment9);
6143     l_ppl_grp_rec.segment10 := f_formatted_grp_seg_val('p_people_segment10',p_people_segment10);
6144     l_ppl_grp_rec.segment11 := f_formatted_grp_seg_val('p_people_segment11',p_people_segment11);
6145     l_ppl_grp_rec.segment12 := f_formatted_grp_seg_val('p_people_segment12',p_people_segment12);
6146     l_ppl_grp_rec.segment13 := f_formatted_grp_seg_val('p_people_segment13',p_people_segment13);
6147     l_ppl_grp_rec.segment14 := f_formatted_grp_seg_val('p_people_segment14',p_people_segment14);
6148     l_ppl_grp_rec.segment15 := f_formatted_grp_seg_val('p_people_segment15',p_people_segment15);
6149     l_ppl_grp_rec.segment16 := f_formatted_grp_seg_val('p_people_segment16',p_people_segment16);
6150     l_ppl_grp_rec.segment17 := f_formatted_grp_seg_val('p_people_segment17',p_people_segment17);
6151     l_ppl_grp_rec.segment18 := f_formatted_grp_seg_val('p_people_segment18',p_people_segment18);
6152     l_ppl_grp_rec.segment19 := f_formatted_grp_seg_val('p_people_segment19',p_people_segment19);
6153     l_ppl_grp_rec.segment20 := f_formatted_grp_seg_val('p_people_segment20',p_people_segment20);
6154     l_ppl_grp_rec.segment21 := f_formatted_grp_seg_val('p_people_segment21',p_people_segment21);
6155     l_ppl_grp_rec.segment22 := f_formatted_grp_seg_val('p_people_segment22',p_people_segment22);
6156     l_ppl_grp_rec.segment23 := f_formatted_grp_seg_val('p_people_segment23',p_people_segment23);
6157     l_ppl_grp_rec.segment24 := f_formatted_grp_seg_val('p_people_segment24',p_people_segment24);
6158     l_ppl_grp_rec.segment25 := f_formatted_grp_seg_val('p_people_segment25',p_people_segment25);
6159     l_ppl_grp_rec.segment26 := f_formatted_grp_seg_val('p_people_segment26',p_people_segment26);
6160     l_ppl_grp_rec.segment27 := f_formatted_grp_seg_val('p_people_segment27',p_people_segment27);
6161     l_ppl_grp_rec.segment28 := f_formatted_grp_seg_val('p_people_segment28',p_people_segment28);
6162     l_ppl_grp_rec.segment29 := f_formatted_grp_seg_val('p_people_segment29',p_people_segment29);
6163     l_ppl_grp_rec.segment30 := f_formatted_grp_seg_val('p_people_segment30',p_people_segment30);
6164 
6165     hr_utility.set_location('People Grp KFF segments assigned to record: ' ||
6166                                     'l_ppl_grp_rec ', 160);
6167 
6168   -- Code handles all the cases if the data coming in is not corrected
6169   -- erronous data pump data, hence not 'DP ERROR'
6170 
6171     IF p_web_adi_identifier <> 'DP ERROR' THEN --{{
6172         hr_utility.set_location('IF <> DP Error ', 170);
6173         IF (chk_party%ISOPEN) THEN -- {
6174             CLOSE chk_party;
6175         END IF; -- }
6176         OPEN  chk_party( c_party_id       => l_per_rec.party_id
6177                        , c_bg_grp_id      => l_per_rec.business_group_id
6178                        , c_person_id      => p_dup_person_id
6179                        , c_effective_date => l_effective_date);
6180 
6181         FETCH chk_party INTO l_chk_per;
6182 
6183         IF (chk_party%NOTFOUND) THEN -- {{
6184             -- If person doesn't exist in system then create a new person
6185             hr_utility.set_location(' Creating a new Student Employee', 180);
6186             IF (p_data_pump_flag = 'Y') THEN -- {
6187                 hr_utility.set_location('If data pump flag = Y', 190);
6188                 -- If person is to be created through Data Pump
6189                 hr_datapump(p_data_pump_batch_line_id =>
6190                                             p_data_pump_batch_line_id
6191                            , p_batch_id               => p_batch_id
6192                            , p_contact_name           => p_contact_name
6193                            , p_adjusted_svc_date      => p_adjusted_svc_date
6194                            , p_dp_mode                => 'INSERT');
6195             ELSE -- }{
6196                 hr_utility.set_location('If data pump flag <> Y', 200);
6197                 -- Else person is to be created through real-time APIs
6198                 -- Create the employee
6199                 create_empin_hrms(p_validate          => FALSE
6200                                  ,p_effective_date    => l_per_rec.start_date
6201                                  ,p_adjusted_svc_date => p_adjusted_svc_date
6202                                  ,p_per_comments      => p_per_comments
6203                                  ,p_emp_api_out       => l_emp_api_out);
6204 
6205                 -- Create the primary address
6206 
6207                 l_add_rec.person_id    := l_emp_api_out.person_id;
6208                 l_add_rec.primary_flag := 'Y';
6209 
6210                 -- Call Address API only if user has eneterd address details
6211 
6212                 IF (p_address_line1 IS NOT NULL AND
6213                     l_add_rec.style IS NOT NULL    ) THEN -- {
6214                     hr_utility.set_location('Address line 1 is filled', 210);
6215 
6216                     l_add_rec.date_from := l_per_rec.start_date;
6217                     l_add_rec.date_to   := Null;
6218                     insupd_address(p_effective_date     => l_per_rec.start_date
6219                                   , p_hr_address_id     => l_add_rec.address_id
6220                                   , p_hr_object_version_number =>
6221                                             l_add_rec.object_version_number);
6222                 END IF; -- }
6223 
6224                 -- Update employee primary assignment
6225 
6226                 l_asg_rec.assignment_id         := l_emp_api_out.assignment_id;
6227                 l_asg_rec.object_version_number :=
6228                                    l_emp_api_out.asg_object_version_number;
6229 
6230                 hr_utility.set_location('Updating asg criteria ', 220);
6231                 update_stuempasg_criteria(p_effective_date =>
6232                                                        l_per_rec.start_date ,
6233                                           p_asg_crit_out   => l_asg_crit_out);
6234 
6235                 hr_utility.set_location('Updated asg criteria', 230);
6236 
6237                 -- Create Phones record default to H1=Home
6238 
6239                 l_phones_rec.parent_id  := l_emp_api_out.person_id;
6240                 l_phones_rec.date_from  := l_per_rec.start_date;
6241                 -- Create Contact Details
6242                 l_cntct_rec.person_id   := l_emp_api_out.person_id;
6243                 -- Create Contact Type only when Contact Details have been
6244                 -- entered
6245                 IF l_cntct_rec.contact_type IS NOT NULL THEN -- {
6246                     hr_utility.set_location('Contact type is not null', 240);
6247                     create_person_contact(p_effective_date=>l_per_rec.start_date
6248                                          , p_contact_name    => p_contact_name
6249                                          , p_legislation_code => g_leg_code
6250                                          , p_crt_cntct_out=>l_crt_emp_api_out);
6251                 END IF; -- }
6252                 IF g_leg_code = 'US' THEN
6253                   -- Get Passport details from OSS
6254                   Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
6255                   (p_business_group_id => l_per_rec.business_group_id
6256                   ,p_person_id         => l_per_rec.person_id
6257                   ,p_party_id          => l_per_rec.party_id
6258                   ,p_effective_date    => l_per_rec.start_date
6259                   ,p_pp_error_code     => l_pp_error_code
6260                   ,p_passport_warning  => l_passport_warning
6261                    );
6262                   -- Get Visa Details from OSS
6263                   Pqp_Hrtca_Integration.InsUpd_InHR_Visa
6264                   (p_business_group_id => l_per_rec.business_group_id
6265                   ,p_person_id         => l_per_rec.person_id
6266                   ,p_party_id          => l_per_rec.party_id
6267                   ,p_effective_date    => l_per_rec.start_date
6268                   ,p_visa_error_code   => l_visa_error_code
6269                   ,p_visa_warning      => l_visa_warning
6270                    );
6271                   -- Get Visit History details from OSS
6272                   Pqp_Hrtca_Integration.InsUpd_InHR_Visit
6273                   (p_business_group_id => l_per_rec.business_group_id
6274                   ,p_person_id         => l_per_rec.person_id
6275                   ,p_party_id          => l_per_rec.party_id
6276                   ,p_effective_date    => l_per_rec.start_date
6277                   ,p_visit_error_code  => l_visit_error_code
6278                   ,p_visit_warning     => l_visit_warning
6279                   );
6280                 END IF;
6281                -- Create People Exra Information
6282                 IF l_student_number IS NOT NULL THEN -- {
6283                     hr_utility.set_location('Updating Extra Info', 250);
6284                     hr_utility.set_location('Error Code ' ||
6285                                      l_oss_error_code, 255);
6286                     Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
6287                      (p_business_group_id => l_per_rec.business_group_id
6288                      ,p_person_id         => l_per_rec.person_id
6289                      ,p_party_id          => l_per_rec.party_id
6290                      ,p_effective_date    => l_per_rec.start_date
6291                      ,p_oss_error_code    => l_oss_error_code
6292                      ,p_ossDtls_warning   => l_ossDtls_warning);
6293                 END IF; -- }
6294             END IF; -- }
6295 
6296         ELSIF (l_chk_per.system_person_type) IN ('OTHER'  ,
6297                                                  'EX_EMP' ,
6298                                                  'EX_APL' ) THEN
6299             -- If the person already exists in the system
6300             hr_utility.set_location(' Current person type: ' ||
6301                                     l_chk_per.system_person_type, 260);
6302 
6303 	    --Raise error if contingent worker is being tried to be hired as a student employee
6304             IF l_chk_per.system_person_type ='OTHER' THEN
6305                FOR ptu_rec IN  csr_per_ptu
6306                               (c_person_id         => l_chk_per.person_id
6307                               ,c_business_group_id => p_business_group_id
6308                               ,c_effective_date    => l_effective_date)
6309                LOOP
6310                   IF ptu_rec.system_person_type = 'CWK' THEN
6311                      l_active_cwk := TRUE;
6312                      EXIT;
6313                   END IF;
6314                END LOOP;
6315             END IF;
6316 
6317             IF l_active_cwk THEN
6318                RAISE e_active_cwk;
6319             END IF;
6320 
6321             -- Hire the existing person
6322             l_per_rec.party_id  := l_party_id;
6323             l_per_rec.person_id := p_dup_person_id;
6324             -- If person is to be re-hired through Data Pump
6325             IF (p_data_pump_flag = 'Y') THEN -- {{
6326                 hr_utility.set_location(' Data pump flag = Y' , 270);
6327                 l_add_rec.primary_flag := 'Y';
6328                 hr_datapump(p_data_pump_batch_line_id =>
6329                                                 p_data_pump_batch_line_id
6330                            ,p_batch_id                => p_batch_id
6331                            ,p_contact_name            => p_contact_name
6332                            ,p_adjusted_svc_date       => p_adjusted_svc_date
6333                            ,p_dp_mode                 => 'UPDATE');
6334             ELSE -- }{
6335                 -- Else person is to be re-hired through real-time APIs
6336                 hr_utility.set_location(' Data pump flag <> Y' , 280);
6337 
6338                 hire_person_intoemp(p_validate          => FALSE
6339                                    ,p_hire_date         => l_per_rec.start_date
6340                                    ,p_person_id         => p_dup_person_id
6341                                    ,p_adjusted_svc_date => p_adjusted_svc_date
6342                                    ,p_updper_api_out    => l_updper_api_out
6343                                    ,p_HireToJobapi_out  => l_HireToJobapi_out);
6344                 -- Create the primary address
6345                 l_add_rec.person_id    := p_dup_person_id;
6346                 l_add_rec.primary_flag := 'Y';
6347 
6348                 IF (p_address_line1 IS NOT NULL AND
6349                     l_add_rec.style IS NOT NULL) THEN -- {
6350                   -- Call Address API only if user has eneterd address details
6351                     hr_utility.set_location('Address line 1 is not null' , 290);
6352                     l_add_rec.date_from := l_per_rec.start_date;
6353                     l_add_rec.date_to   := NULL;
6354 
6355                     InsUpd_Address(p_effective_date => l_per_rec.start_date
6356                                   ,p_HR_address_id  => l_add_rec.address_id
6357                                   ,p_HR_object_version_number =>
6358                                              l_add_rec.object_version_number);
6359                 END IF; -- }
6360                 -- Update employee's primary assignment
6361                 l_asg_rec.assignment_id  := l_HireToJobapi_out.assignment_id;
6362                 hr_utility.set_location('Updating Asg criteria' , 300);
6363                 Update_StuEmpAsg_Criteria(p_effective_date =>
6364                                                 l_per_rec.start_date
6365                                          ,p_asg_crit_out   => l_asg_crit_out);
6366                 hr_utility.set_location('Updated Asg criteria' , 310);
6367                 -- Create Contact Details
6368                 l_cntct_rec.person_id   := l_emp_api_out.person_id;
6369                 -- Create Contact Type only when Contact Dets have been entered
6370                 IF l_cntct_rec.contact_type IS NOT NULL THEN -- {
6371                     hr_utility.set_location('Updating Contact Details' , 320);
6372                     Update_Person_Contact(p_effective_date=>l_per_rec.start_date
6373                                          ,p_contact_name     => p_contact_name
6374                                          ,p_legislation_code => g_leg_code
6375                                          ,p_crt_cntct_out => l_crt_emp_api_out);
6376                 END IF; -- }
6377                 IF g_leg_code = 'US' THEN
6378                   -- Get Passport details from OSS
6379                   Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
6380                   (p_business_group_id => l_per_rec.business_group_id
6381                   ,p_person_id         => l_per_rec.person_id
6382                   ,p_party_id          => l_per_rec.party_id
6383                   ,p_effective_date    => l_per_rec.start_date
6384                   ,p_pp_error_code     => l_pp_error_code
6385                   ,p_passport_warning  => l_passport_warning
6386                    );
6387                   -- Get Visa Details from OSS
6388                   Pqp_Hrtca_Integration.InsUpd_InHR_Visa
6389                   (p_business_group_id => l_per_rec.business_group_id
6390                   ,p_person_id         => l_per_rec.person_id
6391                   ,p_party_id          => l_per_rec.party_id
6392                   ,p_effective_date    => l_per_rec.start_date
6393                   ,p_visa_error_code   => l_visa_error_code
6394                   ,p_visa_warning      => l_visa_warning
6395                    );
6396                   -- Get Visit History details from OSS
6397                   Pqp_Hrtca_Integration.InsUpd_InHR_Visit
6398                   (p_business_group_id => l_per_rec.business_group_id
6399                   ,p_person_id         => l_per_rec.person_id
6400                   ,p_party_id          => l_per_rec.party_id
6401                   ,p_effective_date    => l_per_rec.start_date
6402                   ,p_visit_error_code  => l_visit_error_code
6403                   ,p_visit_warning     => l_visit_warning
6404                   );
6405                 END IF;
6406                 IF l_student_number IS NOT NULL THEN -- {
6407                     -- Create People Exra Information
6408                     hr_utility.set_location('Updating Extra Info' , 330);
6409                     Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
6410                        (p_business_group_id => l_per_rec.business_group_id
6411                        ,p_person_id         => l_per_rec.person_id
6412                        ,p_party_id          => l_per_rec.party_id
6413                        ,p_effective_date    => l_per_rec.start_date
6414                        ,p_oss_error_code    => l_oss_error_code
6415                        ,p_ossDtls_warning   => l_ossDtls_warning);
6416                 END IF; --}
6417             END IF; -- }
6418         ELSIF l_chk_per.system_person_type IN
6419 	      ('EX_EMP_APL','APL_EX_APL','APL') THEN -- {
6420                hr_utility.set_location('..Applicant being hired as Student' ||
6421                                        ' Employee', 340);
6422                hr_utility.set_location(' Current person type: ' ||
6423                                        l_chk_per.system_person_type, 340);
6424             l_per_rec.party_id  := l_party_id;
6425             l_per_rec.person_id := p_dup_person_id;
6426             -- If person is to be re-hired through Data Pump
6427             IF (p_data_pump_flag = 'Y') THEN -- {{
6428                 hr_utility.set_location(' Data pump flag = Y' , 350);
6429                 l_add_rec.primary_flag := 'Y';
6430                 hr_datapump(p_data_pump_batch_line_id =>
6431                                                 p_data_pump_batch_line_id
6432                            ,p_batch_id                => p_batch_id
6433                            ,p_contact_name            => p_contact_name
6434                            ,p_adjusted_svc_date       => p_adjusted_svc_date
6435                            ,p_dp_mode                 => 'UPDATE');
6436             ELSE
6437                 -- Else person is to be re-hired through real-time APIs
6438                 hr_utility.set_location(' Data pump flag <> Y' , 280);
6439                 l_per_rec.person_id         := l_chk_per.person_id;
6440                 l_per_rec.business_group_id := p_business_group_id;
6441                 l_per_rec.party_id          := l_party_id;
6442                 l_effective_date            := p_date_of_hire;
6443                 l_per_rec.start_date        := l_effective_date;
6444 
6445                 --Get the value of duplicate assignment id
6446 		IF (get_dup_asg_id%ISOPEN) THEN
6447 		   CLOSE get_dup_asg_id;
6448 		END IF;
6449 		OPEN get_dup_asg_id(c_dup_per_id         => l_chk_per.person_id
6450 		                   ,c_business_group_id  => p_business_group_id
6451 				   ,c_eff_date           => p_date_of_hire);
6452                 FETCH get_dup_asg_id
6453 		   INTO l_dup_asg_id;
6454 		CLOSE get_dup_asg_id;
6455 
6456                 IF NVL(l_dup_asg_id,0) <> 0 then
6457                    Hire_Applicant_IntoEmp
6458                    (p_validate           => FALSE
6459                    ,p_hire_date          => l_effective_date
6460                    ,p_person_id          => l_chk_per.person_id
6461                    ,p_assignment_id      => l_dup_asg_id
6462                    ,p_adjusted_svc_date  => p_adjusted_svc_date
6463                    ,p_updper_api_out     => l_updper_api_out
6464                    ,p_HireAppapi_out     => l_HireAppapi_out);
6465                    l_asg_rec.assignment_id  := l_dup_asg_id;
6466                 ELSE
6467                    Create_EmpIn_HRMS
6468                    (p_validate            => FALSE
6469                    ,p_effective_date      => l_per_rec.START_DATE
6470                    ,p_adjusted_svc_date   => p_adjusted_svc_date
6471                    ,p_per_comments        => NULL
6472                    ,p_emp_api_out         => l_emp_api_out
6473                    );
6474                    l_add_rec.person_id    := l_emp_api_out.person_id;
6475                    l_per_rec.person_id    := l_emp_api_out.person_id;
6476                    l_cntct_rec.person_id  := l_emp_api_out.person_id;
6477                    l_phones_rec.parent_id  := l_emp_api_out.person_id;
6478 		   l_asg_rec.assignment_id  := l_emp_api_out.assignment_id;
6479                 END IF;
6480 
6481                 -- Create Contact Type only when Contact Details have been entered
6482                 l_cntct_rec.person_id   := l_emp_api_out.person_id;
6483                 -- Create Contact Type only when Contact Dets have been entered
6484                 IF l_cntct_rec.contact_type IS NOT NULL THEN
6485                     hr_utility.set_location('Updating Contact Details' , 320);
6486                     Update_Person_Contact(p_effective_date=>l_per_rec.start_date
6487                                          ,p_contact_name     => p_contact_name
6488                                          ,p_legislation_code => g_leg_code
6489                                          ,p_crt_cntct_out => l_crt_emp_api_out);
6490                     hr_utility.set_location('Updated Contact Details' , 320);
6491                 END IF;
6492 
6493                 -- Create the primary address
6494                 l_add_rec.person_id    := p_dup_person_id;
6495                 l_add_rec.primary_flag := 'Y';
6496                 -- Call Address API only if user has eneterd address details
6497                 IF (p_address_line1 IS NOT NULL AND
6498                     l_add_rec.style IS NOT NULL) THEN
6499                     hr_utility.set_location('Address line 1 is not null' , 290);
6500                     l_add_rec.date_from := l_per_rec.start_date;
6501                     l_add_rec.date_to   := NULL;
6502 
6503                     hr_utility.set_location(' Updating Person Primary Address ', 150);
6504                     InsUpd_Address(p_effective_date => l_per_rec.start_date
6505                                   ,p_HR_address_id  => l_add_rec.address_id
6506                                   ,p_HR_object_version_number =>
6507                                              l_add_rec.object_version_number);
6508                     hr_utility.set_location(' Updated Person Primary Address ', 150);
6509                 END IF;
6510 
6511                 -- Update employee's primary assignment
6512                 hr_utility.set_location('Updating Asg criteria' , 300);
6513                 Update_StuEmpAsg_Criteria(p_effective_date =>
6514                                                 l_per_rec.start_date
6515                                          ,p_asg_crit_out   => l_asg_crit_out);
6516                 hr_utility.set_location('Updated Asg criteria' , 310);
6517 
6518                 IF g_leg_code = 'US' THEN
6519                   -- Get Passport details from OSS
6520                   Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
6521                   (p_business_group_id => l_per_rec.business_group_id
6522                   ,p_person_id         => l_per_rec.person_id
6523                   ,p_party_id          => l_per_rec.party_id
6524                   ,p_effective_date    => l_per_rec.start_date
6525                   ,p_pp_error_code     => l_pp_error_code
6526                   ,p_passport_warning  => l_passport_warning
6527                    );
6528                   -- Get Visa Details from OSS
6529                   Pqp_Hrtca_Integration.InsUpd_InHR_Visa
6530                   (p_business_group_id => l_per_rec.business_group_id
6531                   ,p_person_id         => l_per_rec.person_id
6532                   ,p_party_id          => l_per_rec.party_id
6533                   ,p_effective_date    => l_per_rec.start_date
6534                   ,p_visa_error_code   => l_visa_error_code
6535                   ,p_visa_warning      => l_visa_warning
6536                    );
6537                   -- Get Visit History details from OSS
6538                   Pqp_Hrtca_Integration.InsUpd_InHR_Visit
6539                   (p_business_group_id => l_per_rec.business_group_id
6540                   ,p_person_id         => l_per_rec.person_id
6541                   ,p_party_id          => l_per_rec.party_id
6542                   ,p_effective_date    => l_per_rec.start_date
6543                   ,p_visit_error_code  => l_visit_error_code
6544                   ,p_visit_warning     => l_visit_warning
6545                   );
6546                 END IF;
6547                 IF l_student_number IS NOT NULL THEN
6548                     -- Create People Exra Information
6549                     hr_utility.set_location('Updating Extra Info' , 330);
6550                     Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
6551                        (p_business_group_id => l_per_rec.business_group_id
6552                        ,p_person_id         => l_per_rec.person_id
6553                        ,p_party_id          => l_per_rec.party_id
6554                        ,p_effective_date    => l_per_rec.start_date
6555                        ,p_oss_error_code    => l_oss_error_code
6556                        ,p_ossDtls_warning   => l_ossDtls_warning);
6557                     hr_utility.set_location('Updated Extra Info' , 330);
6558                 END IF;
6559                     hr_utility.set_location(' Updated Passport, Visa, Visit History' ||
6560                                             ' details: ', 160);
6561 	    END IF;
6562 
6563 	ELSIF l_chk_per.system_person_type IN ('EMP','EMP_APL') THEN
6564 
6565               -- If the person already exists in the system {
6566               hr_utility.set_location(' Current person type: ' ||
6567                                     l_chk_per.system_person_type, 260);
6568               -- Hire the existing person
6569               l_per_rec.party_id  := l_party_id;
6570               l_per_rec.person_id := p_dup_person_id;
6571               -- If person is to be re-hired through Data Pump
6572               IF (p_data_pump_flag = 'Y') THEN -- {{
6573                   hr_utility.set_location(' Data pump flag = Y' , 270);
6574                   l_add_rec.primary_flag := 'Y';
6575                   hr_datapump(p_data_pump_batch_line_id =>
6576                                                 p_data_pump_batch_line_id
6577                              ,p_batch_id                => p_batch_id
6578                              ,p_contact_name            => p_contact_name
6579                              ,p_adjusted_svc_date       => p_adjusted_svc_date
6580                              ,p_dp_mode                 => 'UPDATE');
6581               ELSE -- }{
6582                    -- Else person is to be re-hired through real-time APIs
6583                    hr_utility.set_location(' Data pump flag <> Y' , 280);
6584 
6585                    hr_utility.set_location(' Updating person details ', 180);
6586                    Upd_OSS_Person
6587                    (p_validate            => FALSE
6588                    ,p_effective_date      => l_per_rec.start_date
6589                    ,p_person_id           => l_per_rec.person_id
6590                    ,p_adjusted_svc_date   => p_adjusted_svc_date
6591                    ,p_updper_api_out      => l_updper_api_out
6592                    );
6593                    hr_utility.set_location(' Updated person details ', 180);
6594 
6595                    -- Call the Address API only if user has eneterd the address details
6596                   IF (p_address_line1 IS NOT NULL AND
6597                       l_add_rec.style IS NOT NULL) THEN
6598 		      hr_utility.set_location('Address line 1 is not null' , 290);
6599                       l_add_rec.person_id    := p_dup_person_id;
6600                       l_add_rec.primary_flag := 'Y';
6601                       l_add_rec.date_from := l_per_rec.start_date;
6602                       l_add_rec.date_to   := NULL;
6603 
6604                       InsUpd_Address(p_effective_date => l_per_rec.start_date
6605                                     ,p_HR_address_id  => l_add_rec.address_id
6606                                     ,p_HR_object_version_number =>
6607                                                l_add_rec.object_version_number);
6608                   END IF;
6609 
6610                   --Get the value of duplicate assignment id
6611 		  IF (get_dup_asg_id%ISOPEN) THEN
6612 		     CLOSE get_dup_asg_id;
6613 		  END IF;
6614 		  OPEN get_dup_asg_id(c_dup_per_id         => l_chk_per.person_id
6615 		                     ,c_business_group_id  => p_business_group_id
6616 		                     ,c_eff_date           => p_date_of_hire);
6617                   FETCH get_dup_asg_id
6618 		     INTO l_dup_asg_id;
6619 		  CLOSE get_dup_asg_id;
6620 
6621                   -- Update employee's primary assignment
6622                   l_asg_rec.assignment_id  := l_dup_asg_id;
6623                   hr_utility.set_location('Updating Asg criteria' , 300);
6624                   Update_StuEmpAsg_Criteria(p_effective_date =>
6625                                                 l_per_rec.start_date
6626                                          ,p_asg_crit_out   => l_asg_crit_out);
6627                   hr_utility.set_location('Updated Asg criteria' , 310);
6628 
6629                   IF g_leg_code = 'US' THEN
6630                      -- Get Passport details from OSS
6631                      Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
6632                      (p_business_group_id => l_per_rec.business_group_id
6633                      ,p_person_id         => l_per_rec.person_id
6634                      ,p_party_id          => l_per_rec.party_id
6635                      ,p_effective_date    => l_per_rec.start_date
6636                      ,p_pp_error_code     => l_pp_error_code
6637                      ,p_passport_warning  => l_passport_warning
6638                      );
6639                      -- Get Visa Details from OSS
6640                      Pqp_Hrtca_Integration.InsUpd_InHR_Visa
6641                      (p_business_group_id => l_per_rec.business_group_id
6642                      ,p_person_id         => l_per_rec.person_id
6643                      ,p_party_id          => l_per_rec.party_id
6644                      ,p_effective_date    => l_per_rec.start_date
6645                      ,p_visa_error_code   => l_visa_error_code
6646                      ,p_visa_warning      => l_visa_warning
6647                       );
6648                      -- Get Visit History details from OSS
6649                      Pqp_Hrtca_Integration.InsUpd_InHR_Visit
6650                      (p_business_group_id => l_per_rec.business_group_id
6651                      ,p_person_id         => l_per_rec.person_id
6652                      ,p_party_id          => l_per_rec.party_id
6653                      ,p_effective_date    => l_per_rec.start_date
6654                      ,p_visit_error_code  => l_visit_error_code
6655                      ,p_visit_warning     => l_visit_warning
6656                      );
6657                   END IF;
6658                   IF l_student_number IS NOT NULL THEN -- {
6659                      -- Create People Exra Information
6660                      hr_utility.set_location('Updating Extra Info' , 330);
6661                      Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
6662                         (p_business_group_id => l_per_rec.business_group_id
6663                         ,p_person_id         => l_per_rec.person_id
6664                         ,p_party_id          => l_per_rec.party_id
6665                         ,p_effective_date    => l_per_rec.start_date
6666                         ,p_oss_error_code    => l_oss_error_code
6667                         ,p_ossDtls_warning   => l_ossDtls_warning);
6668                   END IF;
6669 
6670               END IF;
6671 
6672         END IF;
6673 
6674         IF (chk_party%ISOPEN) THEN -- {
6675             CLOSE chk_party;
6676         END IF; -- }
6677 
6678     ELSIF p_web_adi_identifier = 'DP ERROR' THEN -- }{
6679         -- Procedure call which handles if user is trying to correct the
6680         -- erronous data from Data Pump Interface Tables
6681         hr_datapumperr( p_data_pump_batch_line_id => p_data_pump_batch_line_id
6682                       , p_batch_id                => p_batch_id
6683                       , p_contact_name            => p_contact_name
6684                       , p_adjusted_svc_date       => p_adjusted_svc_date);
6685 
6686     END IF; -- }}
6687     hr_utility.set_location('Leaving: ' || l_proc_name, 350);
6688 
6689    EXCEPTION
6690      WHEN e_active_cwk THEN
6691        CLOSE chk_party;
6692        ROLLBACK TO create_student_employee;
6693        hr_utility.set_location('..CWK being hired as Student Employee', 360);
6694        hr_utility.set_message(8303, 'PQP_230216_HROSS_ACTIVE_CTW');
6695        hr_utility.set_location('Leaving: ' || l_proc_name, 360);
6696        hr_utility.raise_error;
6697 
6698      WHEN Others THEN
6699        CLOSE chk_party;
6700        ROLLBACK TO create_student_employee;
6701        hr_utility.raise_error;
6702 
6703 END Create_Student_Employee;
6704 
6705 -- =============================================================================
6706 -- ~ Create_Batch_Header_For_Data_Pump:
6707 -- =============================================================================
6708 PROCEDURE Create_BatchHdr_For_DataPump
6709          (p_batch_process_name   OUT NOCOPY Varchar2
6710          ,p_batch_process_id     OUT NOCOPY Number) AS
6711 
6712   -- Cursor to get the business group name
6713    CURSOR csr_get_bg_name (c_bg_grp_id IN Number) IS
6714    SELECT pbg.NAME
6715      FROM per_business_groups pbg
6716     WHERE pbg.business_group_id = c_bg_grp_id;
6717 
6718    l_bg_name                per_business_groups.NAME%TYPE;
6719    l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||
6720                                            'Create_BatchHdr_For_DataPump';
6721 
6722 BEGIN
6723    hr_utility.set_location('Entering: ' || l_proc_name, 10);
6724 
6725    SELECT hr_pump_batch_headers_s.nextval
6726      INTO p_batch_process_id
6727      FROM dual;
6728    p_batch_process_name := 'HROSS Batch Process ' || p_batch_process_id;
6729 
6730    OPEN  csr_get_bg_name(Fnd_Profile.VALUE('PER_BUSINESS_GROUP_ID'));
6731    FETCH csr_get_bg_name INTO l_bg_name;
6732    CLOSE csr_get_bg_name;
6733 
6734    INSERT INTO hr_pump_batch_headers
6735    (batch_id
6736    ,batch_name
6737    ,batch_status
6738    ,business_group_name)
6739    VALUES
6740    (p_batch_process_id
6741    ,p_batch_process_name
6742    ,'U'
6743    ,l_bg_name);
6744 
6745    hr_utility.set_location('Leaving: ' || l_proc_name, 20);
6746 
6747 END Create_BatchHdr_For_DataPump;
6748 
6749 -- =============================================================================
6750 -- ~ Create_OSS_Person:
6751 -- =============================================================================
6752 PROCEDURE Create_OSS_Person
6753          (p_business_group_id            IN Number
6754          ,p_dup_person_id                IN Number
6755          ,p_effective_date               IN Date
6756          -- Person Details: Per_All_People_F
6757          ,p_party_id                     IN Number
6758          ,p_last_name                    IN Varchar2
6759          ,p_middle_name                  IN Varchar2
6760          ,p_first_name                   IN Varchar2
6761          ,p_suffix                       IN Varchar2
6762          ,p_prefix                       IN Varchar2
6763          ,p_title                        IN Varchar2
6764          ,p_email_address                IN Varchar2
6765          ,p_preferred_name               IN Varchar2
6766          ,p_marital_status               IN Varchar2
6767          ,p_sex                          IN Varchar2
6768          ,p_nationality                  IN Varchar2
6769          ,p_national_identifier          IN Varchar2
6770          ,p_date_of_birth                IN Date
6771          ,p_date_of_hire                 IN Date
6772          ,p_employee_number              IN Varchar2
6773          ,p_person_type_id               IN Number
6774          ,p_date_employee_data_verified  IN Date
6775          ,p_expense_check_send_to_addres IN Varchar2
6776          ,p_previous_last_name           IN Varchar2
6777          ,p_registered_disabled_flag     IN Varchar2
6778          ,p_vendor_id                    IN Number
6779          ,p_date_of_death                IN Date
6780          ,p_background_check_status      IN Varchar2
6781          ,p_background_date_check        IN Date
6782          ,p_blood_type                   IN Varchar2
6783          ,p_correspondence_language      IN Varchar2
6784          ,p_fast_path_employee           IN Varchar2
6785          ,p_fte_capacity                 IN Number
6786          ,p_honors                       IN Varchar2
6787          ,p_last_medical_test_by         IN Varchar2
6788          ,p_last_medical_test_date       IN Date
6789          ,p_mailstop                     IN Varchar2
6790          ,p_office_number                IN Varchar2
6791          ,p_on_military_service          IN Varchar2
6792          ,p_pre_name_adjunct             IN Varchar2
6793          ,p_projected_start_date         IN Date
6794          ,p_resume_exists                IN Varchar2
6795          ,p_resume_last_updated          IN Date
6796          ,p_second_passport_exists       IN Varchar2
6797          ,p_student_status               IN Varchar2
6798          ,p_work_schedule                IN Varchar2
6799          ,p_benefit_group_id             IN Number
6800          ,p_receipt_of_death_cert_date   IN Date
6801          ,p_coord_ben_med_pln_no         IN Varchar2
6802          ,p_coord_ben_no_cvg_flag        IN Varchar2
6803          ,p_coord_ben_med_ext_er         IN Varchar2
6804          ,p_coord_ben_med_pl_name        IN Varchar2
6805          ,p_coord_ben_med_insr_crr_name  IN Varchar2
6806          ,p_coord_ben_med_insr_crr_ident IN Varchar2
6807          ,p_coord_ben_med_cvg_strt_dt    IN Date
6808          ,p_coord_ben_med_cvg_end_dt     IN Date
6809          ,p_uses_tobacco_flag            IN Varchar2
6810          ,p_dpdnt_adoption_date          IN Date
6811          ,p_dpdnt_vlntry_svce_flag       IN Varchar2
6812          ,p_original_date_of_hire        IN Date
6813          ,p_adjusted_svc_date            IN Date
6814          ,p_town_of_birth                IN Varchar2
6815          ,p_region_of_birth              IN Varchar2
6816          ,p_country_of_birth             IN Varchar2
6817          ,p_global_person_id             IN Varchar2
6818          -- Person DF
6819          ,p_per_attribute_category       IN Varchar2
6820          ,p_per_attribute1               IN Varchar2
6821          ,p_per_attribute2               IN Varchar2
6822          ,p_per_attribute3               IN Varchar2
6823          ,p_per_attribute4               IN Varchar2
6824          ,p_per_attribute5               IN Varchar2
6825          ,p_per_attribute6               IN Varchar2
6826          ,p_per_attribute7               IN Varchar2
6827          ,p_per_attribute8               IN Varchar2
6828          ,p_per_attribute9               IN Varchar2
6829          ,p_per_attribute10              IN Varchar2
6830          ,p_per_attribute11              IN Varchar2
6831          ,p_per_attribute12              IN Varchar2
6832          ,p_per_attribute13              IN Varchar2
6833          ,p_per_attribute14              IN Varchar2
6834          ,p_per_attribute15              IN Varchar2
6835          ,p_per_attribute16              IN Varchar2
6836          ,p_per_attribute17              IN Varchar2
6837          ,p_per_attribute18              IN Varchar2
6838          ,p_per_attribute19              IN Varchar2
6839          ,p_per_attribute20              IN Varchar2
6840          ,p_per_attribute21              IN Varchar2
6841          ,p_per_attribute22              IN Varchar2
6842          ,p_per_attribute23              IN Varchar2
6843          ,p_per_attribute24              IN Varchar2
6844          ,p_per_attribute25              IN Varchar2
6845          ,p_per_attribute26              IN Varchar2
6846          ,p_per_attribute27              IN Varchar2
6847          ,p_per_attribute28              IN Varchar2
6848          ,p_per_attribute29              IN Varchar2
6849          ,p_per_attribute30              IN Varchar2
6850          -- Person DDF
6851          ,p_per_information_category     IN Varchar2
6852          ,p_per_information1             IN Varchar2
6853          ,p_per_information2             IN Varchar2
6854          ,p_per_information3             IN Varchar2
6855          ,p_per_information4             IN Varchar2
6856          ,p_per_information5             IN Varchar2
6857          ,p_per_information6             IN Varchar2
6858          ,p_per_information7             IN Varchar2
6859          ,p_per_information8             IN Varchar2
6860          ,p_per_information9             IN Varchar2
6861          ,p_per_information10            IN Varchar2
6862          ,p_per_information11            IN Varchar2
6863          ,p_per_information12            IN Varchar2
6864          ,p_per_information13            IN Varchar2
6865          ,p_per_information14            IN Varchar2
6866          ,p_per_information15            IN Varchar2
6867          ,p_per_information16            IN Varchar2
6868          ,p_per_information17            IN Varchar2
6869          ,p_per_information18            IN Varchar2
6870          ,p_per_information19            IN Varchar2
6871          ,p_per_information20            IN Varchar2
6872          ,p_per_information21            IN Varchar2
6873          ,p_per_information22            IN Varchar2
6874          ,p_per_information23            IN Varchar2
6875          ,p_per_information24            IN Varchar2
6876          ,p_per_information25            IN Varchar2
6877          ,p_per_information26            IN Varchar2
6878          ,p_per_information27            IN Varchar2
6879          ,p_per_information28            IN Varchar2
6880          ,p_per_information29            IN Varchar2
6881          ,p_per_information30            IN Varchar2
6882          -- Primary Address: Per_Addresses
6883          ,p_pradd_ovlapval_override      IN Varchar2
6884          ,p_address_type                 IN Varchar2
6885          ,p_adr_comments                 IN Varchar2
6886          ,p_primary_flag                 IN Varchar2
6887          ,p_address_style                IN Varchar2
6888          ,p_address_line1                IN Varchar2
6889          ,p_address_line2                IN Varchar2
6890          ,p_address_line3                IN Varchar2
6891          ,p_region1                      IN Varchar2
6892          ,p_region2                      IN Varchar2
6893          ,p_region3                      IN Varchar2
6894          ,p_town_or_city                 IN Varchar2
6895          ,p_country                      IN Varchar2
6896          ,p_postal_code                  IN Varchar2
6897          ,p_telephone_no1                IN Varchar2
6898          ,p_telephone_no2                IN Varchar2
6899          ,p_telephone_no3                IN Varchar2
6900          ,p_address_date_from            IN Date
6901          ,p_address_date_to              IN Date
6902          ,p_adr_attribute_category       IN Varchar2
6903          ,p_adr_attribute1               IN Varchar2
6904          ,p_adr_attribute2               IN Varchar2
6905          ,p_adr_attribute3               IN Varchar2
6906          ,p_adr_attribute4               IN Varchar2
6907          ,p_adr_attribute5               IN Varchar2
6908          ,p_adr_attribute6               IN Varchar2
6909          ,p_adr_attribute7               IN Varchar2
6910          ,p_adr_attribute8               IN Varchar2
6911          ,p_adr_attribute9               IN Varchar2
6912          ,p_adr_attribute10              IN Varchar2
6913          ,p_adr_attribute11              IN Varchar2
6914          ,p_adr_attribute12              IN Varchar2
6915          ,p_adr_attribute13              IN Varchar2
6916          ,p_adr_attribute14              IN Varchar2
6917          ,p_adr_attribute15              IN Varchar2
6918          ,p_adr_attribute16              IN Varchar2
6919          ,p_adr_attribute17              IN Varchar2
6920          ,p_adr_attribute18              IN Varchar2
6921          ,p_adr_attribute19              IN Varchar2
6922          ,p_adr_attribute20              IN Varchar2
6923          ,p_add_information13            IN Varchar2
6924          ,p_add_information14            IN Varchar2
6925          ,p_add_information15            IN Varchar2
6926          ,p_add_information16            IN Varchar2
6927          ,p_add_information17            IN Varchar2
6928          ,p_add_information18            IN Varchar2
6929          ,p_add_information19            IN Varchar2
6930          ,p_add_information20            IN Varchar2
6931          -- Person Phones: Per_Phones
6932          ,p_phone_type                   IN Varchar2
6933          ,p_phone_number                 IN Varchar2
6934          ,p_phone_date_from              IN Date
6935          ,p_phone_date_to                IN Date
6936          -- Person Contact: Per_Contact_Relationships
6937          ,p_contact_type                 IN Varchar2
6938          ,p_contact_name                 IN Varchar2
6939          ,p_primary_contact              IN Varchar2
6940          ,p_primary_relationship         IN Varchar2
6941          ,p_contact_date_from            IN Date
6942          ,p_contact_date_to              IN Date
6943          ,p_return_status                OUT NOCOPY Varchar2
6944          ,p_dup_asg_id                   IN Number
6945          ,p_mode_type                    IN Varchar2
6946         ) AS
6947   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Create_OSS_Person';
6948   l_effective_date         Date;
6949   l_chk_per                chk_party%ROWTYPE;
6950   l_dff_ctx          fnd_descr_flex_contexts.descriptive_flex_context_code%TYPE;
6951   l_emp_api_out            t_hrEmpApi;
6952   l_updper_api_out         t_UpdEmp_Api;
6953   l_HireToJobapi_out       t_HrToJob_Api;
6954   l_crt_emp_api_out        t_CreateContact_Api;
6955   l_pp_error_code          Varchar2(50);
6956   l_passport_warning       Boolean;
6957   l_visa_error_code        Varchar2(50);
6958   l_visa_warning           Boolean;
6959   l_visit_error_code       Varchar2(50);
6960   l_visit_warning          Boolean;
6961   l_oss_error_code         Varchar2(50);
6962   l_ossDtls_warning        Boolean;
6963   l_error_message          Varchar2(2000);
6964   l_per_ptu_rec            csr_per_ptu%ROWTYPE;
6965   l_HireAppapi_out         t_HrApp_Api;
6966   l_active_cwk             Boolean;
6967   e_active_cwk             Exception;
6968 
6969 BEGIN
6970   SAVEPOINT create_upd_person;
6971   g_debug_on := hr_utility.debug_enabled;
6972 
6973   hr_utility.set_location('Entering: ' || l_proc_name, 10);
6974 
6975   IF g_debug_on THEN
6976      hr_utility.set_location('..p_business_group_id :' || p_business_group_id,20);
6977      hr_utility.set_location('..p_dup_person_id :' || p_dup_person_id,20);
6978      hr_utility.set_location('..p_party_id :' || p_party_id,20);
6979      hr_utility.set_location('..p_last_name :' || p_last_name,20);
6980      hr_utility.set_location('..p_marital_status :' || p_marital_status,20);
6981      hr_utility.set_location('..p_sex :' || p_sex,20);
6982      hr_utility.set_location('..p_date_of_birth :' || p_date_of_birth,20);
6983      hr_utility.set_location('..p_date_of_hire :' || p_date_of_hire,20);
6984      hr_utility.set_location('..p_employee_number :' || p_employee_number,20);
6985      hr_utility.set_location('..p_person_type_id :' || p_person_type_id,20);
6986      hr_utility.set_location('..p_effective_date :' || p_effective_date,20);
6987   END IF;
6988 
6989   l_per_rec     := NULL;
6990   l_hr_soft_rec := NULL;
6991   l_add_rec     := NULL;
6992   l_ppl_grp_rec := NULL;
6993   l_asg_rec     := NULL;
6994 
6995   l_effective_date := p_date_of_hire;
6996 
6997   -- Get Bus. Group Id in a pkg global variable
6998   OPEN  csr_bg_code (c_bg_grp_id => p_business_group_id);
6999   FETCH csr_bg_code INTO g_leg_code,g_emp_num_gen;
7000   CLOSE csr_bg_code;
7001   -- ===========================================================================
7002   -- ~ Person Details
7003   -- ===========================================================================
7004   l_per_rec.business_group_id             := p_business_group_id;
7005   l_per_rec.party_id                      := p_party_id;
7006   l_per_rec.last_name                     := p_last_name;
7007   l_per_rec.middle_names                  := p_middle_name;
7008   l_per_rec.first_name                    := p_first_name;
7009   l_per_rec.suffix                        := p_suffix;
7010   l_per_rec.pre_name_adjunct              := p_prefix;
7011   l_per_rec.title                         := p_title;
7012   l_per_rec.email_address                 := p_email_address;
7013   l_per_rec.known_as                      := p_preferred_name;
7014   l_per_rec.marital_status                := p_marital_status;
7015   l_per_rec.sex                           := p_sex;
7016   l_per_rec.nationality                   := p_nationality;
7017   l_per_rec.national_identifier           := p_national_identifier;
7018   l_per_rec.date_of_birth                 := p_date_of_birth;
7019   l_per_rec.start_date                    := p_date_of_hire;
7020   IF g_emp_num_gen <> 'A' THEN
7021     l_per_rec.employee_number := p_employee_number;
7022   ELSE
7023     l_per_rec.employee_number := Null;
7024   END IF;
7025   l_per_rec.person_type_id                := p_person_type_id;
7026   l_per_rec.date_employee_data_verified   := p_date_employee_data_verified;
7027   l_per_rec.expense_check_send_to_address := p_expense_check_send_to_addres;
7028   l_per_rec.previous_last_name            := p_previous_last_name;
7029   l_per_rec.registered_disabled_flag      := p_registered_disabled_flag;
7030   l_per_rec.vendor_id                     := p_vendor_id;
7031   l_per_rec.date_of_death                 := p_date_of_death;
7032   l_per_rec.background_check_status       := p_background_check_status;
7033   l_per_rec.background_date_check         := p_background_date_check;
7034   l_per_rec.blood_type                    := p_blood_type;
7035   l_per_rec.correspondence_language       := p_correspondence_language;
7036   l_per_rec.fast_path_employee            := p_fast_path_employee;
7037   l_per_rec.fte_capacity                  := p_fte_capacity;
7038   l_per_rec.honors                        := p_honors;
7039   l_per_rec.last_medical_test_by          := p_last_medical_test_by;
7040   l_per_rec.last_medical_test_date        := p_last_medical_test_date;
7041   l_per_rec.mailstop                      := p_mailstop;
7042   l_per_rec.office_number                 := p_office_number;
7043   l_per_rec.on_military_service           := NVL(p_on_military_service,'N');
7044   l_per_rec.pre_name_adjunct              := p_pre_name_adjunct;
7045   l_per_rec.projected_start_date          := p_projected_start_date;
7046   l_per_rec.resume_exists                 := NVL(p_resume_exists,'N');
7047   l_per_rec.resume_last_updated           := p_resume_last_updated;
7048   l_per_rec.second_passport_exists        := NVL(p_second_passport_exists,'N');
7049   l_per_rec.student_status                := p_student_status;
7050   l_per_rec.work_schedule                 := p_work_schedule;
7051   l_per_rec.benefit_group_id              := p_benefit_group_id;
7052   l_per_rec.receipt_of_death_cert_date    := p_receipt_of_death_cert_date;
7053   l_per_rec.coord_ben_med_pln_no          := p_coord_ben_med_pln_no;
7054   l_per_rec.coord_ben_no_cvg_flag         := NVL(p_coord_ben_no_cvg_flag,'N');
7055   l_per_rec.coord_ben_med_ext_er          := p_coord_ben_med_ext_er;
7056   l_per_rec.coord_ben_med_pl_name         := p_coord_ben_med_pl_name;
7057   l_per_rec.coord_ben_med_insr_crr_name   := p_coord_ben_med_insr_crr_name;
7058   l_per_rec.coord_ben_med_insr_crr_ident  := p_coord_ben_med_insr_crr_ident;
7059   l_per_rec.coord_ben_med_cvg_strt_dt     := p_coord_ben_med_cvg_strt_dt;
7060   l_per_rec.coord_ben_med_cvg_end_dt      := p_coord_ben_med_cvg_end_dt;
7061   l_per_rec.uses_tobacco_flag             := p_uses_tobacco_flag;
7062   l_per_rec.dpdnt_adoption_date           := p_dpdnt_adoption_date;
7063   l_per_rec.dpdnt_vlntry_svce_flag        := NVL(p_dpdnt_vlntry_svce_flag,'N');
7064   l_per_rec.original_date_of_hire         := p_original_date_of_hire;
7065   l_per_rec.town_of_birth                 := p_town_of_birth;
7066   l_per_rec.region_of_birth               := p_region_of_birth;
7067   l_per_rec.country_of_birth              := p_country_of_birth;
7068   l_per_rec.global_person_id              := p_global_person_id;
7069 
7070   hr_utility.set_location('Person Details assigned to record :l_per_rec ', 30);
7071 
7072   -- Person DF: Customer defined
7073   l_per_rec.attribute_category            := p_per_attribute_category;
7074   l_per_rec.attribute1                    := p_per_attribute1;
7075   l_per_rec.attribute2                    := p_per_attribute2;
7076   l_per_rec.attribute3                    := p_per_attribute3;
7077   l_per_rec.attribute4                    := p_per_attribute4;
7078   l_per_rec.attribute5                    := p_per_attribute5;
7079   l_per_rec.attribute6                    := p_per_attribute6;
7080   l_per_rec.attribute7                    := p_per_attribute7;
7081   l_per_rec.attribute8                    := p_per_attribute8;
7082   l_per_rec.attribute9                    := p_per_attribute9;
7083   l_per_rec.attribute10                   := p_per_attribute10;
7084   l_per_rec.attribute11                   := p_per_attribute11;
7085   l_per_rec.attribute12                   := p_per_attribute12;
7086   l_per_rec.attribute13                   := p_per_attribute13;
7087   l_per_rec.attribute14                   := p_per_attribute14;
7088   l_per_rec.attribute15                   := p_per_attribute15;
7089   l_per_rec.attribute16                   := p_per_attribute16;
7090   l_per_rec.attribute17                   := p_per_attribute17;
7091   l_per_rec.attribute18                   := p_per_attribute18;
7092   l_per_rec.attribute19                   := p_per_attribute19;
7093   l_per_rec.attribute20                   := p_per_attribute20;
7094   l_per_rec.attribute21                   := p_per_attribute21;
7095   l_per_rec.attribute22                   := p_per_attribute22;
7096   l_per_rec.attribute23                   := p_per_attribute23;
7097   l_per_rec.attribute24                   := p_per_attribute24;
7098   l_per_rec.attribute25                   := p_per_attribute25;
7099   l_per_rec.attribute26                   := p_per_attribute26;
7100   l_per_rec.attribute27                   := p_per_attribute27;
7101   l_per_rec.attribute28                   := p_per_attribute28;
7102   l_per_rec.attribute29                   := p_per_attribute29;
7103   l_per_rec.attribute30                   := p_per_attribute30;
7104 
7105   hr_utility.set_location('Person DF assigned to record :l_per_rec ', 40);
7106 
7107   -- Person DDF: Different for each legislation
7108   OPEN  csr_style (c_context_code => g_leg_code);
7109   FETCH csr_style INTO l_dff_ctx;
7110   IF csr_style%FOUND THEN
7111      l_per_rec.per_information_category  :=
7112        NVL(p_per_information_category,g_leg_code);
7113   END IF;
7114   CLOSE csr_style;
7115   l_per_rec.per_information1              := p_per_information1;
7116   l_per_rec.per_information2              := p_per_information2;
7117   l_per_rec.per_information3              := p_per_information3;
7118   l_per_rec.per_information4              := p_per_information4;
7119   l_per_rec.per_information5              := p_per_information5;
7120   l_per_rec.per_information6              := p_per_information6;
7121   l_per_rec.per_information7              := p_per_information7;
7122   l_per_rec.per_information8              := p_per_information8;
7123   l_per_rec.per_information9              := p_per_information9;
7124   l_per_rec.per_information10             := p_per_information10;
7125   l_per_rec.per_information11             := p_per_information11;
7126   l_per_rec.per_information12             := p_per_information12;
7127   l_per_rec.per_information13             := p_per_information13;
7128   l_per_rec.per_information14             := p_per_information14;
7129   l_per_rec.per_information15             := p_per_information15;
7130   l_per_rec.per_information16             := p_per_information16;
7131   l_per_rec.per_information17             := p_per_information17;
7132   l_per_rec.per_information18             := p_per_information18;
7133   l_per_rec.per_information19             := p_per_information19;
7134   l_per_rec.per_information20             := p_per_information20;
7135   l_per_rec.per_information21             := p_per_information21;
7136   l_per_rec.per_information22             := p_per_information22;
7137   l_per_rec.per_information23             := p_per_information23;
7138   l_per_rec.per_information24             := p_per_information24;
7139   l_per_rec.per_information25             := p_per_information25;
7140   l_per_rec.per_information26             := p_per_information26;
7141   l_per_rec.per_information27             := p_per_information27;
7142   l_per_rec.per_information28             := p_per_information28;
7143   l_per_rec.per_information29             := p_per_information29;
7144   l_per_rec.per_information30             := p_per_information30;
7145 
7146   hr_utility.set_location('Person DDF assigned to record :l_per_rec ', 50);
7147 
7148   -- ===========================================================================
7149   -- ~ Person Address Record
7150   -- ===========================================================================
7151   -- p_pradd_ovlapval_override;
7152   l_add_rec.business_group_id             := p_business_group_id;
7153   l_add_rec.party_id                      := p_party_id;
7154   l_add_rec.address_type                  := p_address_type;
7155   l_add_rec.comments                      := p_adr_comments;
7156   l_add_rec.primary_flag                  := NVL(p_primary_flag,'Y');
7157   l_add_rec.style                         := p_address_style;
7158   l_add_rec.address_line1                 := p_address_line1;
7159   l_add_rec.address_line2                 := p_address_line2;
7160   l_add_rec.address_line3                 := p_address_line3;
7161   l_add_rec.region_1                      := p_region1;
7162   l_add_rec.region_2                      := p_region2;
7163   l_add_rec.region_3                      := p_region3;
7164   l_add_rec.town_or_city                  := p_town_or_city;
7165   l_add_rec.country                       := p_country;
7166   l_add_rec.postal_code                   := p_postal_code;
7167   l_add_rec.telephone_number_1            := p_telephone_no1;
7168   l_add_rec.telephone_number_2            := p_telephone_no2;
7169   l_add_rec.telephone_number_3            := p_telephone_no3;
7170   l_add_rec.add_information13             := p_add_information13;
7171   l_add_rec.add_information14             := p_add_information14;
7172   l_add_rec.add_information15             := p_add_information15;
7173   l_add_rec.add_information16             := p_add_information16;
7174   l_add_rec.add_information18             := p_add_information17;
7175   l_add_rec.add_information18             := p_add_information18;
7176   l_add_rec.add_information19             := p_add_information19;
7177   l_add_rec.add_information20             := p_add_information20;
7178 
7179   hr_utility.set_location('Address DDF assigned to record, Style: ' ||
7180                            p_address_style, 60);
7181 
7182   -- Address DF
7183   l_add_rec.addr_attribute_category       := p_adr_attribute_category;
7184   l_add_rec.addr_attribute1               := p_adr_attribute1;
7185   l_add_rec.addr_attribute2               := p_adr_attribute2;
7186   l_add_rec.addr_attribute3               := p_adr_attribute3;
7187   l_add_rec.addr_attribute4               := p_adr_attribute4;
7188   l_add_rec.addr_attribute5               := p_adr_attribute5;
7189   l_add_rec.addr_attribute6               := p_adr_attribute6;
7190   l_add_rec.addr_attribute7               := p_adr_attribute7;
7191   l_add_rec.addr_attribute8               := p_adr_attribute8;
7192   l_add_rec.addr_attribute9               := p_adr_attribute9;
7193   l_add_rec.addr_attribute10              := p_adr_attribute10;
7194   l_add_rec.addr_attribute11              := p_adr_attribute11;
7195   l_add_rec.addr_attribute12              := p_adr_attribute12;
7196   l_add_rec.addr_attribute13              := p_adr_attribute13;
7197   l_add_rec.addr_attribute14              := p_adr_attribute14;
7198   l_add_rec.addr_attribute15              := p_adr_attribute15;
7199   l_add_rec.addr_attribute16              := p_adr_attribute16;
7200   l_add_rec.addr_attribute17              := p_adr_attribute17;
7201   l_add_rec.addr_attribute18              := p_adr_attribute18;
7202   l_add_rec.addr_attribute19              := p_adr_attribute19;
7203   l_add_rec.addr_attribute20              := p_adr_attribute20;
7204 
7205   hr_utility.set_location('Address DF assigned to record, Style: ' ||
7206                            p_address_style, 70);
7207 
7208   OPEN  chk_party (c_party_id       => l_per_rec.party_id
7209                   ,c_bg_grp_id      => l_per_rec.business_group_id
7210                   ,c_person_id      => p_dup_person_id
7211                   ,c_effective_date => l_effective_date
7212                    );
7213   FETCH chk_party INTO l_chk_per;
7214   IF chk_party%NOTFOUND THEN
7215      hr_utility.set_location(' Creating a new Student Employee', 80);
7216      -- Create the employee
7217      l_effective_date     := p_date_of_hire;
7218      l_per_rec.start_date := l_effective_date;
7219 
7220      Create_EmpIn_HRMS
7221      (p_validate            => FALSE
7222      ,p_effective_date      => l_per_rec.START_DATE
7223      ,p_adjusted_svc_date   => p_adjusted_svc_date
7224      ,p_per_comments        => NULL
7225      ,p_emp_api_out         => l_emp_api_out
7226      );
7227 
7228      -- Create the primary address
7229      l_add_rec.person_id    := l_emp_api_out.person_id;
7230      l_add_rec.primary_flag := 'Y';
7231      hr_utility.set_location(' Creating Primary Address', 90);
7232      -- Call the Address API only if user has eneterd the address details
7233      IF p_address_line1 IS NOT NULL AND
7234         l_add_rec.style IS NOT NULL THEN
7235 
7236        l_add_rec.date_from  := l_effective_date;
7237        l_add_rec.date_to    := p_address_date_to;
7238 
7239        InsUpd_Address
7240        (p_effective_date           => l_effective_date
7241        ,p_HR_address_id            => l_add_rec.address_id
7242        ,p_HR_object_version_number => l_add_rec.object_version_number
7243        );
7244      END IF;
7245 
7246      -- Create Phones record default to H1=Home
7247      hr_utility.set_location(' Creating Phones record', 100);
7248      l_phones_rec.parent_id  := l_emp_api_out.person_id;
7249      l_phones_rec.date_from  := l_effective_date;
7250 
7251      -- Create Contact Details
7252      l_cntct_rec.person_id   := l_emp_api_out.person_id;
7253      hr_utility.set_location(' Creating Contact details', 110);
7254 
7255      -- Create Contact Type only when Contact Details have been entered
7256      IF l_cntct_rec.contact_type IS NOT NULL THEN
7257         Create_Person_Contact
7258         (p_effective_date   => l_effective_date
7259         ,p_contact_name     => p_contact_name
7260         ,p_legislation_code => g_leg_code
7261         ,p_crt_cntct_out    => l_crt_emp_api_out
7262         );
7263      END IF;
7264      IF g_leg_code = 'US' THEN
7265        -- Get Passport details from OSS
7266        Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
7267        (p_business_group_id => p_business_group_id
7268        ,p_person_id         => l_per_rec.person_id
7269        ,p_party_id          => p_party_id
7270        ,p_effective_date    => l_effective_date
7271        ,p_pp_error_code     => l_pp_error_code
7272        ,p_passport_warning  => l_passport_warning
7273         );
7274        -- Get Visa Details from OSS
7275        Pqp_Hrtca_Integration.InsUpd_InHR_Visa
7276        (p_business_group_id => p_business_group_id
7277        ,p_person_id         => l_per_rec.person_id
7278        ,p_party_id          => p_party_id
7279        ,p_effective_date    => l_effective_date
7280        ,p_visa_error_code   => l_visa_error_code
7281        ,p_visa_warning      => l_visa_warning
7282         );
7283        -- Get Visit History details from OSS
7284        Pqp_Hrtca_Integration.InsUpd_InHR_Visit
7285        (p_business_group_id => p_business_group_id
7286        ,p_person_id         => l_per_rec.person_id
7287        ,p_party_id          => p_party_id
7288        ,p_effective_date    => l_effective_date
7289        ,p_visit_error_code  => l_visit_error_code
7290        ,p_visit_warning     => l_visit_warning
7291        );
7292      END IF;
7293      -- Create the Person EIT to specify the person as an
7294      -- OSS Person along with the Person number, party id.
7295      Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
7296      (p_business_group_id => p_business_group_id
7297      ,p_person_id         => l_per_rec.person_id
7298      ,p_party_id          => p_party_id
7299      ,p_effective_date    => l_effective_date
7300      ,p_oss_error_code    => l_oss_error_code
7301      ,p_ossDtls_warning   => l_ossDtls_warning
7302       );
7303 
7304   ELSIF l_chk_per.system_person_type IN
7305          ('OTHER','EX_EMP','EX_APL') THEN
7306 
7307      hr_utility.set_location(' Current person type: ' ||
7308                               l_chk_per.system_person_type, 120);
7309      -- Hire the existing person
7310      l_per_rec.person_id  := l_chk_per.person_id;
7311      l_per_rec.business_group_id := p_business_group_id;
7312      l_per_rec.party_id   := p_party_id;
7313      l_effective_date     := p_date_of_hire;
7314      l_per_rec.start_date := l_effective_date;
7315 
7316      IF l_chk_per.system_person_type ='OTHER' THEN
7317         FOR ptu_rec IN  csr_per_ptu
7318                         (c_person_id         => l_chk_per.person_id
7319                         ,c_business_group_id => p_business_group_id
7320                         ,c_effective_date    => l_effective_date)
7321         LOOP
7322            IF ptu_rec.system_person_type = 'CWK' THEN
7323               l_active_cwk := TRUE;
7324               EXIT;
7325            END IF;
7326         END LOOP;
7327      END IF;
7328 
7329      IF l_active_cwk THEN
7330         RAISE e_active_cwk;
7331      END IF;
7332 
7333      -- Hire the Contact, Ex-Employee, Ex-Applicant or Ex-Contingent Worker
7334      Hire_Person_IntoEmp
7335      (p_validate            => FALSE
7336      ,p_hire_date           => l_per_rec.start_date
7337      ,p_person_id           => p_dup_person_id
7338      ,p_adjusted_svc_date   => p_adjusted_svc_date
7339      ,p_updper_api_out      => l_updper_api_out
7340      ,p_HireToJobapi_out    => l_HireToJobapi_out
7341       );
7342      -- Create the primary address
7343      l_add_rec.person_id    := p_dup_person_id;
7344      l_add_rec.primary_flag := 'Y';
7345 
7346      -- Call the Address API only if user has eneterd the address details
7347      IF p_address_line1 IS NOT NULL AND
7348         l_add_rec.style IS NOT NULL THEN
7349        l_add_rec.date_from  := l_effective_date;
7350        l_add_rec.date_to    := p_address_date_to;
7351 
7352        InsUpd_Address
7353        (p_effective_date           => l_effective_date
7354        ,p_HR_address_id            => l_add_rec.address_id
7355        ,p_HR_object_version_number => l_add_rec.object_version_number
7356        );
7357      END IF;
7358 
7359      -- Create Contact Details
7360      l_cntct_rec.person_id   := l_emp_api_out.person_id;
7361 
7362      -- Create Contact Type only when Contact Details have been entered
7363      IF l_cntct_rec.contact_type IS NOT NULL THEN
7364        Create_Person_Contact
7365         (p_effective_date   => l_effective_date
7366         ,p_contact_name     => p_contact_name
7367         ,p_legislation_code => g_leg_code
7368         ,p_crt_cntct_out    => l_crt_emp_api_out
7369         );
7370      END IF;
7371      IF g_leg_code = 'US' THEN
7372         -- Get Passport details from OSS
7373         Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
7374         (p_business_group_id => p_business_group_id
7375         ,p_person_id         => l_per_rec.person_id
7376         ,p_party_id          => p_party_id
7377         ,p_effective_date    => l_effective_date
7378         ,p_pp_error_code     => l_pp_error_code
7379         ,p_passport_warning  => l_passport_warning
7380          );
7381         -- Get Visa Details from OSS
7382         Pqp_Hrtca_Integration.InsUpd_InHR_Visa
7383         (p_business_group_id => p_business_group_id
7384         ,p_person_id         => l_per_rec.person_id
7385         ,p_party_id          => p_party_id
7386         ,p_effective_date    => l_effective_date
7387         ,p_visa_error_code   => l_visa_error_code
7388         ,p_visa_warning      => l_visa_warning
7389          );
7390         -- Get Visit History details from OSS
7391         Pqp_Hrtca_Integration.InsUpd_InHR_Visit
7392         (p_business_group_id => p_business_group_id
7393         ,p_person_id         => l_per_rec.person_id
7394         ,p_party_id          => p_party_id
7395         ,p_effective_date    => l_effective_date
7396         ,p_visit_error_code  => l_visit_error_code
7397         ,p_visit_warning     => l_visit_warning
7398         );
7399      END IF;
7400      -- Create the Person EIT to specify the person as an
7401      -- OSS Person along with the Person number, party id.
7402      Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
7403      (p_business_group_id => p_business_group_id
7404      ,p_person_id         => l_per_rec.person_id
7405      ,p_party_id          => p_party_id
7406      ,p_effective_date    => l_effective_date
7407      ,p_oss_error_code    => l_oss_error_code
7408      ,p_ossDtls_warning   => l_ossDtls_warning
7409       );
7410 
7411 
7412   ELSIF l_chk_per.system_person_type IN
7413         ('EX_EMP_APL','APL_EX_APL','APL') THEN
7414      hr_utility.set_location(' Current person type: ' ||
7415                               l_chk_per.system_person_type, 130);
7416      hr_utility.set_location('..Applicant being hired as Student' ||
7417                              ' Employee', 130);
7418 
7419      l_per_rec.person_id         := l_chk_per.person_id;
7420      l_per_rec.business_group_id := p_business_group_id;
7421      l_per_rec.party_id          := p_party_id;
7422      l_effective_date            := p_date_of_hire;
7423      l_per_rec.start_date        := l_effective_date;
7424      -- Hire the Applicant Assignment
7425      IF NVL(p_dup_asg_id,0) <> 0 then
7426         Hire_Applicant_IntoEmp
7427         (p_validate           => FALSE
7428         ,p_hire_date          => l_effective_date
7429         ,p_person_id          => l_chk_per.person_id
7430         ,p_assignment_id      => p_dup_asg_id
7431         ,p_adjusted_svc_date  => p_adjusted_svc_date
7432         ,p_updper_api_out     => l_updper_api_out
7433         ,p_HireAppapi_out     => l_HireAppapi_out);
7434 	--passed the value of person to add_rec
7435 	--Bug 5447808
7436         l_add_rec.person_id    := l_chk_per.person_id;
7437 	--
7438      ELSE
7439          Create_EmpIn_HRMS
7440          (p_validate            => FALSE
7441          ,p_effective_date      => l_per_rec.START_DATE
7442          ,p_adjusted_svc_date   => p_adjusted_svc_date
7443          ,p_per_comments        => NULL
7444          ,p_emp_api_out         => l_emp_api_out
7445          );
7446          l_add_rec.person_id    := l_emp_api_out.person_id;
7447          l_per_rec.person_id    := l_emp_api_out.person_id;
7448          l_cntct_rec.person_id  := l_emp_api_out.person_id;
7449          l_phones_rec.parent_id  := l_emp_api_out.person_id;
7450      END IF;
7451      -- Create Contact Type only when Contact Details have been entered
7452      IF l_cntct_rec.contact_type IS NOT NULL THEN
7453        Create_Person_Contact
7454         (p_effective_date   => l_effective_date
7455         ,p_contact_name     => p_contact_name
7456         ,p_legislation_code => g_leg_code
7457         ,p_crt_cntct_out    => l_crt_emp_api_out
7458         );
7459      END IF;
7460      hr_utility.set_location(' Updated person details ', 140);
7461      -- Call the Address API only if user has eneterd the address details
7462      IF p_address_line1 IS NOT NULL AND
7463 
7464        l_add_rec.style IS NOT NULL THEN
7465        --Moved to  NVL(p_dup_asg_id,0) <> 0 block
7466       -- l_add_rec.person_id := l_per_rec.person_id;
7467        l_add_rec.business_group_id := l_per_rec.business_group_id;
7468        l_add_rec.primary_flag := 'Y';
7469 
7470        l_add_rec.date_from  := l_effective_date;
7471        l_add_rec.date_to    := NULL;
7472 
7473        hr_utility.set_location(' Updating Person Primary Address ', 150);
7474        InsUpd_Address
7475        (p_effective_date           => l_effective_date
7476        ,p_HR_address_id            => l_add_rec.address_id
7477        ,p_HR_object_version_number => l_add_rec.object_version_number
7478        );
7479      END IF;
7480 
7481      IF g_leg_code = 'US' THEN
7482         -- Get Passport details from OSS
7483         Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
7484         (p_business_group_id => p_business_group_id
7485         ,p_person_id         => l_per_rec.person_id
7486         ,p_party_id          => p_party_id
7487         ,p_effective_date    => l_effective_date
7488         ,p_pp_error_code     => l_pp_error_code
7489         ,p_passport_warning  => l_passport_warning
7490          );
7491         -- Get Visa Details from OSS
7492         Pqp_Hrtca_Integration.InsUpd_InHR_Visa
7493         (p_business_group_id => p_business_group_id
7494         ,p_person_id         => l_per_rec.person_id
7495         ,p_party_id          => p_party_id
7496         ,p_effective_date    => l_effective_date
7497         ,p_visa_error_code   => l_visa_error_code
7498         ,p_visa_warning      => l_visa_warning
7499          );
7500         -- Get Visit History details from OSS
7501         Pqp_Hrtca_Integration.InsUpd_InHR_Visit
7502         (p_business_group_id => p_business_group_id
7503         ,p_person_id         => l_per_rec.person_id
7504         ,p_party_id          => p_party_id
7505         ,p_effective_date    => l_effective_date
7506         ,p_visit_error_code  => l_visit_error_code
7507         ,p_visit_warning     => l_visit_warning
7508         );
7509      END IF;
7510 
7511      -- Create the Person EIT to specify the person as an
7512      -- OSS Person along with the Person number, party id.
7513      Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
7514      (p_business_group_id => p_business_group_id
7515      ,p_person_id         => l_per_rec.person_id
7516      ,p_party_id          => p_party_id
7517      ,p_effective_date    => l_effective_date
7518      ,p_oss_error_code    => l_oss_error_code
7519      ,p_ossDtls_warning   => l_ossDtls_warning
7520       );
7521 
7522      hr_utility.set_location(' Updated Passport, Visa, Visit History' ||
7523                              ' details: ', 160);
7524 
7525   ELSIF l_chk_per.system_person_type IN ('EMP','EMP_APL') THEN
7526 
7527      hr_utility.set_location(' Current person type: ' ||
7528                                l_chk_per.system_person_type, 170);
7529 
7530      l_per_rec.person_id := l_chk_per.person_id;
7531      l_per_rec.business_group_id := p_business_group_id;
7532      l_per_rec.party_id  := p_party_id;
7533      l_effective_date    := p_effective_date;
7534 
7535      Upd_OSS_Person
7536      (p_validate            => FALSE
7537      ,p_effective_date      => l_effective_date
7538      ,p_person_id           => l_per_rec.person_id
7539      ,p_adjusted_svc_date   => p_adjusted_svc_date
7540      ,p_updper_api_out      => l_updper_api_out
7541       );
7542 
7543      hr_utility.set_location(' Updated person details ', 180);
7544 
7545      -- Call the Address API only if user has eneterd the address details
7546      IF p_address_line1 IS NOT NULL AND
7547 
7548        l_add_rec.style IS NOT NULL THEN
7549        l_add_rec.person_id := l_per_rec.person_id;
7550        l_add_rec.business_group_id := l_per_rec.business_group_id;
7551        l_add_rec.primary_flag := 'Y';
7552 
7553        l_add_rec.date_from  := l_effective_date;
7554        l_add_rec.date_to    := NULL;
7555 
7556        hr_utility.set_location(' Updating Person Primary Address ', 190);
7557        InsUpd_Address
7558        (p_effective_date           => l_effective_date
7559        ,p_HR_address_id            => l_add_rec.address_id
7560        ,p_HR_object_version_number => l_add_rec.object_version_number
7561        );
7562 
7563      END IF;
7564 
7565      IF g_leg_code = 'US'       AND
7566         p_mode_type <> 'UPDATE' THEN
7567         -- Get Passport details from OSS
7568         Pqp_Hrtca_Integration.InsUpd_InHR_PassPort
7569         (p_business_group_id => p_business_group_id
7570         ,p_person_id         => l_per_rec.person_id
7571         ,p_party_id          => p_party_id
7572         ,p_effective_date    => l_effective_date
7573         ,p_pp_error_code     => l_pp_error_code
7574         ,p_passport_warning  => l_passport_warning
7575          );
7576         -- Get Visa Details from OSS
7577         Pqp_Hrtca_Integration.InsUpd_InHR_Visa
7578         (p_business_group_id => p_business_group_id
7579         ,p_person_id         => l_per_rec.person_id
7580         ,p_party_id          => p_party_id
7581         ,p_effective_date    => l_effective_date
7582         ,p_visa_error_code   => l_visa_error_code
7583         ,p_visa_warning      => l_visa_warning
7584          );
7585         -- Get Visit History details from OSS
7586         Pqp_Hrtca_Integration.InsUpd_InHR_Visit
7587         (p_business_group_id => p_business_group_id
7588         ,p_person_id         => l_per_rec.person_id
7589         ,p_party_id          => p_party_id
7590         ,p_effective_date    => l_effective_date
7591         ,p_visit_error_code  => l_visit_error_code
7592         ,p_visit_warning     => l_visit_warning
7593         );
7594 
7595         -- Create the Person EIT to specify the person as an
7596         -- OSS Person along with the Person number, party id.
7597         Pqp_Hrtca_Integration.InsUpd_InHR_OSSPerDtls
7598         (p_business_group_id => p_business_group_id
7599         ,p_person_id         => l_per_rec.person_id
7600         ,p_party_id          => p_party_id
7601         ,p_effective_date    => l_effective_date
7602         ,p_oss_error_code    => l_oss_error_code
7603         ,p_ossDtls_warning   => l_ossDtls_warning
7604         );
7605      END IF;
7606 
7607      hr_utility.set_location(' Updated Passport, Visa, Visit History' ||
7608                              ' details: ', 200);
7609 
7610   END IF;
7611   CLOSE chk_party;
7612 
7613   hr_utility.set_location('Leaving: ' || l_proc_name, 210);
7614 
7615 EXCEPTION
7616    WHEN e_active_cwk THEN
7617     CLOSE chk_party;
7618     ROLLBACK TO create_upd_person;
7619     l_error_message := 'Active Contingent Worker cannot be hired as a ' ||
7620                         'Student Employee';
7621     l_error_message:= l_per_rec.first_name ||' '||l_per_rec.last_name ||': '||
7622                       l_error_message;
7623     l_error_message := Replace(l_error_message,'ORA-20001:',' ');
7624     hr_utility.set_location('..CWK being hired as Student Employee', 220);
7625     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7626     hr_utility.set_message_token('GENERIC_TOKEN',l_error_message );
7627     hr_utility.set_location('Leaving: ' || l_proc_name, 220);
7628     hr_utility.raise_error;
7629 
7630    WHEN Others THEN
7631     CLOSE chk_party;
7632     ROLLBACK TO create_upd_person;
7633     hr_utility.set_location('SQLCODE :' || SQLCODE, 230);
7634     l_error_message := SQLERRM;
7635     l_error_message:= l_per_rec.first_name ||' '||l_per_rec.last_name|| ': '||
7636                       l_error_message;
7637     l_error_message := Replace(l_error_message,'ORA-20001:',' ');
7638     hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
7639     hr_utility.set_message_token('GENERIC_TOKEN',l_error_message );
7640     hr_utility.set_location('Leaving: ' || l_proc_name, 230);
7641     hr_utility.raise_error;
7642 
7643 END Create_OSS_Person;
7644 
7645 -- =============================================================================
7646 -- ~ Upd_OSS_Person_Asg:
7647 -- =============================================================================
7648 PROCEDURE Upd_OSS_Person_Asg
7649           (p_effective_date               IN     Date
7650           ,p_datetrack_update_mode        IN     Varchar2
7651           ,p_assignment_id                IN     Number
7652           ,p_party_id                     IN     Number
7653           ,p_business_group_id            IN     Number
7654           ,p_valiDate                     IN     Boolean
7655           ,p_called_from_mass_upDate      IN     Boolean
7656           --
7657           ,p_grade_id                     IN     Number
7658           ,p_position_id                  IN     Number
7659           ,p_job_id                       IN     Number
7660           ,p_payroll_id                   IN     Number
7661           ,p_location_id                  IN     Number
7662           ,p_organization_id              IN     Number
7663           ,p_pay_basis_id                 IN     Number
7664           ,p_employment_category          IN     Varchar2
7665           ,p_assignment_category          IN     Varchar2
7666           --
7667           ,p_supervisor_id                IN     Number
7668           ,p_assignment_number            IN     Varchar2
7669           ,p_change_reason                IN     Varchar2
7670           ,p_assignment_status_type_id    IN     Number
7671           ,p_comments                     IN     Varchar2
7672           ,p_Date_probation_end           IN     Date
7673           ,p_default_code_comb_id         IN     Number
7674           ,p_frequency                    IN     Varchar2
7675           ,p_internal_address_line        IN     Varchar2
7676           ,p_manager_flag                 IN     Varchar2
7677           ,p_normal_hours                 IN     Number
7678           ,p_perf_review_period           IN     Number
7679           ,p_perf_review_period_frequency IN     Varchar2
7680           ,p_probation_period             IN     Number
7681           ,p_probation_unit               IN     Varchar2
7682           ,p_sal_review_period            IN     Number
7683           ,p_sal_review_period_frequency  IN     Varchar2
7684           ,p_set_of_books_id              IN     Number
7685           ,p_source_type                  IN     Varchar2
7686           ,p_time_normal_finish           IN     Varchar2
7687           ,p_time_normal_start            IN     Varchar2
7688           ,p_bargaining_unit_code         IN     Varchar2
7689           ,p_labour_union_member_flag     IN     Varchar2
7690           ,p_hourly_salaried_code         IN     Varchar2
7691           ,p_title                        IN     Varchar2
7692           ,p_notice_period                IN     Number
7693           ,p_notice_period_uom            IN     Varchar2
7694           ,p_employee_category            IN     Varchar2
7695           ,p_work_at_home                 IN     Varchar2
7696           ,p_job_post_source_name         IN     Varchar2
7697           ,p_supervisor_assignment_id     IN     Number
7698           --People Group Keyflex Field
7699           ,p_people_group_id              IN     Number
7700           ,p_pgrp_segment1                IN     Varchar2
7701           ,p_pgrp_segment2                IN     Varchar2
7702           ,p_pgrp_segment3                IN     Varchar2
7703           ,p_pgrp_segment4                IN     Varchar2
7704           ,p_pgrp_segment5                IN     Varchar2
7705           ,p_pgrp_segment6                IN     Varchar2
7706           ,p_pgrp_segment7                IN     Varchar2
7707           ,p_pgrp_segment8                IN     Varchar2
7708           ,p_pgrp_segment9                IN     Varchar2
7709           ,p_pgrp_segment10               IN     Varchar2
7710           ,p_pgrp_segment11               IN     Varchar2
7711           ,p_pgrp_segment12               IN     Varchar2
7712           ,p_pgrp_segment13               IN     Varchar2
7713           ,p_pgrp_segment14               IN     Varchar2
7714           ,p_pgrp_segment15               IN     Varchar2
7715           ,p_pgrp_segment16               IN     Varchar2
7716           ,p_pgrp_segment17               IN     Varchar2
7717           ,p_pgrp_segment18               IN     Varchar2
7718           ,p_pgrp_segment19               IN     Varchar2
7719           ,p_pgrp_segment20               IN     Varchar2
7720           ,p_pgrp_segment21               IN     Varchar2
7721           ,p_pgrp_segment22               IN     Varchar2
7722           ,p_pgrp_segment23               IN     Varchar2
7723           ,p_pgrp_segment24               IN     Varchar2
7724           ,p_pgrp_segment25               IN     Varchar2
7725           ,p_pgrp_segment26               IN     Varchar2
7726           ,p_pgrp_segment27               IN     Varchar2
7727           ,p_pgrp_segment28               IN     Varchar2
7728           ,p_pgrp_segment29               IN     Varchar2
7729           ,p_pgrp_segment30               IN     Varchar2
7730           ,p_pgrp_concat_segments         IN     Varchar2
7731           --Soft Coding KeyflexId
7732           ,p_soft_coding_keyflex_id       IN     Number
7733           ,p_soft_concat_segments         IN     Varchar2
7734           ,p_scl_segment1                 IN     Varchar2
7735           ,p_scl_segment2                 IN     Varchar2
7736           ,p_scl_segment3                 IN     Varchar2
7737           ,p_scl_segment4                 IN     Varchar2
7738           ,p_scl_segment5                 IN     Varchar2
7739           ,p_scl_segment6                 IN     Varchar2
7740           ,p_scl_segment7                 IN     Varchar2
7741           ,p_scl_segment8                 IN     Varchar2
7742           ,p_scl_segment9                 IN     Varchar2
7743           ,p_scl_segment10                IN     Varchar2
7744           ,p_scl_segment11                IN     Varchar2
7745           ,p_scl_segment12                IN     Varchar2
7746           ,p_scl_segment13                IN     Varchar2
7747           ,p_scl_segment14                IN     Varchar2
7748           ,p_scl_segment15                IN     Varchar2
7749           ,p_scl_segment16                IN     Varchar2
7750           ,p_scl_segment17                IN     Varchar2
7751           ,p_scl_segment18                IN     Varchar2
7752           ,p_scl_segment19                IN     Varchar2
7753           ,p_scl_segment20                IN     Varchar2
7754           ,p_scl_segment21                IN     Varchar2
7755           ,p_scl_segment22                IN     Varchar2
7756           ,p_scl_segment23                IN     Varchar2
7757           ,p_scl_segment24                IN     Varchar2
7758           ,p_scl_segment25                IN     Varchar2
7759           ,p_scl_segment26                IN     Varchar2
7760           ,p_scl_segment27                IN     Varchar2
7761           ,p_scl_segment28                IN     Varchar2
7762           ,p_scl_segment29                IN     Varchar2
7763           ,p_scl_segment30                IN     Varchar2
7764           -- Assignment DF Information
7765           ,p_ass_attribute_category       IN     Varchar2
7766           ,p_ass_attribute1               IN     Varchar2
7767           ,p_ass_attribute2               IN     Varchar2
7768           ,p_ass_attribute3               IN     Varchar2
7769           ,p_ass_attribute4               IN     Varchar2
7770           ,p_ass_attribute5               IN     Varchar2
7771           ,p_ass_attribute6               IN     Varchar2
7772           ,p_ass_attribute7               IN     Varchar2
7773           ,p_ass_attribute8               IN     Varchar2
7774           ,p_ass_attribute9               IN     Varchar2
7775           ,p_ass_attribute10              IN     Varchar2
7776           ,p_ass_attribute11              IN     Varchar2
7777           ,p_ass_attribute12              IN     Varchar2
7778           ,p_ass_attribute13              IN     Varchar2
7779           ,p_ass_attribute14              IN     Varchar2
7780           ,p_ass_attribute15              IN     Varchar2
7781           ,p_ass_attribute16              IN     Varchar2
7782           ,p_ass_attribute17              IN     Varchar2
7783           ,p_ass_attribute18              IN     Varchar2
7784           ,p_ass_attribute19              IN     Varchar2
7785           ,p_ass_attribute20              IN     Varchar2
7786           ,p_ass_attribute21              IN     Varchar2
7787           ,p_ass_attribute22              IN     Varchar2
7788           ,p_ass_attribute23              IN     Varchar2
7789           ,p_ass_attribute24              IN     Varchar2
7790           ,p_ass_attribute25              IN     Varchar2
7791           ,p_ass_attribute26              IN     Varchar2
7792           ,p_ass_attribute27              IN     Varchar2
7793           ,p_ass_attribute28              IN     Varchar2
7794           ,p_ass_attribute29              IN     Varchar2
7795           ,p_ass_attribute30              IN     Varchar2
7796           --
7797           ,p_grade_ladder_pgm_id          IN     Number
7798           ,p_special_ceiling_step_id      IN     Number
7799           ,p_cagr_grade_def_id            IN     Number
7800           ,p_contract_id                  IN     Number
7801           ,p_establishment_id             IN     Number
7802           ,p_collective_agreement_id      IN     Number
7803           ,p_cagr_id_flex_num             IN     Number
7804           ,p_cag_segment1                 IN     Varchar2
7805           ,p_cag_segment2                 IN     Varchar2
7806           ,p_cag_segment3                 IN     Varchar2
7807           ,p_cag_segment4                 IN     Varchar2
7808           ,p_cag_segment5                 IN     Varchar2
7809           ,p_cag_segment6                 IN     Varchar2
7810           ,p_cag_segment7                 IN     Varchar2
7811           ,p_cag_segment8                 IN     Varchar2
7812           ,p_cag_segment9                 IN     Varchar2
7813           ,p_cag_segment10                IN     Varchar2
7814           ,p_cag_segment11                IN     Varchar2
7815           ,p_cag_segment12                IN     Varchar2
7816           ,p_cag_segment13                IN     Varchar2
7817           ,p_cag_segment14                IN     Varchar2
7818           ,p_cag_segment15                IN     Varchar2
7819           ,p_cag_segment16                IN     Varchar2
7820           ,p_cag_segment17                IN     Varchar2
7821           ,p_cag_segment18                IN     Varchar2
7822           ,p_cag_segment19                IN     Varchar2
7823           ,p_cag_segment20                IN     Varchar2
7824           ,p_return_status                OUT NOCOPY Varchar2
7825           ,p_FICA_exempt                  IN     Varchar2
7826           ) AS
7827   l_proc_name  CONSTANT    Varchar2(150):= g_pkg ||'Upd_OSS_Person_Asg';
7828   l_asg_crit_out           t_AsgUpdCrit_Api;
7829   l_error_msg              Varchar2(2000);
7830   l_FICA_exempt            Varchar2(5);
7831 BEGIN
7832   g_debug_on := hr_utility.debug_enabled;
7833   hr_utility.set_location('Entering: ' || l_proc_name,10);
7834   -- Get Bus. Group Id in a pkg global variable
7835   OPEN  csr_bg_code (c_bg_grp_id => p_business_group_id);
7836   FETCH csr_bg_code INTO g_leg_code,g_emp_num_gen;
7837   CLOSE csr_bg_code;
7838   IF p_FICA_exempt Is NULL THEN
7839      l_FICA_exempt := 'N';
7840   ELSE
7841      l_FICA_exempt := p_FICA_exempt;
7842   END IF;
7843   IF g_debug_on THEN
7844     hr_utility.set_location('..p_business_group_id :' || p_business_group_id, 20);
7845     hr_utility.set_location('..p_assignment_id     :' || p_assignment_id ,20);
7846     hr_utility.set_location('..p_organization_id   :' || p_organization_id ,20);
7847     hr_utility.set_location('..p_job_id            :' || p_job_id ,20);
7848     hr_utility.set_location('..p_pay_basis_id      :' || p_pay_basis_id ,20);
7849     hr_utility.set_location('..p_grade_id          :' || p_grade_id ,20);
7850     hr_utility.set_location('..p_position_id       :' || p_position_id ,20);
7851     hr_utility.set_location('..p_payroll_id        :' || p_payroll_id ,20);
7852     hr_utility.set_location('..p_effective_date    :' || p_effective_date ,20);
7853   END IF;
7854 
7855   -- ===========================================================================
7856   -- ~ Person Primary Assignment
7857   -- ===========================================================================
7858   l_asg_rec.business_group_id             := p_business_group_id;
7859   l_asg_rec.assignment_id                 := p_assignment_id;
7860   l_asg_rec.organization_id               := p_organization_id;
7861   l_asg_rec.job_id                        := p_job_id;
7862   l_asg_rec.grade_id                      := p_grade_id;
7863   l_asg_rec.position_id                   := p_position_id;
7864   l_asg_rec.payroll_id                    := p_payroll_id;
7865   l_asg_rec.assignment_status_type_id     := p_assignment_status_type_id;
7866   l_asg_rec.assignment_number             := p_assignment_number;
7867 
7868   l_asg_rec.assignment_category           := p_assignment_category;
7869   l_asg_rec.employment_category           := p_employment_category;
7870   l_asg_rec.employee_category             := p_employee_category;
7871 
7872   l_asg_rec.collective_agreement_id       := p_collective_agreement_id;
7873   l_asg_rec.pay_basis_id                  := p_pay_basis_id;
7874   l_asg_rec.supervisor_id                 := p_supervisor_id;
7875   l_asg_rec.change_reason                 := p_change_reason;
7876   l_asg_rec.date_probation_end            := p_date_probation_end;
7877   l_asg_rec.default_code_comb_id          := p_default_code_comb_id;
7878   l_asg_rec.frequency                     := p_frequency;
7879   l_asg_rec.internal_address_line         := p_internal_address_line;
7880   l_asg_rec.manager_flag                  := p_manager_flag;
7881   l_asg_rec.normal_hours                  := p_normal_hours;
7882   l_asg_rec.perf_review_period            := p_perf_review_period;
7883   l_asg_rec.perf_review_period_frequency  := p_perf_review_period_frequency;
7884   l_asg_rec.probation_period              := p_probation_period;
7885   l_asg_rec.probation_unit                := p_probation_unit;
7886   l_asg_rec.sal_review_period             := p_sal_review_period;
7887   l_asg_rec.sal_review_period_frequency   := p_sal_review_period_frequency;
7888   l_asg_rec.set_of_books_id               := p_set_of_books_id;
7889   l_asg_rec.source_type                   := p_source_type;
7890   l_asg_rec.time_normal_finish            := p_time_normal_finish;
7891   l_asg_rec.time_normal_start             := p_time_normal_start;
7892   l_asg_rec.bargaining_unit_code          := p_bargaining_unit_code;
7893   l_asg_rec.labour_union_member_flag      := p_labour_union_member_flag;
7894   l_asg_rec.hourly_salaried_code          := p_hourly_salaried_code;
7895   l_asg_rec.location_id                   := p_location_id;
7896 
7897   hr_utility.set_location('Person Primary Assignment segments assigned to ' ||
7898                           'record: l_asg_rec ', 30);
7899   -- Additional Assignment Details
7900   l_asg_rec.ass_attribute_category        := p_ass_attribute_category;
7901   l_asg_rec.ass_attribute1                := p_ass_attribute1;
7902   l_asg_rec.ass_attribute2                := p_ass_attribute2;
7903   l_asg_rec.ass_attribute3                := p_ass_attribute3;
7904   l_asg_rec.ass_attribute4                := p_ass_attribute4;
7905   l_asg_rec.ass_attribute5                := p_ass_attribute5;
7906   l_asg_rec.ass_attribute6                := p_ass_attribute6;
7907   l_asg_rec.ass_attribute7                := p_ass_attribute7;
7908   l_asg_rec.ass_attribute8                := p_ass_attribute8;
7909   l_asg_rec.ass_attribute9                := p_ass_attribute9;
7910   l_asg_rec.ass_attribute10               := p_ass_attribute10;
7911   l_asg_rec.ass_attribute11               := p_ass_attribute11;
7912   l_asg_rec.ass_attribute12               := p_ass_attribute12;
7913   l_asg_rec.ass_attribute13               := p_ass_attribute13;
7914   l_asg_rec.ass_attribute14               := p_ass_attribute14;
7915   l_asg_rec.ass_attribute15               := p_ass_attribute15;
7916   l_asg_rec.ass_attribute16               := p_ass_attribute16;
7917   l_asg_rec.ass_attribute17               := p_ass_attribute17;
7918   l_asg_rec.ass_attribute18               := p_ass_attribute18;
7919   l_asg_rec.ass_attribute19               := p_ass_attribute19;
7920   l_asg_rec.ass_attribute20               := p_ass_attribute20;
7921   l_asg_rec.ass_attribute21               := p_ass_attribute21;
7922   l_asg_rec.ass_attribute22               := p_ass_attribute22;
7923   l_asg_rec.ass_attribute23               := p_ass_attribute23;
7924   l_asg_rec.ass_attribute24               := p_ass_attribute24;
7925   l_asg_rec.ass_attribute25               := p_ass_attribute25;
7926   l_asg_rec.ass_attribute26               := p_ass_attribute26;
7927   l_asg_rec.ass_attribute27               := p_ass_attribute27;
7928   l_asg_rec.ass_attribute28               := p_ass_attribute28;
7929   l_asg_rec.ass_attribute29               := p_ass_attribute29;
7930   l_asg_rec.ass_attribute30               := p_ass_attribute30;
7931 
7932   hr_utility.set_location('Additional Assignment Details assigned to ' ||
7933                           'record: l_asg_rec ', 40);
7934 
7935   -- ===========================================================================
7936   -- ~ Soft Coding Keyflex field
7937   -- ===========================================================================
7938   l_asg_rec.soft_coding_keyflex_id        := p_soft_coding_keyflex_id;
7939   l_hr_soft_rec.concatenated_segments     := p_soft_concat_segments;
7940   l_hr_soft_rec.segment1                  := p_scl_segment1;
7941   l_hr_soft_rec.segment2                  := p_scl_segment2;
7942   l_hr_soft_rec.segment3                  := p_scl_segment3;
7943   l_hr_soft_rec.segment4                  := p_scl_segment4;
7944   l_hr_soft_rec.segment5                  := p_scl_segment5;
7945   l_hr_soft_rec.segment6                  := p_scl_segment6;
7946   l_hr_soft_rec.segment7                  := p_scl_segment7;
7947   l_hr_soft_rec.segment8                  := p_scl_segment8;
7948   l_hr_soft_rec.segment9                  := p_scl_segment9;
7949   l_hr_soft_rec.segment10                 := p_scl_segment10;
7950   l_hr_soft_rec.segment11                 := p_scl_segment11;
7951   l_hr_soft_rec.segment12                 := p_scl_segment12;
7952   l_hr_soft_rec.segment13                 := p_scl_segment13;
7953   l_hr_soft_rec.segment14                 := p_scl_segment14;
7954   l_hr_soft_rec.segment15                 := p_scl_segment15;
7955   l_hr_soft_rec.segment16                 := p_scl_segment16;
7956   l_hr_soft_rec.segment17                 := p_scl_segment17;
7957   l_hr_soft_rec.segment18                 := p_scl_segment18;
7958   l_hr_soft_rec.segment19                 := p_scl_segment19;
7959   l_hr_soft_rec.segment20                 := p_scl_segment20;
7960   l_hr_soft_rec.segment21                 := p_scl_segment21;
7961   l_hr_soft_rec.segment22                 := p_scl_segment22;
7962   l_hr_soft_rec.segment23                 := p_scl_segment23;
7963   l_hr_soft_rec.segment24                 := p_scl_segment24;
7964   l_hr_soft_rec.segment25                 := p_scl_segment25;
7965   l_hr_soft_rec.segment26                 := p_scl_segment26;
7966   l_hr_soft_rec.segment27                 := p_scl_segment27;
7967   l_hr_soft_rec.segment28                 := p_scl_segment28;
7968   l_hr_soft_rec.segment29                 := p_scl_segment29;
7969   l_hr_soft_rec.segment30                 := p_scl_segment30;
7970 
7971   hr_utility.set_location('Soft Coding KFF segments assigned to record: ' ||
7972                           'l_hr_soft_rec ', 50);
7973 
7974   -- ===========================================================================
7975   -- ~ People Group Keyflex
7976   -- ===========================================================================
7977   l_asg_rec.people_group_id              := p_people_group_id;
7978   l_ppl_grp_rec.group_name               := p_pgrp_concat_segments;
7979   l_ppl_grp_rec.segment1                 := p_pgrp_segment1;
7980   l_ppl_grp_rec.segment2                 := p_pgrp_segment2;
7981   l_ppl_grp_rec.segment3                 := p_pgrp_segment3;
7982   l_ppl_grp_rec.segment4                 := p_pgrp_segment4;
7983   l_ppl_grp_rec.segment5                 := p_pgrp_segment5;
7984   l_ppl_grp_rec.segment6                 := p_pgrp_segment6;
7985   l_ppl_grp_rec.segment7                 := p_pgrp_segment7;
7986   l_ppl_grp_rec.segment8                 := p_pgrp_segment8;
7987   l_ppl_grp_rec.segment9                 := p_pgrp_segment9;
7988   l_ppl_grp_rec.segment10                := p_pgrp_segment10;
7989   l_ppl_grp_rec.segment11                := p_pgrp_segment11;
7990   l_ppl_grp_rec.segment12                := p_pgrp_segment12;
7991   l_ppl_grp_rec.segment13                := p_pgrp_segment13;
7992   l_ppl_grp_rec.segment14                := p_pgrp_segment14;
7993   l_ppl_grp_rec.segment15                := p_pgrp_segment15;
7994   l_ppl_grp_rec.segment16                := p_pgrp_segment16;
7995   l_ppl_grp_rec.segment17                := p_pgrp_segment17;
7996   l_ppl_grp_rec.segment18                := p_pgrp_segment18;
7997   l_ppl_grp_rec.segment19                := p_pgrp_segment19;
7998   l_ppl_grp_rec.segment20                := p_pgrp_segment20;
7999   l_ppl_grp_rec.segment21                := p_pgrp_segment21;
8000   l_ppl_grp_rec.segment22                := p_pgrp_segment22;
8001   l_ppl_grp_rec.segment23                := p_pgrp_segment23;
8002   l_ppl_grp_rec.segment24                := p_pgrp_segment24;
8003   l_ppl_grp_rec.segment25                := p_pgrp_segment25;
8004   l_ppl_grp_rec.segment26                := p_pgrp_segment26;
8005   l_ppl_grp_rec.segment27                := p_pgrp_segment27;
8006   l_ppl_grp_rec.segment28                := p_pgrp_segment28;
8007   l_ppl_grp_rec.segment29                := p_pgrp_segment29;
8008   l_ppl_grp_rec.segment30                := p_pgrp_segment30;
8009 
8010   hr_utility.set_location('People Grp KFF segments assigned to record: ' ||
8011                           'l_ppl_grp_rec ', 60);
8012 
8013   Update_StuEmpAsg_Criteria
8014   (p_effective_date => p_effective_date
8015   ,p_asg_crit_out   => l_asg_crit_out
8016    );
8017   -- If Leg. Code is US then check if the student is exempt from FICA.
8018   hr_utility.set_location('p_FICA_exempt: ' ||p_FICA_exempt, 60);
8019 
8020   IF (g_leg_code ='US' AND
8021       l_FICA_exempt IS NOT NULL )THEN
8022     Student_FICA_Status
8023     (p_assignment_id     => p_assignment_id
8024     ,p_effective_date    => p_effective_date
8025     ,p_business_group_id => p_business_group_id
8026     ,p_FICA_Status       => l_FICA_exempt);
8027   END IF;
8028   hr_utility.set_location('Leaving : ' || l_proc_name,70);
8029 
8030 EXCEPTION
8031   WHEN Others THEN
8032   hr_utility.set_location('SQLCODE :' || SQLCODE,80);
8033   l_error_msg := SQLERRM;
8034   hr_utility.set_message(8303, 'PQP_230500_HROSS_GENERIC_ERR');
8035   hr_utility.set_message_token('GENERIC_TOKEN',l_error_msg );
8036   hr_utility.set_location('Leaving: ' || l_proc_name, 80);
8037   hr_utility.raise_error;
8038 
8039 END Upd_OSS_Person_Asg;
8040 
8041 -- =============================================================================
8042 -- ~ Get_Person_Type:
8043 -- =============================================================================
8044 FUNCTION Get_Person_Type
8045         (p_person_id         IN Number
8046         ,p_business_group_id IN Number
8047         ,p_effective_date    IN Date) Return Varchar2 Is
8048 
8049 
8050   CURSOR csr_per_type (c_person_id         IN Number
8051                       ,c_business_group_id IN Number
8052                       ,c_effective_date    IN Date) IS
8053   SELECT ppt.system_person_type
8054         ,ppt.user_person_type
8055         ,ppt.person_type_id
8056     FROM per_people_f ppf
8057         ,per_person_types ppt
8058    WHERE ppt.person_type_id = ppf.person_type_id
8059      AND c_effective_date BETWEEN ppf.effective_start_date
8060                               AND ppf.effective_end_date
8061      AND ppf.person_id = c_person_id
8062      AND ppt.business_group_id = c_business_group_id
8063      AND ppf.business_group_id = ppt.business_group_id;
8064 
8065   l_return_value  Varchar(600);
8066   l_per_type_rec  csr_per_type%ROWTYPE;
8067 
8068 BEGIN
8069   l_return_value := null;
8070   OPEN csr_per_type (c_person_id         => p_person_id
8071                     ,c_business_group_id => p_business_group_id
8072                     ,c_effective_date    => p_effective_date);
8073   FETCH csr_per_type INTO l_per_type_rec;
8074   CLOSE csr_per_type;
8075 
8076   FOR per_type IN csr_per_ptu
8077                   (c_person_id         => p_person_id
8078                   ,c_business_group_id => p_business_group_id
8079                   ,c_effective_date    => p_effective_date)
8080   LOOP
8081     IF l_return_value IS NOT NULL THEN
8082       l_return_value := l_return_value ||'.'||per_type.user_person_type;
8083     ELSE
8084       l_return_value := per_type.user_person_type;
8085     END IF;
8086   END LOOP;
8087 
8088   IF l_per_type_rec.system_person_type Is Not Null AND
8089      l_per_type_rec.system_person_type = 'OTHER' THEN
8090      IF l_return_value Is Null THEN
8091         l_return_value := l_per_type_rec.user_person_type;
8092      END IF;
8093   END IF;
8094 
8095   RETURN NVL(l_return_value,'0');
8096 
8097 END Get_Person_Type;
8098 
8099 END Pqp_Hross_Integration;