Showing posts with label HRMS. Show all posts
Showing posts with label HRMS. Show all posts

Sunday, December 29, 2024

Query to get Employee Absence details in Oracle APPS

SELECT /*+ rule*/
       paaf.person_id
  ,paaf.assignment_id
  ,flv.meaning absence_category
  ,c.name absence_type
  ,flv1.meaning absence_reason
  ,abs.date_notification
  ,abs.date_projected_start
  ,abs.date_projected_end
  ,abs.date_start
  ,abs.date_end
  ,abs.absence_days
  ,abs.attribute1
  ,abs.attribute2
  ,abs.attribute3
  ,abs.attribute4
  ,abs.attribute5
  ,abs.attribute6
  ,abs.attribute7
  ,abs.attribute8
  ,abs.attribute9
  ,abs.attribute10
  ,abs.attribute11
  ,abs.attribute12
  ,abs.attribute13
  ,abs.attribute14
  ,abs.attribute15
  ,abs.attribute16
  ,abs.attribute17
  ,abs.attribute18
  ,abs.attribute19
  ,abs.attribute20
  ,b.admission_code
  ,b.admission_date
  ,b.amendment_date
      ,b.amendment_reason
  ,b.concatenated_segments
  ,b.contact_grade
      ,b.contact_type
  ,b.discharge_date
  ,b.disease_name
      ,b.hospital_name
  ,b.leave_amended
  ,b.leave_salary_paid
      ,b.physician_approved_accident
  ,b.physician_name
      ,b.resumption_date
  ,b.context
  FROM per_absence_attendances abs
      ,per_absence_attendance_types c
      ,per_abs_attendance_reasons d
      ,per_absence_attendances_dfv b
      ,fnd_lookup_values flv1
      ,fnd_lookup_values flv
      ,per_all_assignments_f paaf          
 WHERE abs.person_id = paaf.person_id
   AND abs.ROWID = b.row_id
   AND abs.absence_attendance_type_id = c.absence_attendance_type_id(+)
   AND abs.abs_attendance_reason_id = d.abs_attendance_reason_id(+)
   AND d.name = flv1.lookup_code(+)
   AND flv1.lookup_type(+) = 'ABSENCE_REASON'
   AND flv.lookup_code(+) = c.absence_category
   AND flv.lookup_type(+) = 'ABSENCE_CATEGORY'
ORDER BY abs.person_id
        ,absence_type
,date_start 
DESC

Oracle HRMS, Absence Management & PMS Interview Questions

  • What are the tables impacted while creating a new Employee?
  • What are the mandatory fields require to create an employee In Employee Screen?
  • What are the base tables of HRMS?
  • What is the impact on base tables while Rehiring an Employee?
  • What is the impact on base tables while Terminating an Employee?
  • What is the process to create Business Group?
  • What are the mandatory KFFs & DFFs for Creating Business Group?
  • What are EIT & SITs and difference between them ?
  • What is bursting file do in XML publisher Report?
  • What are the ways to create an XML Publisher Report?
  • Absence Management Setup Steps and what are the Fast Formulas used in Absence Management?
  • What are the main Absence Management Tables?
  • What are the Performance Management setup steps?
  • What are the Appraisal Document statuses?
  • What are the APIs used in HRMS and what are mandatory parameters for API?
  • What is object version number, p_validate and what is the use?
  • Payroll basic tables and what is costing and payroll setup.
  • What is Payroll run process and what is the use of element link.
  • How to attach Element to all employees?

Thursday, July 28, 2022

Query to get Element Advance Salary in Oracle APPS HRMS

SELECT papf.employee_number
      ,prrv.result_value
  FROM pay_run_results prr
  ,pay_element_types_f petf
  ,pay_run_result_values prrv
  ,pay_input_values_f piv
  ,pay_assignment_actions paa
  ,pay_payroll_actions ppa
  ,per_all_assignments_f paaf
  ,per_all_people_f papf
 WHERE prr.element_type_id = petf.element_type_id
   AND prr.run_result_id = prrv.run_result_id
   AND prrv.input_value_id = piv.input_value_id
   AND prr.assignment_action_id = paa.assignment_action_id
   AND paaf.assignment_id = paa.assignment_id
   AND paaf.business_group_id = fnd_profile.value('PER_BUSINESS_GROUP_ID')
   and paaf.person_id= papf.person_id
   AND papf.business_group_id = fnd_profile.value('PER_BUSINESS_GROUP_ID')
   AND upper(petf.element_name) = 'ADVANCE SALARY'
   AND piv.name = 'Pay Value' 
   AND SYSDATE BETWEEN piv.effective_start_date AND  piv.effective_end_date
   AND SYSDATE BETWEEN petf.effective_start_date AND  petf.effective_end_date
   AND SYSDATE BETWEEN paaf.effective_start_date AND  paaf.effective_end_date
   AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
   AND ppa.payroll_action_id = paa.payroll_action_id                         
   AND ppa.action_type IN ('Q', 'R')
   AND ppa.effective_date = '31-JUL-2022'
   AND prrv.result_value > '0'

Thursday, June 30, 2022

Employee Category(PER_ALL_ASSIGNMENTS_F.EMPLOYMENT_CATEGORY) in Employee Assignment Form in Oracle APPS

PER_ALL_ASSIGNMENTS_F.EMPLOYMENT_CATEGORY values coming from HR_LOOKUPS.LOOKUP_TYPE = 'EMP_CAT'

SELECT * FROM HR_LOOKUPS WHERE LOOKUP_TYPE = 'EMP_CAT' AND enabled_flag = 'Y' AND SYSDATE BETWEEN NVL (start_date_active, SYSDATE) AND NVL (end_date_active, SYSDATE)





