Friday, May 29, 2020

API to create Employee in Oracle Apps R12 (HR_EMPLOYEE_API.CREATE_EMPLOYEE)











            In this post, we have given a script to create an employee in R12 instance.

API: HR_EMPLOYEE_API.CREATE_EMPLOYEE

Instance: R12

Script:

DECLARE 
  ln_person_id                 NUMBER;
  ln_assignment_id             per_all_assignments_f.assignment_id%TYPE;
  ln_per_object_version_number per_all_people_f.object_version_number%TYPE;
  ln_asg_object_version_number per_all_assignments_f.object_version_number%TYPE;
  ld_per_effective_start_date  per_all_people_f.effective_start_date%TYPE;
  ld_per_effective_end_date    per_all_people_f.effective_end_date%TYPE;
  lv_full_name                 per_all_people_f.full_name%TYPE;
  ln_per_comment_id            per_all_people_f.comment_id%TYPE;
  ln_assignment_sequence       per_all_assignments_f.assignment_sequence%TYPE;
  lv_assignment_number         per_all_assignments_f.assignment_number%TYPE;
  lv_employee_number           VARCHAR2(200) DEFAULT '1234567';
  lb_name_combination_warning  BOOLEAN;
  lb_assign_payroll_warning    BOOLEAN;
  lb_orig_hire_warning         BOOLEAN;
BEGIN
  HR_EMPLOYEE_API.CREATE_EMPLOYEE
        (
         -- IN parameters
         p_validate                  => FALSE,
         p_hire_date                 => SYSDATE,
         p_business_group_id         => 81, --from per_business_groups_perf
         p_last_name                 => 'SHARE',
         p_middle_names              => 'ORACLE',  
         p_sex                       => 'M',
         p_person_type_id            => NULL,
         p_email_address             => 'test@shareoracleapps.com',
         p_first_name                => 'APPS',
         p_employee_number           => lv_employee_number,
         -- OUT parameters                                         
         p_person_id                 => ln_person_id,
         p_assignment_id             => ln_assignment_id,
         p_per_object_version_number => ln_per_object_version_number,
         p_asg_object_version_number => ln_asg_object_version_number,
         p_per_effective_start_date  => ld_per_effective_start_date,
         p_per_effective_end_date    => ld_per_effective_end_date,
         p_full_name                 => lv_full_name,
         p_per_comment_id            => ln_per_comment_id,
         p_assignment_sequence       => ln_assignment_sequence,
         p_assignment_number         => lv_assignment_number,
         p_name_combination_warning  => lb_name_combination_warning,
         p_assign_payroll_warning    => lb_assign_payroll_warning,
         p_orig_hire_warning         => lb_orig_hire_warning
      );      
        
  DBMS_OUTPUT.PUT_LINE('p_employee_number '|| lv_employee_number);
  DBMS_OUTPUT.PUT_LINE('p_person_id '|| ln_person_id);
  DBMS_OUTPUT.PUT_LINE('p_assignment_id '|| ln_assignment_id);
  DBMS_OUTPUT.PUT_LINE('p_per_object_version_number '|| ln_per_object_version_number);
  DBMS_OUTPUT.PUT_LINE('p_asg_object_version_number '|| ln_asg_object_version_number);
  DBMS_OUTPUT.PUT_LINE('p_per_effective_start_date '|| ld_per_effective_start_date);
  DBMS_OUTPUT.PUT_LINE('p_per_effective_end_date '|| ld_per_effective_end_date);
  DBMS_OUTPUT.PUT_LINE('p_full_name '|| lv_full_name);
  DBMS_OUTPUT.PUT_LINE('p_per_comment_id '|| ln_per_comment_id);
  DBMS_OUTPUT.PUT_LINE('p_assignment_sequence '|| ln_assignment_sequence);
  DBMS_OUTPUT.PUT_LINE('p_assignment_number '|| lv_assignment_number);
       
END;

Output:

p_employee_number 1234567 p_person_id 12345 p_assignment_id 130 p_per_object_version_number 2 p_asg_object_version_number 1 p_per_effective_start_date 29-MAY-20 p_per_effective_end_date 31-DEC-12 p_full_name SHARE, APPS ORACLE p_per_comment_id p_assignment_sequence p_assignment_number 1234567

2 Responses to “API to create Employee in Oracle Apps R12 (HR_EMPLOYEE_API.CREATE_EMPLOYEE)”

wisewitch said...
May 29, 2020 at 10:15 AM

Handy API Script. Thank you!!


RahmanAjani said...
February 5, 2021 at 7:18 AM

lv_employee_number VARCHAR2(200) DEFAULT '1234567'; must be written without the default value else you will encounter an error message.


Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.