Thursday, January 16, 2014

API to Create Employee Establishments / School or College

CREATE OR REPLACE PROCEDURE xxxx_emp_establishment_p
IS
   CURSOR get_details
   IS
      SELECT *
        FROM xxxx_emp_establishment_t
       WHERE process_flag = 'N';

   l_err_msg                 VARCHAR2 (500) := NULL;
   l_attendance_id           NUMBER := NULL;
   l_object_version_number   NUMBER := NULL;
BEGIN
   --Initialize Session
   fnd_global.
    apps_initialize (user_id => 2234,                        -- XXXX_MIGRATION
                                     resp_id => 50637,    -- XXXX HRMS Manager
                                                      resp_appl_id => 800 -- Human Resouces
                                                                         );

   FOR fetch_details IN get_details
   LOOP
      l_err_msg := NULL;
      l_attendance_id := NULL;
      l_object_version_number := NULL;


      BEGIN
         per_estab_attendances_api.
          create_attended_estab (
            p_validate                => FALSE,
            p_effective_date          => SYSDATE,
            p_fulltime                => 'N',
            p_attended_start_date     => fetch_details.edu_start_dt,
            p_attended_end_date       => fetch_details.edu_end_dt,
            p_business_group_id       => l_business_group_id_gl,
            p_person_id               => fetch_details.person_id,
            p_establishment_id        => fetch_details.establishment_id,
            p_attendance_id           => l_attendance_id,
            p_object_version_number   => l_object_version_number);

         UPDATE xxxx_emp_establishment_t edu
            SET edu.process_flag = 'Y', edu.err_msg = NULL
          WHERE edu.oracle_employee_number =
                   fetch_details.oracle_employee_number;

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_err_msg := SQLERRM;

            UPDATE xxxx_emp_establishment_t edu
               SET edu.process_flag = 'N', err_msg = l_err_msg
             WHERE edu.oracle_employee_number =
                      fetch_details.oracle_employee_number;

            COMMIT;
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      l_err_msg := SQLERRM;
      DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);

END xxxx_emp_establishment_p;

No comments:

Post a Comment