***This API used to update the element entry values at assignment level.
DECLARE
l_effective_start_date DATE :=null;
l_effective_end_date DATE :=null;
l_update_warning BOOLEAN;
l_element_type_id NUMBER := NULL;
l_input_stop_salary_id NUMBER := NULL;
ln_element_link_id NUMBER;
l_effective_date date;
l_object_version_number number;
l_element_entry_id number;
cursor c1 is
select pf.person_id,
xx.employee_number,
xx.salary,
pfpf.assignment_id,
pfpf.business_group_id
from xx_emp_basic_sal xx,
per_all_people_f pf,
per_all_assignments_f pfpf
where 1=1
and xx.employee_number = pf.employee_number
and pf.person_id = pfpf.person_id
-- AND pf.employee_number ='1032625'
and xx.status is null ;
BEGIN
-- Get Element Type ID
SELECT element_type_id
INTO l_element_type_id
FROM pay_element_types_f_tl
WHERE element_name = 'Basic Salary';
-- Get Input Value ID
SELECT pivt.input_value_id
INTO l_input_stop_salary_id
FROM pay_input_values_f piv, pay_input_values_f_tl pivt
WHERE 1 = 1
AND piv.element_type_id = l_element_type_id
AND piv.input_value_id = pivt.input_value_id
AND pivt.NAME = 'Monthly Amount';
FOR i IN c1
LOOP
l_element_entry_id :=null;
l_effective_date :=null;
l_object_version_number :=null;
SELECT element_entry_id ,EFFECTIVE_START_DATE,OBJECT_VERSION_NUMBER
into l_element_entry_id ,l_effective_date,l_object_version_number
FROM pay_element_entries_f peef
where 1=1
and assignment_id =i.assignment_id
and element_link_id =84;
BEGIN
pay_element_entry_api.
update_element_entry (
p_validate => FALSE,
p_datetrack_update_mode => 'CORRECTION',
p_effective_date => l_effective_date,
p_business_group_id => 82,
p_element_entry_id => l_element_entry_id ,
p_object_version_number => l_object_version_number,
p_input_value_id1 => l_input_stop_salary_id,
p_entry_value1 => i.salary,
p_effective_start_date => l_effective_start_date,
p_effective_end_date => l_effective_end_date,
p_update_warning => l_update_warning);
COMMIT;
DBMS_OUTPUT.
put_line ('Element Entry has been Updated: ' || l_element_entry_id);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.
put_line (
'Inner Exception: ' || SQLERRM || ' - ' || l_element_entry_id);
END;
update xx_emp_basic_sal
set status ='UPDATED'
where employee_number = i.employee_number ;
commit;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;
DECLARE
l_effective_start_date DATE :=null;
l_effective_end_date DATE :=null;
l_update_warning BOOLEAN;
l_element_type_id NUMBER := NULL;
l_input_stop_salary_id NUMBER := NULL;
ln_element_link_id NUMBER;
l_effective_date date;
l_object_version_number number;
l_element_entry_id number;
cursor c1 is
select pf.person_id,
xx.employee_number,
xx.salary,
pfpf.assignment_id,
pfpf.business_group_id
from xx_emp_basic_sal xx,
per_all_people_f pf,
per_all_assignments_f pfpf
where 1=1
and xx.employee_number = pf.employee_number
and pf.person_id = pfpf.person_id
-- AND pf.employee_number ='1032625'
and xx.status is null ;
BEGIN
-- Get Element Type ID
SELECT element_type_id
INTO l_element_type_id
FROM pay_element_types_f_tl
WHERE element_name = 'Basic Salary';
-- Get Input Value ID
SELECT pivt.input_value_id
INTO l_input_stop_salary_id
FROM pay_input_values_f piv, pay_input_values_f_tl pivt
WHERE 1 = 1
AND piv.element_type_id = l_element_type_id
AND piv.input_value_id = pivt.input_value_id
AND pivt.NAME = 'Monthly Amount';
FOR i IN c1
LOOP
l_element_entry_id :=null;
l_effective_date :=null;
l_object_version_number :=null;
SELECT element_entry_id ,EFFECTIVE_START_DATE,OBJECT_VERSION_NUMBER
into l_element_entry_id ,l_effective_date,l_object_version_number
FROM pay_element_entries_f peef
where 1=1
and assignment_id =i.assignment_id
and element_link_id =84;
BEGIN
pay_element_entry_api.
update_element_entry (
p_validate => FALSE,
p_datetrack_update_mode => 'CORRECTION',
p_effective_date => l_effective_date,
p_business_group_id => 82,
p_element_entry_id => l_element_entry_id ,
p_object_version_number => l_object_version_number,
p_input_value_id1 => l_input_stop_salary_id,
p_entry_value1 => i.salary,
p_effective_start_date => l_effective_start_date,
p_effective_end_date => l_effective_end_date,
p_update_warning => l_update_warning);
COMMIT;
DBMS_OUTPUT.
put_line ('Element Entry has been Updated: ' || l_element_entry_id);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.
put_line (
'Inner Exception: ' || SQLERRM || ' - ' || l_element_entry_id);
END;
update xx_emp_basic_sal
set status ='UPDATED'
where employee_number = i.employee_number ;
commit;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;
No comments:
Post a Comment