Wednesday, January 4, 2017

Create Person Extra Information API (Sample Script)



DECLARE
   ln_person_extra_info_id    NUMBER;
   ln_object_version_number   NUMBER;
BEGIN
   hr_person_extra_info_api.create_person_extra_info (p_validate                      => FALSE,
                                                      p_person_id                     => 533825,
                                                      p_information_type              => 'XX_NATIONAL_IDENTIFIER',
                                                      p_pei_attribute_category        => 'Mexico',
                                                      p_pei_attribute1                => 'X12345',
                                                      p_pei_attribute2                => 'X67890',
                                                      p_pei_attribute3                => 'ABCDXYZ',
                                                      p_pei_information_category      => 'XX_NATIONAL_IDENTIFIER',
                                                      p_pei_information1              => TO_CHAR (SYSDATE - 9000, 'RRRR/MM/DD HH24:MI:SS'),
                                                      p_pei_information3              => 'Mexico',
                                                      p_person_extra_info_id          => ln_person_extra_info_id,
                                                      p_object_version_number         => ln_object_version_number
                                                     );
   COMMIT;
   DBMS_OUTPUT.put_line ('LN_PERSON_EXTRA_INFO_ID : ' || ln_person_extra_info_id);
EXCEPTION
   WHEN OTHERS
   THEN
      ROLLBACK;
      DBMS_OUTPUT.put_line (SQLERRM);

END;


Tuesday, January 3, 2017

Create Person Address API (Sample Script)


DECLARE
   ln_address_id                NUMBER;
   ln_addr_obj_version_number   NUMBER;
BEGIN
   apps.hr_person_address_api.create_person_address (
----------------------------------------------------------------
-- In Paramenters (HR_PERSON_ADDRESS_API.CREATE_PERSON_ADDRESS)
----------------------------------------------------------------
                                                     p_effective_date               => TRUNC (SYSDATE),
                                                     p_pradd_ovlapval_override      => FALSE,
                                                     p_validate_county              => TRUE,
                                                     p_person_id                    => 533285,
                                                     p_primary_flag                 => 'Y',
                                                     p_style                        => 'US',
                                                     p_date_from                    => TRUNC (SYSDATE),
                                                     p_address_line1                => '50 Main Street',
                                                     p_town_or_city                 => 'White Plains',
                                                     p_region_1                     => 'Westchester',
                                                     p_region_2                     => 'NY',
                                                     p_postal_code                  => 10601,
                                                     p_country                      => 'US',
-----------------------------------------------------------------
-- Out Paramenters (HR_PERSON_ADDRESS_API.CREATE_PERSON_ADDRESS)
-----------------------------------------------------------------
                                                     p_address_id                   => ln_address_id,
                                                     p_object_version_number        => ln_addr_obj_version_number
                                                    );
   DBMS_OUTPUT.put_line ('Address Id: ' || ln_address_id);
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('HR_PERSON_ADDRESS_API.CREATE_PERSON_ADDRESS API Error: ' || SQLERRM);

END;

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;