Today we’ll give an example for ” API to create employee in oracle apps R12 “
API we are using is :- hr_employee_api.create_employee
---**** How to create an Employee ***---
- look for API called “hr_employee_api.create_employee”.
- fill parameters that are required for your business.
- declare parameter in your subprogram to handle all of the out parameter.
Note:- *there is 4 parameters that are required (p_hire_date, p_business_group_id , p_last_name, p_sex) to be filled.
*if you want to insert data through a cursor Make sure to initial “p_employee_number” to be null every iteration to avoid errors.
DECLARE V_API_ERROR VARCHAR2 (500); p_employee_number VARCHAR2 (200); V_ERROR_MSG VARCHAR2 (500) := NULL; p_person_id NUMBER; p_assignment_id NUMBER; p_per_object_version_number NUMBER; p_asg_object_version_number NUMBER; p_per_effective_start_date DATE; p_per_effective_end_date DATE; p_full_name VARCHAR2 (200); p_per_comment_id NUMBER; p_assignment_sequence NUMBER; p_assignment_number VARCHAR2 (200); p_name_combination_warning BOOLEAN; p_assign_payroll_warning BOOLEAN; p_orig_hire_warning BOOLEAN; BEGIN hr_employee_api.create_employee ( p_hire_date => TRUNC(SYSDATE), -- if you try to insert "Sysdate" only you will get an error .instade yo can pass it as String p_business_group_id => 202, --this is the defalt business group for the vision edithion of the EBS p_last_name => 'Shmes', p_first_name => 'Ahmed', -- not required p_sex => 'M', p_employee_number => p_employee_number, p_person_id => p_person_id, p_assignment_id => p_assignment_id, p_per_object_version_number => p_per_object_version_number, p_asg_object_version_number => p_asg_object_version_number, p_per_effective_start_date => p_per_effective_start_date, p_per_effective_end_date => p_per_effective_end_date, p_full_name => p_full_name, p_per_comment_id => p_per_comment_id, p_assignment_sequence => p_assignment_sequence, p_assignment_number => p_assignment_number, p_name_combination_warning => p_name_combination_warning, p_assign_payroll_warning => p_assign_payroll_warning, p_orig_hire_warning => p_orig_hire_warning); commit; DBMS_OUTPUT.PUT_LINE (p_employee_number); --To ensure that the data inserted successfully EXCEPTION WHEN OTHERS THEN V_API_ERROR := SQLERRM; V_ERROR_MSG := V_ERROR_MSG || ' ' || V_API_ERROR; END; /
After your success insertion, tray to search for your employee by his id, that you have as an output of your operating as shown below:
Regards,
Ahmed Shmes.