-- Local Variables
-- -----------------------
lc_dt_ud_mode VARCHAR2(100) := NULL;
ln_assignment_id NUMBER := 18546;
ln_supervisor_id NUMBER := 14024;
ln_object_number NUMBER := 3;
ln_people_group_id NUMBER /*:= 1*/;
-- Out Variables for Find Date Track Mode API
-- -----------------------------------------------------------------
lb_correction BOOLEAN;
lb_update BOOLEAN;
lb_update_override BOOLEAN;
lb_update_change_insert BOOLEAN;
-- Out Variables for Update Employee Assignment API
-- ----------------------------------------------------------------------------
ln_soft_coding_keyflex_id HR_SOFT_CODING_KEYFLEX.SOFT_CODING_KEYFLEX_ID%TYPE;
lc_concatenated_segments VARCHAR2(2000);
ln_comment_id PER_ALL_ASSIGNMENTS_F.COMMENT_ID%TYPE;
lb_no_managers_warning BOOLEAN;
ln_special_ceiling_step_id PER_ALL_ASSIGNMENTS_F.SPECIAL_CEILING_STEP_ID%TYPE;
lc_group_name VARCHAR2(30);
ld_effective_start_date PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE%TYPE;
ld_effective_end_date PER_ALL_ASSIGNMENTS_F.EFFECTIVE_END_DATE%TYPE;
lb_org_now_no_manager_warning BOOLEAN;
lb_other_manager_warning BOOLEAN;
lb_spp_delete_warning BOOLEAN;
lc_entries_changed_warning VARCHAR2(30);
lb_tax_district_changed_warn BOOLEAN;
l_effective_date date;
l_emp_hire_date date;
l_sup_hire_date date;
l_person_id number;
BEGIN
for i in (select af.assignment_id,
af.effective_start_date,
af.object_version_number,
p.person_id supervisor_id,
af.person_id
from xxcorp_emp_sup es,
(select distinct person_id,
to_number(employee_number) employee_number
from per_people_f) p,
(select * from (
select af.person_id,
af.effective_start_date,
af.assignment_id,
af.object_version_number,
row_number() over (partition by af.person_id order by af.effective_start_date desc) row_id
from PER_ALL_ASSIGNMENTS_F af
) where row_id=1) af
where
es.person_id=af.person_id
and es.status is null
and es.supervisor_num=p.employee_number
--and es.person_id=1236
)
loop
ln_assignment_id := i.assignment_id;
ln_supervisor_id := i.supervisor_id;
ln_object_number := i.object_version_number;
l_effective_date := i.effective_start_date;
select hire_date into l_emp_hire_date from xxbak_employees_hire_date where person_id= i.person_id;
select hire_date into l_sup_hire_date from xxbak_employees_hire_date where person_id= i.supervisor_id;
if l_emp_hire_date < l_sup_hire_date then
lc_dt_ud_mode := 'UPDATE';
else
lc_dt_ud_mode := 'CORRECTION';
end if;
if l_sup_hire_date > l_effective_date
then l_effective_date := l_sup_hire_date;
end if;
if l_emp_hire_date < l_sup_hire_date then
lc_dt_ud_mode := 'UPDATE';
else lc_dt_ud_mode := 'CORRECTION';
end if;
select decode(lc_dt_ud_mode,'UPDATE',l_effective_date+1,l_effective_date) into l_effective_date from dual;
-- Update Employee Assignment
-- ---------------------------------------------
l_person_id := i.person_id;
begin
-- DBMS_OUTPUT.put_line(lc_dt_ud_mode);
hr_assignment_api .update_emp_asg
( -- Input data elements
-- ------------------------------
p_effective_date => l_effective_date+1,
p_datetrack_update_mode => lc_dt_ud_mode,
p_assignment_id => ln_assignment_id,
p_supervisor_id => ln_supervisor_id,
p_change_reason => NULL,
-- p_manager_flag => 'N',
p_bargaining_unit_code => NULL,
p_labour_union_member_flag => NULL,
p_ass_attribute1 =>92,
-- p_segment1 => 204,
-- p_segment3 => 'N',
-- p_normal_hours => 10,
-- p_frequency => 'W',
-- Output data elements
-- -------------------------------
p_object_version_number => ln_object_number,
p_soft_coding_keyflex_id => ln_soft_coding_keyflex_id,
p_concatenated_segments => lc_concatenated_segments,
p_comment_id => ln_comment_id,
p_effective_start_date => ld_effective_start_date,
p_effective_end_date => ld_effective_end_date,
p_no_managers_warning => lb_no_managers_warning,
p_other_manager_warning => lb_other_manager_warning
);
update xxcorp_emp_sup s set status='Y' where s.person_id=l_person_id;
EXCEPTION
WHEN OTHERS THEN
-- ROLLBACK;
dbms_output.put_line(l_person_id);
DBMS_OUTPUT.put_line(lc_dt_ud_mode);
dbms_output.put_line(SQLERRM);
-- update xxcorp_emp_sup s set status= where s.person_id=l_person_id;
end;
end loop;
--COMMIT;
END;
No comments:
Post a Comment