DECLARE
lc_employee_number PER_ALL_PEOPLE_F.EMPLOYEE_NUMBER%TYPE;
ln_person_id PER_ALL_PEOPLE_F.PERSON_ID%TYPE;
ln_assignment_id PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_ID%TYPE;
ln_object_ver_number PER_ALL_ASSIGNMENTS_F.OBJECT_VERSION_NUMBER%TYPE;
ln_asg_ovn NUMBER;
ld_per_effective_start_date PER_ALL_PEOPLE_F.EFFECTIVE_START_DATE%TYPE;
ld_per_effective_end_date PER_ALL_PEOPLE_F.EFFECTIVE_END_DATE%TYPE;
lc_full_name PER_ALL_PEOPLE_F.FULL_NAME%TYPE;
ln_per_comment_id PER_ALL_PEOPLE_F.COMMENT_ID%TYPE;
ln_assignment_sequence PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_SEQUENCE%TYPE;
lc_assignment_number PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_NUMBER%TYPE;
lb_name_combination_warning BOOLEAN;
lb_assign_payroll_warning BOOLEAN;
lb_orig_hire_warning BOOLEAN;
l_count NUMBER := 0;
l_error NUMBER;
l_error_msg VARCHAR2 (4000);
CURSOR c1
IS
SELECT employee_id,
(SELECT PERSON_TYPE_ID
FROM PER_PERSON_TYPES
WHERE USER_PERSON_TYPE = employee_type
AND BUSINESS_GROUP_ID = 82)
employee_type,
(CASE
WHEN title = 'Mr.' THEN 'MR.'
WHEN title = 'Ms.' THEN 'MS.'
END)
title,
first_name,
last_name,
middle_name,
national_identifier_,
to_char(TO_DATE (date_of_birth, 'DD-MON-RRRR') , 'DD-MON-RRRR') date_of_birth,
to_char(TO_DATE (hire_date, 'DD-MON-RRRR'), 'DD-MON-RRRR') hire_date,
(SELECT TERRITORY_CODE
FROM FND_TERRITORIES_VL
WHERE TERRITORY_SHORT_NAME = country_of_birth)
country_of_birth,
email_id,
(SELECT LOOKUP_CODE
FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'NATIONALITY'
and LANGUAGE = 'US'
AND MEANING = nationality)
nationality,
(CASE
WHEN marital_status = 'Married' THEN 'M'
WHEN marital_status = 'Single' THEN 'S'
WHEN marital_status = 'Divorced' THEN 'D'
WHEN marital_status = 'Widowed' THEN 'W'
END)
marital_status,
(CASE
WHEN gender = 'Male' THEN 'M'
WHEN gender = 'Female' THEN 'F'
END)
gender,
process_flag,
process_message
FROM XXHRL_MY_EMPLOYEE_MASTER
WHERE NVL (process_flag, 'N') = 'N';
BEGIN
FOR i IN c1
LOOP
BEGIN
DBMS_OUTPUT.put_line ('In Loop');
l_error := 0;
lc_employee_number := i.employee_id;
hr_employee_api.create_employee (
-- ------------------------------
p_hire_date => i.hire_date,
p_business_group_id => 82,
p_last_name => i.last_name,
p_first_name => i.first_name,
p_person_type_id => i.employee_type,
p_sex => i.gender,
p_national_identifier => i.national_identifier_,
p_date_of_birth => i.date_of_birth,
p_marital_status => i.marital_status,
p_email_address => i.email_id,
p_nationality => i.nationality,
p_title => i.title,
p_country_of_birth => i.country_of_birth,
-- Output parameters
p_employee_number => lc_employee_number,
p_person_id => ln_person_id,
p_assignment_id => ln_assignment_id,
p_per_object_version_number => ln_object_ver_number,
p_asg_object_version_number => ln_asg_ovn,
p_per_effective_start_date => ld_per_effective_start_date,
p_per_effective_end_date => ld_per_effective_end_date,
p_full_name => lc_full_name,
p_per_comment_id => ln_per_comment_id,
p_assignment_sequence => ln_assignment_sequence,
p_assignment_number => lc_assignment_number,
p_name_combination_warning => lb_name_combination_warning,
p_assign_payroll_warning => lb_assign_payroll_warning,
p_orig_hire_warning => lb_orig_hire_warning
);
l_count := l_count + 1;
DBMS_OUTPUT.put_line ('Employee loaded # ' || l_count || 'Person Id :' || ln_person_id);
UPDATE XXHRL_MY_EMPLOYEE_MASTER
SET process_flag = 'Y', process_message = 'Loaded'
WHERE employee_id = i.employee_id;
EXCEPTION
WHEN OTHERS
THEN
l_error := 1;
l_error_msg := 'Exception ' || SQLERRM;
DBMS_OUTPUT.put_line (SQLERRM);
END;
IF l_error = 1
THEN
UPDATE XXHRL_MY_EMPLOYEE_MASTER
SET process_flag = 'N', process_message = l_error_msg --SUBSTR (l_error_msg, 3999)
WHERE employee_id = i.employee_id;
END IF;
l_error := 0;
l_error_msg := NULL;
END LOOP;
--COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLERRM);
END;
/
0 Comments