Thursday 14 March 2013

API to Create Employee in Oracle Applications

Oracle Application

API To Create Employee

A beginners guide: - API to create Employee
What is APIs? How to create an Employee using API?

Application Programming Interfaces (APIs) are stored procedures that enable you to insert and update data in Oracle Applications.
– HR_EMPLOYEE_API.CREATE_EMPLOYEE is a name of API to create an Employee.


Sample Code:
/*--------------------------------------------------------------------------------------------------------------------*/
DECLARE
 
 l_person_id                           PER_ALL_PEOPLE_F.PERSON_ID%TYPE;
 l_employee_number              PER_ALL_PEOPLE_F.EMPLOYEE_NUMBER%TYPE    := 'RRK_01';
 l_full_name                            PER_ALL_PEOPLE_F.FULL_NAME%TYPE;
 l_assignment_id                     PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_ID%TYPE;
 l_object_version_number      PER_ALL_ASSIGNMENTS_F.OBJECT_VERSION_NUMBER%TYPE;
 l_asg_object_version_number NUMBER;
 l_per_effective_start_date     PER_ALL_PEOPLE_F.EFFECTIVE_START_DATE%TYPE;
 l_per_effective_end_date      PER_ALL_PEOPLE_F.EFFECTIVE_END_DATE%TYPE;
 l_per_comment_id                PER_ALL_PEOPLE_F.COMMENT_ID%TYPE;
 l_assignment_seq                  PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_SEQUENCE%TYPE;
 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;

BEGIN
           hr_employee_api.create_employee
           (  
             --INPUT Parameter
               P_HIRE_DATE                      => TO_DATE('14-JUN-2012'),
               P_BUSINESS_GROUP_ID  => 101, --fnd_profile.value_specific('PER_BUSINESS_GROUP_ID'),
               P_LAST_NAME                   => 'Kesarkar',
               p_first_name                           => 'Rachana',
               p_middle_names                     => 'Ramakant',
               P_SEX                                   => 'F',
               P_NATIONAL_IDENTIFIER=> '183-25-2525',
               p_date_of_birth                      => TO_DATE('25-FEB-1990'),
               p_known_as                           => 'Rachana',
              --OUTPUT Parameter
               P_EMPLOYEE_NUMBER   => l_employee_number,
               p_person_id                           => l_person_id,
               p_assignment_id                     => l_assignment_id,
               P_PER_OBJECT_VERSION_NUMBER => l_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_seq,
               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
        );
      
        dbms_output.put_line('Employee with Employee Number: ' || l_employee_number || ' created sucessfully');
 
    COMMIT; 
END; 

/*--------------------------------------------------------------------------------------------------------------------*/

How to see the result?

Navigate to HRMS Manage -> People -> Enter and Maintain.

 

Enter the short character string to search an employee.

 

Click on Find.

 
 

 

7 comments:

  1. very nice.it will be helpful for beginners.

    ReplyDelete
  2. did we need to give fnd_global.apps_initialize and mo_global in the API ?

    ReplyDelete
  3. iam getting the below error :
    ORA-20001: FLEX-CONTEXT NOT FOUND: N, VALUE, , N, DFF, PER_PEOPLE

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. hey bro!, did you solve the problem? any solution?

      Delete
  4. http://apdba.blogspot.com/ Thanks it is very nice.

    ReplyDelete