API to Rehire of Ex- Employees

Procedure for Rehire of Ex- Employees:

 

 

Procedure XXHR_EMP_REHIRE
as
/* =====================================================================
— NAME : XXHR_EMP_REHIRE

— PROGRAM TYPE : Procedure

— DESCRIPTION : This is used to rehire an employee
— INPUTS : None
— OUTPUTS : None
— ===================================================================*/

l_num_assg_ovn number;
— ln_assignment_id NUMBER;
l_dat_per_effective_start_date date;
l_dat_per_effective_end_date date;
l_num_assignment_sequence NUMBER;
l_bool_assign_payroll_warning boolean;
l_var_assignment_number VARCHAR2(100);
l_num_per_ovn number;
l_num_assignment_id number;
lv_err varchar2(3000);
l_num_person_id number;
l_num_object_version_number number;
l_num_discarded_records number:=0;
l_num_successful_rec number:=0;
l_num_failed_rec number:=0;
l_var_flag varchar2(100);

CURSOR c_emp
IS
SELECT LAST_NAME,
first_name,
birth_date,
euhreka_employee_number,
from_date,
process_id
from xxhr_eureh_geos_personal
where
process_flag =’EX-EMP REHIRE’;

begin
for r_emp in c_emp
loop
begin
select person_id , object_version_number
into l_num_person_id,
l_num_object_version_number
FROM per_all_people_f
WHERE first_name = r_emp.first_name
AND last_name = r_emp.last_name
AND date_of_birth = r_emp.birth_date
AND sysdate BETWEEN effective_start_date AND effective_end_date;
EXCEPTION
when others then
l_var_flag := ‘N’;
l_num_discarded_records := l_num_discarded_records +1 ;
update xxhr_eureh_geos_personal
set process_flag =’E’,
error_msg =’Employee Not found for Rehire’
where process_id = r_emp.process_id;
fnd_file.put_line(fnd_file.LOG,’Emp not found for Rehire :’||r_emp.EUHREKA_EMPLOYEE_NUMBER );
END;

l_num_per_ovn := l_num_object_version_number;
if nvl(l_var_flag, ‘Y’) = ‘Y’
then
begin
hr_employee_api.re_hire_ex_employee
( — Input data elements
— —————————–
p_validate => false,
p_hire_date => r_emp.from_date,
p_person_id => l_num_person_id,
p_rehire_reason => ‘ ‘,
— Output data elements
— ——————————–
p_assignment_id => l_num_assignment_id,
p_per_object_version_number => l_num_per_ovn,
p_asg_object_version_number => l_num_assg_ovn,
p_per_effective_start_date => l_dat_per_effective_start_date,
p_per_effective_end_date => l_dat_per_effective_end_date,
p_assignment_sequence => l_num_assignment_sequence,
p_assignment_number => l_var_assignment_number,
p_assign_payroll_warning => l_bool_assign_payroll_warning
);
l_num_SUCCESSFUL_REC := l_num_SUCCESSFUL_REC + 1;

UPDATE XXHR_EUREH_GEOS_PERSONAL
SET PROCESS_FLAG = ‘S’
where process_id = r_emp.process_id;

exception when others then
lv_err := sqlerrm;
l_num_failed_rec := l_num_failed_rec +1;
UPDATE XXHR_EUREH_GEOS_PERSONAL
SET PROCESS_FLAG = ‘E’,
error_msg = lv_err
where process_id = r_emp.process_id;
fnd_file.put_line(fnd_file.LOG,’EMp Re Hire not done for :’||r_emp.EUHREKA_EMPLOYEE_NUMBER );
end;

end if;
end loop;
DBMS_OUTPUT.put_line ( ‘ Number of successful records for Emp Rehire is’
|| l_num_successful_rec
|| ‘ , failed records is ‘
|| l_num_failed_rec
|| ‘ and discarded records is ‘
|| l_num_discarded_records
);
fnd_file.put_line (fnd_file.log,
‘Number of successful records for Emp Rehire is ‘
|| l_num_successful_rec
|| ‘ , failed records is ‘
|| l_num_failed_rec
|| ‘ and discarded records is ‘
|| l_num_discarded_records
);

END XXHR_EMP_REHIRE;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s