Monday, June 30, 2014

API to Terminate Employee

DECLARE
   l_termination_date             DATE := TO_DATE ('01-JUN-2014');
   l_last_standard_process_date   DATE := NULL;
   l_last_std_process_date_out    DATE := NULL;
   l_supervisor_warning           BOOLEAN := NULL;
   l_event_warning                BOOLEAN := NULL;
   l_interview_warning            BOOLEAN := NULL;
   l_review_warning               BOOLEAN := NULL;
   l_recruiter_warning            BOOLEAN := NULL;
   l_asg_future_changes_warning   BOOLEAN := NULL;
   l_entries_changed_warning      VARCHAR2 (500) := NULL;
   l_pay_proposal_warning         BOOLEAN := NULL;
   l_dod_warning                  BOOLEAN := NULL;

   CURSOR c1
   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 IN (1, 2)
             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 c1
   LOOP
      BEGIN
         l_last_standard_process_date := NULL;


         hr_ex_employee_api.
          actual_termination_emp (
            p_validate                     => FALSE,
            p_effective_date               => SYSDATE,
            p_period_of_service_id         => i.period_of_service_id,
            p_object_version_number        => i.object_version_number,
            p_actual_termination_date      => l_termination_date,
            p_last_standard_process_date   => l_last_standard_process_date,
            p_attribute_category           => NULL,
            p_attribute1                   => '010',
            p_last_std_process_date_out    => l_last_std_process_date_out,
            p_supervisor_warning           => l_supervisor_warning,
            p_event_warning                => l_event_warning,
            p_interview_warning            => l_interview_warning,
            p_review_warning               => l_review_warning,
            p_recruiter_warning            => l_recruiter_warning,
            p_asg_future_changes_warning   => l_asg_future_changes_warning,
            p_entries_changed_warning      => l_entries_changed_warning,
            p_pay_proposal_warning         => l_pay_proposal_warning,
            p_dod_warning                  => l_dod_warning);
         COMMIT;

         DBMS_OUTPUT.
          put_line (
               i.person_id
            || ' has been Terminated Successfully on '
            || l_termination_date);
      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;

2 comments:

  1. Thanks it's working. But you need to be careful when to select the last termination date.

    ReplyDelete
  2. IT SHOWING THIS ERROR

    Inner Exception: 12298 ORA-06508: PL/SQL: could not find program unit being called

    ReplyDelete