Monday, January 2, 2017

Employee / Person Creation API (Sample Script)


Person Type: APPLICANT

DECLARE
   ln_person_id                   NUMBER;
   ln_assignment_id               NUMBER;
   ln_application_id              NUMBER;
   ln_per_object_version_number   NUMBER;
   ln_asg_object_version_number   NUMBER;
   ln_apl_object_version_number   NUMBER;
   ld_per_effective_start_date    DATE;
   ld_per_effective_end_date      DATE;
   lv_full_name                   VARCHAR2 (240);
   lv_applicant_number            VARCHAR2 (240);
   ln_per_comment_id              NUMBER;
   ln_assignment_sequence         NUMBER;
   lb_name_combination_warning    BOOLEAN;
   lb_orig_hire_warning           BOOLEAN;
BEGIN
   hr_applicant_api.create_applicant (p_validate                       => FALSE,
                                      p_date_received                  => TRUNC (SYSDATE - 1),
                                      p_business_group_id              => 81,
                                      p_last_name                      => 'Lastname 11',
                                      p_person_type_id                 => 1118,
                                      p_first_name                     => 'Firstname 11',
                                      p_known_as                       => 'Person 11',
                                      p_national_identifier            => '22112233',
                                      p_applicant_number               => lv_applicant_number,
                                      p_person_id                      => ln_person_id,
                                      p_assignment_id                  => ln_assignment_id,
                                      p_application_id                 => ln_application_id,
                                      p_per_object_version_number      => ln_per_object_version_number,
                                      p_asg_object_version_number      => ln_asg_object_version_number,
                                      p_apl_object_version_number      => ln_apl_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_name_combination_warning       => lb_name_combination_warning,
                                      p_orig_hire_warning              => lb_orig_hire_warning
                                     );
   DBMS_OUTPUT.put_line ('Applicant Created: ' || lv_applicant_number);
   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);
      ROLLBACK;
END;

Person Type: EMPLOYEE

DECLARE
   ln_person_id                   NUMBER;
   ln_assignment_id               NUMBER;
   ln_per_object_version_number   NUMBER;
   ln_asg_object_version_number   NUMBER;
   ld_per_effective_start_date    DATE;
   ld_per_effective_end_date      DATE;
   lv_full_name                   VARCHAR2 (240);
   ln_per_comment_id              NUMBER;
   ln_assignment_sequence         NUMBER;
   lv_assignment_number           VARCHAR2 (10);
   lb_name_combination_warning    BOOLEAN;
   lb_assign_payroll_warning      BOOLEAN;
   lb_orig_hire_warning           BOOLEAN;
   lv_employee_number             apps.per_all_people_f.employee_number%TYPE;
