Monday, June 30, 2014

API to Reverse Termination

DECLARE
   CURSOR get_terminations
   IS
      SELECT pps.*
        FROM per_all_people_f per,
             per_all_assignments_f paaf,
             per_periods_of_service pps
       WHERE     per.person_id = paaf.person_id
             AND paaf.assignment_type = 'E'
             AND paaf.primary_flag = 'Y'
             AND paaf.person_id = 73691
             AND paaf.assignment_status_type_id = 3
             AND paaf.period_of_service_id = pps.period_of_service_id
             AND SYSDATE BETWEEN per.effective_start_date
                             AND per.effective_end_date
             AND SYSDATE BETWEEN paaf.effective_start_date
                             AND paaf.effective_end_date;
BEGIN
   FOR i IN get_terminations
   LOOP
      BEGIN
         hr_ex_employee_api.
          reverse_terminate_employee (
            p_validate                  => FALSE,
            p_person_id                 => i.person_id,
            p_actual_termination_date   => i.actual_termination_date,
            p_clear_details             => 'Y');
         COMMIT;

         DBMS_OUTPUT.
          put_line (
               'Termination for '
            || i.person_id
            || ' has been Reversed Successfully');
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.
             put_line ('Inner Exception: ' || i.person_id || '  ' || SQLERRM);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;



No comments:

Post a Comment