Friday, May 13, 2022

Query to get Employee Contract Duration in Oracle Apps

Nav: Global HRMS Manager--> People-->Enter and Maintain--> Query Employee--> Click on Others Button-->Select Contract from List

select papf.person_id ,papf.employee_number ,papf.full_name ,pcf.duration ,hl.meaning Units from per_all_people_f papf ,per_contracts_f pcf ,hr_lookups hl where papf.person_id = pcf.person_id AND papf.person_id = :p_person_id AND NVL (TRUNC (papf.effective_end_date), SYSDATE) >= TRUNC (SYSDATE) AND NVL (TRUNC (pcf.effective_end_date), SYSDATE) >= TRUNC (SYSDATE) AND pcf.duration_units = hl.lookup_code AND hl.lookup_type(+) = 'QUALIFYING_UNITS'

Query to get Employee Dependent Date Of Birth(Contact Information) in Oracle APPS

Nav: Global HRMS Manager--> People-->Enter and Maintain--> Query Employee--> Click on Others Button-->Select Contact from List
SELECT papf.person_id ,papf.employee_number ,papf.full_name employee_name ,papf_cont.full_name contact_name ,TO_CHAR(papf_cont.date_of_birth, 'DD-MON-RRRR') contact_date_of_birth ,hl.meaning contact_type FROM per_contact_relationships pcr ,per_all_people_f papf ,hr_lookups hl ,per_all_people_f papf_cont WHERE 1 = 1 AND papf.person_id = pcr.person_id AND pcr.contact_person_id = papf_cont.person_id AND NVL (TRUNC (papf.effective_end_date), SYSDATE) >= TRUNC (SYSDATE) AND NVL (TRUNC (papf_cont.effective_end_date), SYSDATE) >= TRUNC (SYSDATE) AND hl.lookup_type(+) = 'CONTACT' AND hl.lookup_code(+) = pcr.contact_type AND papf.person_id = :p_person_id

Thursday, January 13, 2022

Supplier Type Employee not showing any List Of values while creating in Oracle APPS

This is from Oracle Note Doc ID 2395382.1:

The contingent workers will not be directly visible in the suppliers form.

The functional reason is that Contingent Worker (CW) Employees are different from Company Employees. In case of Contingent workers you generally work with the company that has provided the CW. Also there are many restrictions for the Employee type Suppliers (like we don’t show the address, most of the fields are non editable etc.) that may not apply to CW. As such the way to do this would be to establish a Supplier and then relate this Supplier to the Contingent worker in the HR form.

If the customers requirement is to create Employee type suppliers, the such CW need to be made as a employees and not CW.

Saturday, December 18, 2021

Query to fetch Elements attached to Employee in Oracle APPS

SELECT pbg.name business_group_name
      ,papf.employee_number
      ,papf.full_name
      ,petf.element_name
      ,peef.effective_start_date
  FROM per_all_people_f papf
      ,per_all_assignments_f paaf
      ,pay_element_entries_f peef
      ,pay_element_types_f petf
      ,per_business_groups pbg
 WHERE papf.person_id = paaf.person_id
   AND papf.business_group_id = pbg.business_group_id
   AND pbg.business_group_id = fnd_profile.value('PER_BUSINESS_GROUP_ID')
   AND papf.current_employee_flag = 'Y'
   AND paaf.assignment_id = peef.assignment_id
   AND peef.element_type_id = petf.element_type_id
   AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date
   AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
   AND TRUNC (SYSDATE) BETWEEN peef.effective_start_date AND peef.effective_end_date
   AND TRUNC (SYSDATE) BETWEEN petf.effective_start_date AND petf.effective_end_date
   AND petf.element_name LIKE 'PF%'

Thursday, December 9, 2021

Employee Data migration in Oracle APPS

  1. Extract Data from Source System.
    • If Source system is Oracle EBS only then use the following query to extract data. Please note that query having few columns only. Based on your requirement add additional columns or remove which are not required.
    • Employee Data Extraction Query
  2. Create Staging Table.
  3. Load Data into Staging Table
  4. Run API Script.

    

Step2: Create Staging Table.

DROP TABLE XXSCHEMA.XX_EMPLOYEE_STG
/
DROP SYNONYM APPS.XX_EMPLOYEE_STG
/
CREATE TABLE XXSCHEMA.XX_EMPLOYEE_STG
(
  EMPLOYEE_NUMBER        VARCHAR2(30),
  LAST_NAME              VARCHAR2(150),
  FIRST_NAME             VARCHAR2(150),
  MIDDLE_NAMES           VARCHAR2(60),
  TITLE                  VARCHAR2(30),
  FULL_NAME              VARCHAR2(240),
  HIRE_DATE              DATE,
  ORIGINAL_DATE_OF_HIRE  DATE,
  DATE_OF_BIRTH          DATE,
  TOWN_OF_BIRTH          VARCHAR2(90),
  REGION_OF_BIRTH        VARCHAR2(90),
  COUNTRY_OF_BIRTH       VARCHAR2(90),
  SEX                    VARCHAR2(30),
  NATIONALITY            VARCHAR2(30),
  PERSON_TYPE            VARCHAR2(90),
  NATIONAL_IDENTIFIER    VARCHAR2(30),
  BLOOD_TYPE             VARCHAR2(30),
  EMAIL_ADDRESS          VARCHAR2(240),
  MARITAL_STATUS         VARCHAR2(30),
  OFFICE_NUMBER          VARCHAR2(45),
  DISABILITY VARCHAR2(1),
  ATTRIBUTE_CATEGORY     VARCHAR2(30),
  ATTRIBUTE1             VARCHAR2(150),
  ATTRIBUTE2             VARCHAR2(150),
  ATTRIBUTE3             VARCHAR2(150),
  ATTRIBUTE4             VARCHAR2(150),
  ATTRIBUTE5             VARCHAR2(150),
  ATTRIBUTE6             VARCHAR2(150),
  ATTRIBUTE7             VARCHAR2(150),
  ATTRIBUTE8             VARCHAR2(150),
  ATTRIBUTE9             VARCHAR2(150),
  ATTRIBUTE10            VARCHAR2(150),
  PERSON_ID              NUMBER,
  BUSINESS_GROUP_ID      NUMBER,
  ASSIGNMENT_ID          NUMBER(15),
  STATUS                 VARCHAR2(5),
  ERROR_MSG              VARCHAR2(4000)
)
/
CREATE SYNONYM APPS.XX_EMPLOYEE_STG FOR XXSCHEMA.XX_EMPLOYEE_STG
/