BEGIN
   apps.hr_employee_api.create_employee (
--------------------------------------------------------------
-- In Paramenters (HR_EMPLOYEE_API.CREATE_EMPLOYEE)
--------------------------------------------------------------
                                         p_hire_date                      => TRUNC (SYSDATE),
                                         p_business_group_id              => 81,
                                         p_last_name                      => 'LastName 1',
                                         p_first_name                     => 'FirstName 1',
                                         --   p_title                          => 'Mr',
                                         p_middle_names                   => NULL,
                                         p_sex                            => 'M',
                                         p_person_type_id                 => 1126,
                                         p_national_identifier            => '123-45-6789',
                                         p_date_of_birth                  => TO_DATE ('01-JAN-1985', 'DD-MON-YYYY'),
                                         p_marital_status                 => 'S',
                                         p_known_as                       => 'Person 1',
--------------------------------------------------------------
-- Out Paramenters (HR_EMPLOYEE_API.CREATE_EMPLOYEE)
--------------------------------------------------------------
                                         p_employee_number                => lv_employee_number,
                                         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 ('lv_employee_number : ' || lv_employee_number);
   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      ROLLBACK;
      DBMS_OUTPUT.put_line ('HR_EMPLOYEE_API.CREATE_EMPLOYEE API Error: ' || SQLERRM);
END;

Person Type: CONTINGENT WORKER

DECLARE
   l_validate                    BOOLEAN                                      := FALSE;
   --- DECLARE variables for hr_contingent_worker_api.create_cwk
   --- IN variables
   l_hire_date                   per_all_people_f.start_date%TYPE             := TRUNC (SYSDATE);
   l_last_name                   per_all_people_f.last_name%TYPE              := 'Lastname 5';
   l_first_name                  per_all_people_f.first_name%TYPE             := 'Firstname 5';
   l_middle_names                per_all_people_f.middle_names%TYPE;
   l_sex                         per_all_people_f.sex%TYPE                    := 'M';
   l_known_as                    per_all_people_f.known_as%TYPE;
   l_date_of_birth               per_all_people_f.date_of_birth%TYPE          := TO_DATE ('11/11/1999', 'DD/MM/YYYY');
   --hr_lookups--'MARITAL_STATUS'
   l_marital_status              per_all_people_f.marital_status%TYPE         := 'S';
   l_ni_number                   per_all_people_f.national_identifier%TYPE    := 123456;
   --hr_lookups--'TITLE'
   l_title                       per_all_people_f.title%TYPE                  := 'MR.';
   l_email                       VARCHAR2 (240)                               := 'abcd@xyz.com';
   --hr_lookups--'NATIONALITY'
   l_nationality                 per_all_people_f.nationality%TYPE;                                                                                                --      := 'IN';
   l_employee_number             per_all_people_f.employee_number%TYPE;                                                                                            --    := 567890;
   l_director                    VARCHAR2 (1)                                 DEFAULT 'N';
   l_ni_multiple_asg             VARCHAR2 (1)                                 DEFAULT 'N';
   l_pensioner                   VARCHAR2 (1);
   l_business_group_id           per_business_groups.business_group_id%TYPE   := 81;
   l_person_type_id              per_person_types.person_type_id%TYPE         := 1123;
   --- OUT variables
   l_person_id                   NUMBER                                       DEFAULT NULL;
   l_assignment_id               NUMBER                                       DEFAULT NULL;
   l_per_object_version_number   NUMBER;
   l_pdp_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                   VARCHAR2 (300);
   l_comment_id                  NUMBER;
   l_assignment_sequence         NUMBER;
   l_assignment_number           VARCHAR2 (10);
   l_name_combination_warning    BOOLEAN                                      := FALSE;
--
BEGIN
   --
   hr_contingent_worker_api.create_cwk (p_validate                         => l_validate,
                                        p_start_date                       => l_hire_date,
                                        p_business_group_id                => l_business_group_id,
                                        p_last_name                        => l_last_name,
                                        p_person_type_id                   => l_person_type_id,
                                        p_npw_number                       => l_employee_number,
                                        p_background_check_status          => NULL,
                                        p_background_date_check            => NULL,
                                        p_blood_type                       => NULL,
                                        p_comments                         => NULL,
                                        p_correspondence_language          => NULL,
                                        p_country_of_birth                 => NULL,
                                        p_date_of_birth                    => l_date_of_birth,
                                        p_date_of_death                    => NULL,
                                        p_dpdnt_adoption_date              => NULL,
                                        p_dpdnt_vlntry_svce_flag           => NULL,
                                        p_email_address                    => l_email,
                                        p_first_name                       => l_first_name,
                                        p_fte_capacity                     => NULL,
                                        p_honors                           => NULL,
                                        p_internal_location                => NULL,
                                        p_known_as                         => l_known_as,
                                        p_last_medical_test_by             => NULL,
                                        p_last_medical_test_date           => NULL,
                                        p_mailstop                         => NULL,
                                        p_marital_status                   => l_marital_status,
                                        p_middle_names                     => l_middle_names,
                                        p_national_identifier              => l_ni_number,
                                        p_nationality                      => l_nationality,
                                        p_office_number                    => NULL,
                                        p_on_military_service              => NULL,
                                        p_party_id                         => NULL,
                                        p_pre_name_adjunct                 => NULL,
                                        p_previous_last_name               => NULL,
                                        p_projected_placement_end          => NULL,
                                        p_receipt_of_death_cert_date       => NULL,
                                        p_region_of_birth                  => NULL,
                                        p_registered_disabled_flag         => NULL,
                                        p_resume_exists                    => NULL,
                                        p_resume_last_updated              => NULL,
                                        p_second_passport_exists           => NULL,
                                        p_sex                              => l_sex,
                                        p_student_status                   => NULL,
                                        p_suffix                           => NULL,
                                        p_title                            => l_title,
                                        p_town_of_birth                    => NULL,
                                        p_uses_tobacco_flag                => NULL,
                                        p_vendor_id                        => NULL,
                                        p_work_schedule                    => NULL,
                                        p_work_telephone                   => NULL,
                                        p_exp_check_send_to_address        => NULL,
                                        p_hold_applicant_date_until        => NULL,
                                        p_date_employee_data_verified      => NULL,
                                        p_benefit_group_id                 => NULL,
                                        p_coord_ben_med_pln_no             => NULL,
                                        p_coord_ben_no_cvg_flag            => NULL,
                                        p_original_date_of_hire            => NULL,
                                        p_attribute_category               => NULL,
                                        p_per_information1                 => NULL,
                                        p_per_information30                => NULL,
                                        --Out Variables
                                        p_person_id                        => l_person_id,
                                        p_per_object_version_number        => l_per_object_version_number,
                                        p_per_effective_start_date         => l_per_effective_start_date,
                                        p_per_effective_end_date           => l_per_effective_end_date,
                                        p_pdp_object_version_number        => l_pdp_object_version_number,
                                        p_full_name                        => l_full_name,
                                        p_comment_id                       => l_comment_id,
                                        p_assignment_id                    => l_assignment_id,
                                        p_asg_object_version_number        => l_asg_object_version_number,
                                        p_assignment_sequence              => l_assignment_sequence,
                                        p_assignment_number                => l_assignment_number,
                                        p_name_combination_warning         => l_name_combination_warning
                                       );

   --
   IF l_name_combination_warning
   THEN
      DBMS_OUTPUT.put_line ('Warning validating API: hr_contingent_worker_api.create_cwk');
      ROLLBACK;
   ELSE
      DBMS_OUTPUT.put_line ('Contingent Worker Created: ');
      COMMIT;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Error: ' || SQLERRM);
      ROLLBACK;

END;


No comments:

Post a Comment