DECLARE
v_api_error VARCHAR2 (5000);
v_error_msg VARCHAR2 (5000) := NULL;
p_nationality VARCHAR2 (200);
p_person_type_id NUMBER;
p_employee_number NUMBER;
p_person_id NUMBER;
p_assignment_id NUMBER;
p_per_object_version_number NUMBER;
p_asg_object_version_number NUMBER;
p_per_effective_start_date DATE;
p_per_effective_end_date DATE;
p_full_name VARCHAR2 (150);
p_per_comment_id NUMBER;
p_assignment_sequence NUMBER;
p_assignment_number VARCHAR2 (100);
p_name_combination_warning BOOLEAN;
p_assign_payroll_warning BOOLEAN;
p_orig_hire_warning BOOLEAN;
p_business_group_id NUMBER;
p_object_version_number NUMBER;
p_validate BOOLEAN;
p_effective_date DATE;
p_effective_start_date DATE;
p_effective_end_date DATE;
p_comment_id NUMBER;
p_emp_num VARCHAR2 (50);
BEGIN
FOR hr_data IN (SELECT xx.*
FROM xx_hr_upload_master_data_new xx)
LOOP
BEGIN
hr_employee_api.create_employee
(p_title => UPPER (hr_data.title),
p_email_address => hr_data.email_address,
p_person_type_id => hr_data.person_type_id,
p_attribute3 => hr_data.social_insurance,
p_nationality => UPPER
(TRIM (hr_data.nationality)
),
p_hire_date => hr_data.hire_date,
p_business_group_id => TO_NUMBER
(hr_data.business_group_id),
p_last_name => trim(NVL (hr_data.last_name, '0')),
p_sex => hr_data.gender,
p_first_name => trim(hr_data.first_name),
p_date_of_birth => hr_data.date_of_birth,
p_employee_number => hr_data.employee_number,
p_marital_status => hr_data.marital_status,
p_middle_names => trim(hr_data.middle_names),
p_national_identifier => TO_NUMBER
(hr_data.national_identifier
),
p_previous_last_name => hr_data.ar_name,
p_pre_name_adjunct => NULL,
p_attribute_category => 'EMP',
p_town_of_birth => hr_data.town_of_birth,
-- p_region_of_birth => hr_data.governerate,
p_per_information_category => 'EG',
p_per_information1 => 'EG',
p_per_information2 => 'Cairo',
p_per_information3 => 'Na',
p_person_id => p_person_id,
p_assignment_id => p_assignment_id,
p_per_object_version_number => p_per_object_version_number,
p_asg_object_version_number => p_asg_object_version_number,
p_per_effective_start_date => p_per_effective_start_date,
p_per_effective_end_date => p_per_effective_end_date,
p_full_name => p_full_name,
p_per_comment_id => p_per_comment_id,
p_assignment_sequence => p_assignment_sequence,
p_assignment_number => p_assignment_number,
p_name_combination_warning => p_name_combination_warning,
p_assign_payroll_warning => p_assign_payroll_warning,
p_orig_hire_warning => p_orig_hire_warning
);
BEGIN
UPDATE xx_hr_upload_master_data_new
SET emp_data = 'Done',
error_msg = 'Done',
person_id = p_person_id
WHERE employee_number = hr_data.employee_number;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
EXCEPTION
WHEN OTHERS
THEN
v_api_error := NULL;
v_error_msg := NULL;
v_api_error := SQLERRM;
v_error_msg := v_error_msg || ' ' || v_api_error;
p_person_id := NULL;
UPDATE xx_hr_upload_master_data_new
SET error_msg = v_error_msg,
emp_data = 'T_Error'
WHERE employee_number = hr_data.employee_number;
COMMIT;
END;
/*
BEGIN
p_emp_num := hr_data.employee_number;
p_validate := FALSE;
p_effective_date := TRUNC (SYSDATE);
SELECT person_id, object_version_number
INTO p_person_id, p_object_version_number
FROM per_all_people_f
WHERE employee_number = hr_data.employee_number
AND effective_end_date > SYSDATE
AND business_group_id = hr_data.business_group_id;
hr_person_api.update_person
(p_email_address => hr_data.email_address,
p_title => UPPER (hr_data.title),
p_person_type_id => hr_data.person_type_id,
p_attribute3 => hr_data.social_insurance,
p_nationality => UPPER
(TRIM
(hr_data.nationality
)
),
p_validate => p_validate,
p_effective_date => p_effective_date,
p_datetrack_update_mode => 'CORRECTION',
p_person_id => p_person_id,
p_object_version_number => p_object_version_number,
p_employee_number => p_emp_num,
p_full_name => p_full_name,
p_effective_start_date => p_effective_start_date,
p_effective_end_date => p_effective_end_date,
p_comment_id => p_comment_id,
p_name_combination_warning => p_name_combination_warning,
p_assign_payroll_warning => p_assign_payroll_warning,
p_orig_hire_warning => p_orig_hire_warning
);
EXCEPTION
WHEN OTHERS
THEN
p_emp_num := NULL;
p_validate := NULL;
p_effective_date := NULL;
p_person_id := NULL;
p_effective_start_date := NULL;
p_effective_end_date := NULL;
p_comment_id := NULL;
END;
*/
v_api_error VARCHAR2 (5000);
v_error_msg VARCHAR2 (5000) := NULL;
p_nationality VARCHAR2 (200);
p_person_type_id NUMBER;
p_employee_number NUMBER;
p_person_id NUMBER;
p_assignment_id NUMBER;
p_per_object_version_number NUMBER;
p_asg_object_version_number NUMBER;
p_per_effective_start_date DATE;
p_per_effective_end_date DATE;
p_full_name VARCHAR2 (150);
p_per_comment_id NUMBER;
p_assignment_sequence NUMBER;
p_assignment_number VARCHAR2 (100);
p_name_combination_warning BOOLEAN;
p_assign_payroll_warning BOOLEAN;
p_orig_hire_warning BOOLEAN;
p_business_group_id NUMBER;
p_object_version_number NUMBER;
p_validate BOOLEAN;
p_effective_date DATE;
p_effective_start_date DATE;
p_effective_end_date DATE;
p_comment_id NUMBER;
p_emp_num VARCHAR2 (50);
BEGIN
FOR hr_data IN (SELECT xx.*
FROM xx_hr_upload_master_data_new xx)
LOOP
BEGIN
hr_employee_api.create_employee
(p_title => UPPER (hr_data.title),
p_email_address => hr_data.email_address,
p_person_type_id => hr_data.person_type_id,
p_attribute3 => hr_data.social_insurance,
p_nationality => UPPER
(TRIM (hr_data.nationality)
),
p_hire_date => hr_data.hire_date,
p_business_group_id => TO_NUMBER
(hr_data.business_group_id),
p_last_name => trim(NVL (hr_data.last_name, '0')),
p_sex => hr_data.gender,
p_first_name => trim(hr_data.first_name),
p_date_of_birth => hr_data.date_of_birth,
p_employee_number => hr_data.employee_number,
p_marital_status => hr_data.marital_status,
p_middle_names => trim(hr_data.middle_names),
p_national_identifier => TO_NUMBER
(hr_data.national_identifier
),
p_previous_last_name => hr_data.ar_name,
p_pre_name_adjunct => NULL,
p_attribute_category => 'EMP',
p_town_of_birth => hr_data.town_of_birth,
-- p_region_of_birth => hr_data.governerate,
p_per_information_category => 'EG',
p_per_information1 => 'EG',
p_per_information2 => 'Cairo',
p_per_information3 => 'Na',
p_person_id => p_person_id,
p_assignment_id => p_assignment_id,
p_per_object_version_number => p_per_object_version_number,
p_asg_object_version_number => p_asg_object_version_number,
p_per_effective_start_date => p_per_effective_start_date,
p_per_effective_end_date => p_per_effective_end_date,
p_full_name => p_full_name,
p_per_comment_id => p_per_comment_id,
p_assignment_sequence => p_assignment_sequence,
p_assignment_number => p_assignment_number,
p_name_combination_warning => p_name_combination_warning,
p_assign_payroll_warning => p_assign_payroll_warning,
p_orig_hire_warning => p_orig_hire_warning
);
BEGIN
UPDATE xx_hr_upload_master_data_new
SET emp_data = 'Done',
error_msg = 'Done',
person_id = p_person_id
WHERE employee_number = hr_data.employee_number;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
EXCEPTION
WHEN OTHERS
THEN
v_api_error := NULL;
v_error_msg := NULL;
v_api_error := SQLERRM;
v_error_msg := v_error_msg || ' ' || v_api_error;
p_person_id := NULL;
UPDATE xx_hr_upload_master_data_new
SET error_msg = v_error_msg,
emp_data = 'T_Error'
WHERE employee_number = hr_data.employee_number;
COMMIT;
END;
/*
BEGIN
p_emp_num := hr_data.employee_number;
p_validate := FALSE;
p_effective_date := TRUNC (SYSDATE);
SELECT person_id, object_version_number
INTO p_person_id, p_object_version_number
FROM per_all_people_f
WHERE employee_number = hr_data.employee_number
AND effective_end_date > SYSDATE
AND business_group_id = hr_data.business_group_id;
hr_person_api.update_person
(p_email_address => hr_data.email_address,
p_title => UPPER (hr_data.title),
p_person_type_id => hr_data.person_type_id,
p_attribute3 => hr_data.social_insurance,
p_nationality => UPPER
(TRIM
(hr_data.nationality
)
),
p_validate => p_validate,
p_effective_date => p_effective_date,
p_datetrack_update_mode => 'CORRECTION',
p_person_id => p_person_id,
p_object_version_number => p_object_version_number,
p_employee_number => p_emp_num,
p_full_name => p_full_name,
p_effective_start_date => p_effective_start_date,
p_effective_end_date => p_effective_end_date,
p_comment_id => p_comment_id,
p_name_combination_warning => p_name_combination_warning,
p_assign_payroll_warning => p_assign_payroll_warning,
p_orig_hire_warning => p_orig_hire_warning
);
EXCEPTION
WHEN OTHERS
THEN
p_emp_num := NULL;
p_validate := NULL;
p_effective_date := NULL;
p_person_id := NULL;
p_effective_start_date := NULL;
p_effective_end_date := NULL;
p_comment_id := NULL;
END;
*/