STEP3: Load Data into Staging Table
Load data into staging table either using Control File or directly load from Toad/SQL Developer, etc.

STEP4: API Script
DECLARE
  /*Declaration Of Local variables*/
  /*===========================================================================*/
  v_status                       VARCHAR2(1) := NULL;
  v_err_msg                      VARCHAR2(4000) := NULL;
  v_total_records                NUMBER(15) := 0;
  v_success_records              NUMBER(15) := 0;
  v_failure_records              NUMBER(15) := 0;
  v_emp_exists_cnt               NUMBER(15) := 0;
  v_national_identifier_exts_cnt NUMBER(15) := 0;
  x_person_id                    NUMBER := NULL;
  v_gender_code                  VARCHAR2(15) := NULL;
  v_marital_status               VARCHAR2(15) := NULL;
  v_nationality              VARCHAR2(15) := NULL;
  v_country_of_birth             VARCHAR2(15) := NULL;
  --x_lang_code                    VARCHAR2(15) := NULL;
  v_title                    VARCHAR2(15) := NULL;
  x_assignment_id                NUMBER := NULL;
  v_person_type_id               NUMBER := NULL;
  x_race                         VARCHAR2(60) := NULL;
  x_out_employee_number          NUMBER := NULL;
  x_out_person_id                NUMBER := NULL;
  x_out_assignment_id            NUMBER := NULL;
  x_out_per_obj_vers_no          NUMBER := NULL;
  x_out_asg_obj_vers_no          NUMBER := NULL;
  x_out_per_effective_start_date DATE;
  x_out_per_effective_end_date   DATE;
  x_out_full_name                VARCHAR2(240) := NULL;
  x_out_per_comment_id           NUMBER := NULL;
  x_out_assignment_sequence      NUMBER := NULL;
  x_out_assignment_number        NUMBER := NULL;
  x_religion_code                VARCHAR2(200);
  x_out_orig_hire_warning        BOOLEAN;
  ni_number EXCEPTION;
  v_business_group_id            NUMBER := 1;
  x_ni                           VARCHAR2(30) := NULL;
  x_work_schedule                varchar2(50);
  x_out_name_combination_warning BOOLEAN;
  x_out_assign_payroll_warning   BOOLEAN;
  
l_user_id fnd_user.user_id%TYPE;
l_resp_id fnd_responsibility_tl.responsibility_id%TYPE;
l_resp_appl_id fnd_responsibility_tl.application_id%TYPE;
l_org_id hr_operating_units.organization_id%TYPE;
  ----

  CURSOR cur_xxhr_employee IS
SELECT *
  FROM XX_employee_stg stg
WHERE NVL(status, 'E') = 'E'
   and employee_number NOT IN (SELECT NVL(employee_number, 1) FROM per_all_people_f papf)
   and employee_number = '1234567890'
ORDER BY employee_number ASC, hire_date DESC;

BEGIN
l_user_id := NULL;
l_resp_id := NULL;
l_resp_appl_id := NULL;
l_org_id := NULL;
BEGIN
SELECT user_id
  INTO l_user_id
  FROM fnd_user
WHERE user_name = 'XX_USER';
EXCEPTION
WHEN OTHERS THEN
l_user_id := NULL;
END;
BEGIN
SELECT responsibility_id, application_id 
  INTO l_resp_id, l_resp_appl_id
  FROM fnd_responsibility_tl
WHERE responsibility_name = 'Global HRMS Manager'
   AND language = USERENV('LANG')
   ;
EXCEPTION
WHEN OTHERS THEN
l_resp_id := NULL;
l_resp_appl_id := NULL;
END;
-- Initialize apps session
fnd_global.apps_initialize(user_id      => l_user_id
                          ,resp_id      => l_resp_id
  ,resp_appl_id => l_resp_appl_id
  );
