Tuesday, April 12, 2016

Create employee using Api hr_employee_api.create_employee

 --Firt of all create procedure
 create or replace procedure xx_create_employee
   lp_hire_date         date
  ,lp_business_group_id number
  ,lp_first_name        varchar2
  ,lp_last_name         varchar2
  ,lp_sex               varchar2
  ,lp_date_of_birth     date
  ,lp_known_as          varchar2
 l_employee_number                   per_all_people_f.employee_number%type;
 l_person_id                         per_all_people_f.person_id%type;
 l_assignment_id                     number;
 l_per_object_version_number         number;
 l_asg_object_version_number         number;
 l_per_effective_start_date          date;
 l_per_effective_end_date            date;
 l_full_name                         per_all_people_f.full_name%type;
 l_per_comment_id                    number;
 l_assignment_sequence               number;
 l_assignment_number                 per_all_assignments_f.assignment_number%type;
 l_name_combination_warning          boolean;
 l_assign_payroll_warning            boolean;
 l_orig_hire_warning                 boolean;

--Input data--
   p_hire_date                   => lp_hire_date
  ,p_business_group_id           => lp_business_group_id
  ,p_last_name                   => lp_last_name
  ,p_sex                         => lp_sex
  ,p_first_name                  => lp_first_name
  ,p_middle_names                => null
  ,p_date_of_birth               => lp_date_of_birth
  ,p_known_as                    => lp_known_as
--Output Date--                
 ,p_employee_number              => l_employee_number
 ,p_person_id                    => l_person_id
 ,p_assignment_id                => l_assignment_id
 ,p_per_object_version_number    => l_per_object_version_number
 ,p_asg_object_version_number    => l_asg_object_version_number
 ,p_per_effective_start_date     => l_per_effective_start_date
 ,p_per_effective_end_date       => l_per_effective_end_date
 ,p_full_name                    => l_full_name
 ,p_per_comment_id               => l_per_comment_id 
 ,p_assignment_sequence          => l_assignment_sequence
 ,p_assignment_number            => l_assignment_number
 ,p_name_combination_warning     => l_name_combination_warning
 ,p_assign_payroll_warning       => l_assign_payroll_warning
 ,p_orig_hire_warning            => l_orig_hire_warning
) ;

--Execute procedure --
exec xx_create_employee(TO_DATE('01-JUN-2011'), 626, 'Celin','Deon', 'F',  TO_DATE('08-JUN-1991'), 'Celin');

--select created employee from table  to make sure it saved successfully --
select known_as, employee_number from per_all_people_f
where initcap(known_as) = 'Celin';

1 comment:

  1. I am getting below exception.

    Error starting at line : 3 in command -
    BEGIN xx_create_employee(TO_DATE('01-JUN-2011'), 626, 'Celin','Deon', 'F', TO_DATE('08-JUN-1991'), 'Celin'); END;
    Error report -
    ORA-01403: no data found
    ORA-06512: at "APPS.HR_EMPLOYEE_API", line 1034
    ORA-06512: at "APPS.XX_CREATE_EMPLOYEE", line 28
    ORA-06512: at line 1
    01403. 00000 - "no data found"
    *Cause: No data was found from the objects.
    *Action: There was no data from the objects which may be due to end of fetch.