DBMS_OUTPUT.PUT_LINE('#############################################################');
DBMS_OUTPUT.PUT_LINE('DATA MIGRATION OF EMPLOYEE :');
DBMS_OUTPUT.PUT_LINE('#############################################################');
DBMS_OUTPUT.PUT_LINE('START TIME : ' ||TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS'));

FOR rec_xxhr_employee IN cur_xxhr_employee LOOP
dbms_output.put_line('Loop Opened');
  
v_status           := 'N';
v_err_msg          := NULL;
v_total_records    := v_total_records + 1;
v_emp_exists_cnt   := 0;
v_national_identifier_exts_cnt := 0;
x_person_id        := 0;
v_gender_code      := NULL;
x_assignment_id    := 0;
v_person_type_id   := 0;
v_marital_status   := NULL;
v_nationality      := NULL;
v_title    := NULL;
v_country_of_birth := NULL;
/*x_registered_disabled     := NULL;
x_country_code            := NULL;
x_lang_code               := NULL;*/
x_out_employee_number     := NULL;
x_out_person_id           := NULL;
x_out_assignment_id       := NULL;
x_out_per_obj_vers_no     := NULL;
x_out_asg_obj_vers_no     := NULL;
x_out_full_name           := NULL;
x_out_per_comment_id      := NULL;
x_out_assignment_sequence := NULL;
x_out_assignment_number   := NULL;
  
/* Check For Local Employee Numbmer */
IF rec_xxhr_employee.employee_number IS NULL THEN
v_err_msg := v_err_msg || 'Employee Number cannot be blank';
v_status  := 'E';
ELSE
SELECT COUNT(1)
  INTO v_emp_exists_cnt
  FROM per_all_people_f papf
WHERE UPPER(TRIM(papf.employee_number)) = UPPER(TRIM(rec_xxhr_employee.employee_number))
   AND papf.business_group_id = v_business_group_id
   AND papf.current_employee_flag = 'Y'
   AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND effective_end_date;
IF v_emp_exists_cnt > 0 THEN
v_status:='E';
v_err_msg := v_err_msg||'EMPLOYEE_NUMBER already exists; ';
END IF;
END IF;
  
--Validation For Gender
IF rec_xxhr_employee.sex IS NULL THEN
v_status:='E';
v_err_msg := v_err_msg||'Employee Gender Cannot be Null; ';
ELSIF rec_xxhr_employee.sex IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_gender_code
  FROM hr_lookups
WHERE lookup_type ='SEX'
   AND UPPER(TRIM(MEANING))=UPPER(TRIM(rec_xxhr_employee.sex));
EXCEPTION 
WHEN OTHERS THEN
v_status:='E';
v_err_msg := v_err_msg||'Employee GENDER(SEX) is not valid; ';
END;
END IF;
--Validation for Person_type
IF rec_xxhr_employee.person_type IS NULL THEN
v_err_msg := 'E';
v_err_msg := v_err_msg||'PERSON_TYPE cannot be Null; ';
ELSIF rec_xxhr_employee.person_type IS NOT NULL THEN
BEGIN
SELECT person_type_id
  INTO v_person_type_id
  FROM per_person_types
WHERE UPPER(TRIM(user_person_type)) = UPPER(TRIM(rec_xxhr_employee.person_type))
   AND business_group_id = v_business_group_id;
EXCEPTION 
WHEN OTHERS THEN
v_status :='E';
v_err_msg := v_err_msg||'PERSON_TYPE is not valid; ';
END;
END IF;
--Validation for Birth Date
IF rec_xxhr_employee.date_of_birth IS NULL THEN
v_status :='E';
v_err_msg := v_err_msg||'DATE_OF_BIRTH cannot Null; ';
END IF;

--Validation for Email Address
IF rec_xxhr_employee.email_address IS NULL THEN
v_status := 'E';
v_err_msg := v_err_msg||'EMAIL_ADDRESS cannot Null; ';
END IF;
--Validation for Marital Status
IF rec_xxhr_employee.marital_status IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_marital_status
  FROM hr_lookups
WHERE lookup_type = 'MAR_STATUS'
   AND UPPER(TRIM(meaning))=UPPER(TRIM(rec_xxhr_employee.marital_status));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'MARITAL_STATUS is not valid; ';
END;
END IF;
--Validation for Nationality
IF rec_xxhr_employee.nationality IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_nationality
  FROM hr_lookups
WHERE lookup_type = 'NATIONALITY'
  AND UPPER(TRIM(meaning)) = UPPER(TRIM(rec_xxhr_employee.nationality));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'NATIONALITY is not valid; ';
END;
END IF;
--Validation for Title

IF rec_xxhr_employee.title IS NULL THEN
v_status := 'E';
v_err_msg := v_err_msg||'TITLE cannot Null; ';
ELSIF rec_xxhr_employee.title IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_title
  FROM hr_lookups
WHERE lookup_type ='TITLE'
   AND UPPER(TRIM(meaning)) = UPPER(TRIM(rec_xxhr_employee.title));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'TITLE is not valid; ';
END;
END IF;

--Validation for Country
IF rec_xxhr_employee.COUNTRY_OF_BIRTH IS NOT NULL THEN
BEGIN
SELECT territory_code
  INTO v_country_of_birth
  FROM apps.fnd_territories_vl
--WHERE UPPER(TRIM (territory_short_name)) = UPPER(TRIM(rec_xxhr_employee.country_of_birth));
WHERE UPPER(TRIM (territory_code)) = UPPER(TRIM(rec_xxhr_employee.country_of_birth));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'COUNTRY_OF_BIRTH is not valid; ';
END;
END IF;
IF rec_xxhr_employee.national_identifier IS NOT NULL THEN
SELECT COUNT(national_identifier)
  INTO v_national_identifier_exts_cnt
  FROM per_all_people_f papf
WHERE UPPER(TRIM(papf.national_identifier)) = UPPER(TRIM(rec_xxhr_employee.national_identifier))
   AND papf.business_group_id = v_business_group_id
   AND TRUNC(sysdate) BETWEEN papf.effective_start_date AND effective_end_date;
IF v_national_identifier_exts_cnt > 0 THEN
v_status := 'E';
v_err_msg := v_err_msg||'NATIONAL_IDENTIFIER is already exists; ';
END IF;
END IF;
IF v_status <> 'E' THEN
BEGIN
APPS.Hr_Employee_Api.create_employee(p_validate                  => FALSE,
p_hire_date                 => rec_xxhr_employee.hire_date,
p_business_group_id         => v_business_group_id,
p_last_name                 => rec_xxhr_employee.last_name,
p_sex                       => v_gender_code,--rec_xxhr_employee.sex,
p_person_type_id            => v_person_type_id,
p_date_of_birth             => rec_xxhr_employee.date_of_birth,
p_email_address             => rec_xxhr_employee.email_address,
p_employee_number           => rec_xxhr_employee.employee_number,
p_first_name                => rec_xxhr_employee.first_name,
p_marital_status            => v_marital_status,--rec_xxhr_employee.marital_status,
p_middle_names              => rec_xxhr_employee.middle_names,
p_nationality               => v_nationality,--rec_xxhr_employee.nationality,
p_national_identifier       => rec_xxhr_employee.national_identifier,
p_registered_disabled_flag  => rec_xxhr_employee.disability,
p_title                     => v_title,--UPPER(rec_xxhr_employee.title),
p_attribute_category        => rec_xxhr_employee.attribute_Category,
p_attribute1                => rec_xxhr_employee.attribute1,
p_Attribute2                => rec_xxhr_employee.attribute2,
p_attribute3                => rec_xxhr_employee.attribute3,
p_blood_type                => rec_xxhr_employee.blood_type,
p_office_number             => rec_xxhr_employee.office_number,
p_original_date_of_hire     => rec_xxhr_employee.original_date_of_hire,
p_town_of_birth             => rec_xxhr_employee.town_of_birth,
p_region_of_birth           => rec_xxhr_employee.region_of_birth,
p_country_of_birth          => v_country_of_birth,--rec_xxhr_employee.country_of_birth,
p_person_id                 => x_out_person_id,
p_assignment_id             => x_out_assignment_id,
p_per_object_version_number => x_out_per_obj_vers_no,
p_asg_object_version_number => x_out_asg_obj_vers_no,
p_per_effective_start_date  => x_out_per_effective_start_date,
p_per_effective_end_date    => x_out_per_effective_end_date,
p_full_name                 => x_out_full_name,
p_per_comment_id            => x_out_per_comment_id,
p_assignment_sequence       => x_out_assignment_sequence,
p_assignment_number         => x_out_assignment_number,
p_name_combination_warning  => x_out_name_combination_warning,
p_assign_payroll_warning    => x_out_assign_payroll_warning,
p_orig_hire_warning         => x_out_orig_hire_warning
   );
  --COMMIT;
  v_success_records := v_success_records + 1;
  UPDATE XX_employee_stg
SET status        = 'S',
error_msg     = 'Success',
person_id     = x_out_person_id,
assignment_id = x_out_assignment_id
   WHERE employee_number = rec_xxhr_employee.employee_number;
  --COMMIT;
EXCEPTION
WHEN OTHERS THEN
v_err_msg         := SQLERRM;
v_failure_records := v_failure_records + 1;
  
DBMS_OUTPUT.PUT_LINE('API Exception :' || SQLERRM);
  
UPDATE XX_employee_stg
   SET status = 'E'
  ,error_msg = v_err_msg
WHERE employee_number = rec_xxhr_employee.employee_number;
  
--COMMIT;
END;
ELSE
v_failure_records := v_failure_records + 1;
UPDATE XX_employee_stg
   SET status = 'E'
  ,error_msg = v_err_msg
WHERE employee_number = rec_xxhr_employee.employee_number;
END IF;
  
END LOOP;
DBMS_OUTPUT.PUT_LINE('v_total_records   :' || v_total_records);
DBMS_OUTPUT.PUT_LINE('v_success_records :' || v_success_records);
DBMS_OUTPUT.PUT_LINE('v_failure_records :' || v_failure_records);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Main Exception :-' || SQLERRM);
END;

Wednesday, December 8, 2021

PER_ALL_PEOPLE_F.SEX in Oracle APPS

SELECT *
FROM hr_lookups
WHERE lookup_type ='SEX'

PER_ALL_PEOPLE_F.country_of_birth in Oracle APPS

SELECT territory_code, territory_short_name
  FROM apps.fnd_territories_vl
 WHERE UPPER(TRIM (territory_short_name)) = UPPER(TRIM(:country_of_birth))

PER_ALL_PEOPLE_F.title in Oracle APPS

SELECT *
FROM hr_lookups
WHERE lookup_type ='TITLE'

PER_ALL_PEOPLE_F.nationality in Oracle APPS

SELECT *
  FROM hr_lookups
WHERE lookup_type = 'NATIONALITY'

PER_ALL_PEOPLE_F.MARITAL_STATUS in Oracle APPS

SELECT *
  FROM hr_lookups
WHERE lookup_type = 'MAR_STATUS'

Query to extract Employee Information for Data Migration

SELECT papf.employee_number,
       papf.last_name,
       papf.first_name,
       papf.middle_names,
       papf.title,
       papf.full_name,
       TO_CHAR(papf.start_date, 'DD-MON-RRRR') hire_date,
       TO_CHAR(papf.original_date_of_hire, 'DD-MON-RRRR') original_date_of_hire,
       TO_CHAR(papf.date_of_birth, 'DD-MON-RRRR')  date_of_birth,
       papf.town_of_birth,
       papf.region_of_birth,
       papf.country_of_birth,
       papf.sex,
       papf.nationality,
       ppt.user_person_type person_type,
       papf.national_identifier,
       papf.blood_type blood_group,
       papf.email_address,
       papf.marital_status,
       papf.office_number,
       papf.attribute_category,
       papf.attribute1,
       papf.attribute2,
       papf.attribute3,
       papf.attribute4,
       papf.attribute5,
       papf.attribute6,
       papf.attribute7,
       papf.attribute8,
       papf.attribute9,
       papf.attribute10,
   papf.attribute11,
   papf.attribute12,
   papf.attribute13,
   papf.attribute14,
   papf.attribute15
  FROM per_all_people_f papf,
       per_periods_of_service pos,
       per_person_type_usages_f pptu,
       per_person_types ppt
 WHERE     1 = 1
       AND papf.person_id = pos.person_id
       AND papf.person_id = pptu.person_id
       AND pptu.person_type_id = ppt.person_type_id
       AND papf.current_employee_flag = 'Y'
       AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
                               AND papf.effective_end_date
       AND TRUNC (SYSDATE) BETWEEN pptu.effective_start_date
                               AND pptu.effective_end_date
order by (papf.employee_number)

Tuesday, November 2, 2021

Sample API Script for Creating Employee Dependent Contact Details in Oracle HRMS(APPS)

This is used to migrate Employee Dependent (Contact) Details.

Table Script:

DROP TABLE XXSCHEMA.XX_EMP_CONTACT_STG;
DROP SYNONYM APPS.XX_EMP_CONTACT_STG;

CREATE TABLE XXSCHEMA.XX_EMP_CONTACT_STG
(SL_NO NUMBER
,BUSINESS_GROUP_ID NUMBER
,EMPLOYEE_NUMBER VARCHAR2(30)
,PERSON_ID NUMBER
,CONTACT_LAST_NAME VARCHAR2(150)
,CONTACT_MIDDLE_NAME VARCHAR2(60)
,CONTACT_FIRST_NAME VARCHAR2(150)
,CONTACT_NAME_TITLE VARCHAR2(30)
,CONTACT_GENDER VARCHAR2(30)
,CONTACT_GENDER_CODE VARCHAR2(1)
,CONTACT_DOB DATE
,CONTACT_NATIONAL_IDENTIFIER VARCHAR2(30)
,CONTACT_RELATIONSHIP_TYPE      varchar2(80)
,CONTACT_RELATIONSHIP_TYPE_CODE varchar2(30)
,CONTACT_EFFECTIVE_DATE DATE
,SPOUSE_EFFECTIVE_DATE DATE
,CONTACT_PRIMARY_CONTACT VARCHAR2(1)
,CONTACT_PERSONAL_RELATIONSHIP VARCHAR2(1)
,CONTACT_BENEFICIARY VARCHAR2(1)
,CONTACT_DEPENDENT VARCHAR2(1)
,CONTACT_RELATIONSHIP_ID      NUMBER
,CTR_OBJECT_VERSION_NUMBER    NUMBER
,PER_PERSON_ID                NUMBER
,PER_OBJECT_VERSION_NUMBER    NUMBER
,PER_EFFECTIVE_START_DATE      DATE
,PER_EFFECTIVE_END_DATE        DATE
,FULL_NAME                    VARCHAR2(240)
,PER_COMMENT_ID              NUMBER 
--,NAME_COMBINATION_WARNING      BOOLEAN
--,ORIG_HIRE_WARNING            BOOLEAN
,PROCESS_STATUS VARCHAR2(1)
,PROCESS_MESSAGE VARCHAR2(4000)
);

CREATE SYNONYM APPS.XX_EMP_CONTACT_STG FOR XXSCHEMA.XX_EMP_CONTACT_STG;


Sample Code using Anonymous Block:
DECLARE 
    l_business_group_id                  per_business_groups.business_group_id%TYPE;
    l_contact_rel_id                     per_contact_relationships.contact_relationship_id%TYPE; 
    l_ctr_object_ver_num                 per_contact_relationships.object_version_number%TYPE; 
    l_contact_person                     per_all_people_f.person_id%TYPE; 
    l_object_version_number              per_contact_relationships.object_version_number%TYPE; 
    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                     per_all_people_f.comment_id%TYPE; 
    l_name_comb_warning                  BOOLEAN; 
    l_orig_hire_warning                  BOOLEAN;
 
    l_contact_exp                        EXCEPTION;
    
    
    l_person_id                         per_all_people_f.person_id%TYPE;
    l_contact_type                      hr_lookups.lookup_code%TYPE;    
    l_contact_gender                    hr_lookups.lookup_code%TYPE;
    l_contact_titile_cnt                NUMBER;
    l_effective_date                    DATE;
    l_date                              date;
l_contact_effective_date            DATE;
    l_process_status                    VARCHAR2(1);
    l_process_message                   VARCHAR2(4000);
    
    l_user_id                           fnd_user.user_id%TYPE;    
    l_resp_id                           fnd_responsibility_tl.responsibility_id%TYPE;
    l_resp_appl_id                      fnd_responsibility_tl.application_id%TYPE;
    
    
    CURSOR validate_emp_contacts
    IS
        SELECT *
          FROM xx_emp_contact_stg
         WHERE NVL(process_status, 'N') IN ('N', 'E')
            AND employee_number NOT IN ('1234567890')
            --AND sl_no = 1
         ;
    
    CURSOR emp_contacts
    IS
        SELECT *
          FROM xx_emp_contact_stg
         WHERE process_status IN ('V')
          --AND sl_no = 1
          -- AND 1=2
         ;
BEGIN
    l_user_id := NULL;
    l_resp_id := NULL;
    l_resp_appl_id := NULL;
    l_business_group_id := NULL;
    
    
    BEGIN
        SELECT user_id
          INTO l_user_id
          FROM fnd_user
         WHERE user_name = 'XX_USER';
    EXCEPTION
    WHEN OTHERS THEN
        l_user_id := NULL;
    END;
    
    BEGIN
        SELECT responsibility_id, application_id 
          INTO l_resp_id, l_resp_appl_id
          FROM fnd_responsibility_tl
         WHERE responsibility_name = 'Global HRMS Manager'
           AND language = USERENV('LANG')
           ;
    EXCEPTION
    WHEN OTHERS THEN
        l_resp_id := NULL;
        l_resp_appl_id := NULL;
    END;
    
    -- Initialize apps session
    fnd_global.apps_initialize(user_id      => l_user_id
                              ,resp_id      => l_resp_id
                              ,resp_appl_id => l_resp_appl_id
                              );
    
    BEGIN
        SELECT fnd_profile.value('PER_BUSINESS_GROUP_ID')
          INTO l_business_group_id
          FROM dual;
    EXCEPTION
    WHEN OTHERS THEN
        l_business_group_id := NULL;
    END;
    
    IF l_business_group_id IS NOT NULL THEN
        FOR rec_validate_emp_contacts IN validate_emp_contacts
        LOOP
            l_person_id   := NULL;
            l_contact_type := NULL;
            l_contact_gender := NULL;
            l_contact_titile_cnt := 0;
            l_effective_date := NULL;
l_contact_effective_date := NULL;
            
            IF rec_validate_emp_contacts.employee_number IS NOT NULL THEN
                BEGIN
                    SELECT person_id, original_date_of_hire--, start_date
                      INTO l_person_id, l_effective_date
                      FROM per_all_people_f
                     WHERE TRIM(employee_number) = TRIM(rec_validate_emp_contacts.employee_number)
                       AND business_group_id = l_business_group_id
                       AND SYSDATE BETWEEN effective_start_date AND effective_end_date
                       ;
                EXCEPTION
                WHEN NO_DATA_FOUND THEN
                    l_person_id := NULL;
                    l_process_status := 'E';
                    l_process_message := 'Employee Number '||rec_validate_emp_contacts.employee_number||' does not exists or end dated';
                WHEN OTHERS THEN
                    l_person_id := NULL;
                    l_process_status := 'E';
                    l_process_message := 'Error while validating Employee Number '||rec_validate_emp_contacts.employee_number;
                END;
            ELSE
                l_process_status := 'E';
                l_process_message := 'Employee Number Cannot be Null.';
            END IF;
            
            IF rec_validate_emp_contacts.contact_relationship_type IS NOT NULL THEN
                BEGIN
                    SELECT hl.lookup_code
                      INTO l_contact_type
                      FROM hr_lookups hl
                     WHERE UPPER(TRIM(hl.meaning))=UPPER(TRIM(rec_validate_emp_contacts.contact_relationship_type))
                       AND hl.lookup_type = 'CONTACT';
                EXCEPTION
                WHEN NO_DATA_FOUND THEN
                    l_process_status := 'E';
                    l_process_message := l_process_message||' Contact Relationship Type '||rec_validate_emp_contacts.contact_relationship_type||' does not exists in Lookup Type CONTACT.';
                WHEN OTHERS THEN
                    l_process_status := 'E';
                    l_process_message := l_process_message||' Invalid Contact Relationship Type '||rec_validate_emp_contacts.contact_relationship_type||'.';
                END;
            ELSE
                l_process_status := 'E';
                l_process_message := 'Contact Relationship Type Cannot be Null.';
            END IF;
            
            IF rec_validate_emp_contacts.contact_gender IS NOT NULL THEN            
                BEGIN
                    SELECT hl.lookup_code
                      INTO l_contact_gender
                      FROM hr_lookups hl
                     WHERE UPPER(TRIM(hl.meaning))=UPPER(TRIM(rec_validate_emp_contacts.contact_gender))
                       AND hl.lookup_type = 'SEX';
                EXCEPTION
                WHEN NO_DATA_FOUND THEN
                    l_process_status := 'E';
                    l_process_message := l_process_message||' Contact Gender '||rec_validate_emp_contacts.contact_gender||' does not exists in Lookup Type SEX.';
                WHEN OTHERS THEN
                    l_process_status := 'E';
                    l_process_message := l_process_message||' Invalid Contact Gender '||rec_validate_emp_contacts.contact_gender||'.';
                END;
            ELSE
                l_process_status := 'E';
                l_process_message := 'Contact Gender Cannot be Null.';
            END IF;
            IF rec_validate_emp_contacts.contact_name_title IS NOT NULL THEN
                SELECT COUNT(1)
                  INTO l_contact_titile_cnt
                  FROM hr_lookups hl
                 WHERE UPPER(TRIM(hl.meaning))=UPPER(TRIM(rec_validate_emp_contacts.contact_name_title))
                   AND hl.lookup_type = 'TITLE';
                   
                IF l_contact_titile_cnt = 0 THEN
                    l_process_status := 'E';
                    l_process_message := l_process_message||' Contact Name Title '||rec_validate_emp_contacts.contact_name_title||' does not exists in Lookup Type TITLE.';
                END IF;
            ELSE
                l_process_status := 'E';
                l_process_message := l_process_message||' Contact Name Title Cannot be Null.';
            END IF;
IF UPPER(TRIM(rec_validate_emp_contacts.contact_relationship_type)) <> 'SPOUSE' THEN
IF l_effective_date > rec_validate_emp_contacts.contact_dob THEN
l_contact_effective_date := l_effective_date;
ELSE
l_contact_effective_date := NULL;
END IF;
            END IF;
            UPDATE xx_emp_contact_stg
               SET business_group_id = l_business_group_id
                  ,person_id = l_person_id
                  ,contact_gender_code = l_contact_gender
                  ,contact_relationship_type_code = l_contact_type
                  ,spouse_effective_date = DECODE(UPPER(TRIM(rec_validate_emp_contacts.contact_relationship_type)), 'SPOUSE', l_effective_date, NULL)
  ,contact_effective_date = l_contact_effective_date
                  ,process_status = 'V'
                  ,process_message = NULL
             WHERE sl_no = rec_validate_emp_contacts.sl_no;
        END LOOP;
    ELSE
        UPDATE xx_emp_contact_stg
           SET business_group_id = NULL
              ,process_status = 'E'
              ,process_message = 'Error while fetching business_group_id '
         WHERE process_status IN ('N','E');
    END IF;    
    
    FOR load_emp_contacts IN emp_contacts
    LOOP
            l_contact_rel_id   := null;
            l_ctr_object_ver_num := null;
            l_date := NULL;
            
             dbms_output.put_line('Employee Number: '||load_emp_contacts.employee_number);   
             dbms_output.put_line('Person ID: '||load_emp_contacts.person_id);
            
            IF UPPER(TRIM(load_emp_contacts.contact_relationship_type)) = 'SPOUSE' THEN
                SELECT load_emp_contacts.spouse_effective_date
                   INTO l_date
                   FROM dual;
            ELSE
                SELECT NVL(load_emp_contacts.contact_effective_date, load_emp_contacts.contact_dob)
                  INTO l_date
                  FROM dual;
            END IF;
            
            -- Create Employee Contact
            -- -------------------------------------
            hr_contact_rel_api.create_contact
            (    -- Input data elements
               -- -----------------------------
                 p_validate                          => FALSE
                ,p_start_date                        => /*DECODE(load_emp_contacts.contact_relationship_type, 'SPOUSE', load_emp_contacts.spouse_effective_date
                                                                                                                    , load_emp_contacts.contact_dob)*/
                                                        l_date
                ,p_business_group_id                 => load_emp_contacts.business_group_id
                ,p_person_id                         => load_emp_contacts.person_id
                ,p_contact_type                      => load_emp_contacts.contact_relationship_type_code
                ,p_date_start                        => l_date
                ,p_title                             => UPPER(TRIM(load_emp_contacts.contact_name_title))-- 'MR.'
                ,p_last_name                         => load_emp_contacts.contact_last_name  
                ,p_middle_names                      => load_emp_contacts.contact_middle_name 
                ,p_first_name                        => load_emp_contacts.contact_first_name 
                ,p_date_of_birth                     => load_emp_contacts.contact_dob
                ,p_sex                               => load_emp_contacts.contact_gender_code --'M'
                ,p_primary_contact_flag              => load_emp_contacts.contact_primary_contact
                ,p_personal_flag                     => load_emp_contacts.contact_personal_relationship --'Y'
                ,p_beneficiary_flag                  => load_emp_contacts.contact_beneficiary
                ,p_dependent_flag                    => load_emp_contacts.contact_dependent
                --,p_effective_date                    => l_date
                -- Output data elements
                -- --------------------------------
                ,p_contact_relationship_id           => l_contact_rel_id
                ,p_ctr_object_version_number         => l_ctr_object_ver_num
                ,p_per_person_id                     => l_contact_person
                ,p_per_object_version_number         => l_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_name_combination_warning          => l_name_comb_warning
                ,p_orig_hire_warning                 => l_orig_hire_warning
            );
         
        IF l_contact_rel_id is null then
            dbms_output.put_line('Create Contact Relationship failed '||sqlerrm);
            UPDATE xx_emp_contact_stg
               SET process_status = 'E'
                  ,process_message = 'Create Contact Relationship failed '
             WHERE sl_no = load_emp_contacts.sl_no;
            --raise l_contact_exp;
        ELSE
            dbms_output.put_line('Contact Relationship Created');     
            UPDATE xx_emp_contact_stg
               SET contact_relationship_id = l_contact_rel_id
                  ,ctr_object_version_number = l_ctr_object_ver_num
                  ,per_person_id = l_contact_person
                  ,per_object_version_number = l_object_version_number
                  ,per_effective_start_date = l_per_effective_start_date
                  ,per_effective_end_date = l_per_effective_end_date
                  ,full_name = l_full_name
                  ,per_comment_id = l_per_comment_id
                  --,name_combination_warning = l_name_comb_warning
                  --,orig_hire_warning = l_orig_hire_warning
                  ,process_status = 'S'
                  ,process_message = 'Success'
             WHERE sl_no = load_emp_contacts.sl_no;
        END IF;
     
    END LOOP;
     --COMMIT;
    
EXCEPTION
WHEN OTHERS THEN
    --ROLLBACK;
    dbms_output.put_line('Inside Exception: '||SQLERRM);
END;
/

ORA-20001: FLEX-NULL REQUIRED SEGMENT: N, SEGMENT_NAME, 'XX_SEGMENT_NAME' while creating Employee Contact hr_contact_rel_api.create_contact

While creating relationship type contact for employee using hr_contact_rel_api.create_contact API, getting "ORA-20001: FLEX-NULL REQUIRED SEGMENT: N, SEGMENT_NAME, 'XX_SEGMENT_NAME'" error. When you face such error please validate "Further Contact R'ship Info" flex field has any mandatory values as shown in below screenshot.


Please pass value for flex value and test it.


APEX$TASK_PK

  APEX$TASK_PK is a substitution string holding the primary key value of the system of records