Showing posts with label Core HR Queries. Show all posts
Showing posts with label Core HR Queries. Show all posts

Friday, July 3, 2015

Query: People Assignment Salary - History





select
    ppf.employee_number                                                     "Employee Number",
    --
    ppp.change_date                                                         "From" ,
    decode (ppp.date_to,hr_general.end_of_time, to_date (null),ppp.date_to) "To",
    nvl(ppp.proposed_salary_n,0)-(lag(ppp.proposed_salary_n)
        over (order by ppp.change_date))                                    "Change Amount",
    round(((nvl(ppp.proposed_salary_n,0)-(lag(ppp.proposed_salary_n)
        over (order by ppp.change_date)))/ppp.proposed_salary_n)*100,0)     "Change %",
    ppp.proposed_salary_n                                                   "Salary",
    (ppp.proposed_salary_n*12)                                              "Annualized Salary",
    pet.input_currency_code                                                 "Currency",
    ppb.name                                                                "Salary Basis",
    hr_general.decode_lookup ('PER_SAL_PROPOSAL_STATUS',ppp.approved)       "Status",
    --
    ppp.pay_proposal_id
from
    per_pay_proposals ppp,
    per_performance_reviews ppr,
    per_assignments_f2 paa,
    per_people_f ppf,
    per_pay_bases ppb,
    pay_input_values_f piv,
    pay_element_types_f pet,
    fnd_currencies_tl fct,
    fnd_user fu
where  
    1=1
and ppp.performance_review_id = ppr.performance_review_id(+)
and paa.assignment_id = ppp.assignment_id
and paa.person_id = ppf.person_id
and ppp.last_updated_by = fu.user_id(+)
and ppp.change_date between paa.effective_start_date and paa.effective_end_date
and paa.pay_basis_id = ppb.pay_basis_id(+)
and per_saladmin_utility.get_currency (ppp.assignment_id,ppp.change_date) = fct.name
and fct.language = userenv ('LANG')
and fct.currency_code = pet.input_currency_code
and ppb.input_value_id = piv.input_value_id
and piv.element_type_id = pet.element_type_id
and ppp.assignment_id=12951
and ppp.change_date between piv.effective_start_date
and piv.effective_end_date
and ppp.change_date between pet.effective_start_date and pet.effective_end_date
--
and ppf.employee_number = '1309'
order by
    change_date desc;

Query: Salary Management





select
    ppf.employee_number                 "Employee Number",
    --
    ppf.full_name                         "Full Name",
    psf.assignment_number                 "Assignment Number",
    ppb.name                              "Salary basis",
    ppp.change_date                       "Approved Date",
    ppp.proposed_salary_n                 "Approved Salary",
    pro1.change_date                      "Change Date",
    pro1.proposed_salary_n                "Proposed Salary",
    proposal_reason                       "Proposal Reason",
    pppc.change_percentage                "COL %",
    pppc.change_amount_n                  "COL Amount",
    psf.employment_category               "Assignment Category",           -- lookup;EMP_CAT
    --
    ppf.person_id,
    ppb.pay_basis_id
from
     per_all_people_f ppf,
     per_assignments_f psf,
     per_pay_bases ppb,
      per_pay_proposals pro1,
     (select ppp.change_date,
                  ppp.proposed_salary_n,
                  ppp.approved,
                  ppp.assignment_id
             from per_pay_proposals ppp
            where approved = 'Y')  ppp,
    per_pay_proposal_components pppc        
where
    1=1
and ppf.person_id = psf.person_id
and psf.pay_basis_id = ppb.pay_basis_id
and psf.assignment_id = pro1.assignment_id(+)
and pro1.approved(+) = 'N'
and psf.assignment_id = ppp.assignment_id(+)
and (ppp.change_date is null
     or ppp.change_date = (select max (change_date)
                        from per_pay_proposals pro3
                        where ppp.assignment_id = pro3.assignment_id
                        and pro3.approved = 'Y'))
and pro1.pay_proposal_id = pppc.pay_proposal_id(+)
and sysdate between ppf.effective_start_date and ppf.effective_end_date
and sysdate between psf.effective_start_date and psf.effective_end_date
--
and ppf.employee_number = '1309'
order by
    1,2;

Query: People Assignment Salary - Peer Avg


select     /*+ leading(sal.day) */
    percentile_cont (0.5)
    within group (order by sal.salary)         "Salary",
    sal.currency_code                          "Currency",
    round (
    avg (
    (sal.salary
    / case
         when sal.grade_mid_value = 0 then 1
         else sal.grade_mid_value
      end)
    * 100),
    2)                                          "COMPARATIO",
    trunc (
   avg (
   case
      when sal.salary <= sal.grade_min
      then
         0
      when sal.salary >= sal.grade_max
      then
         5
      when sal.salary <= (sal.grade_mid_value + sal.grade_min) / 2
      then
         1
      when sal.salary < sal.grade_mid_value
      then
         2
      when sal.salary >= (sal.grade_mid_value + sal.grade_max) / 2
      then
         4
      when sal.salary >= sal.grade_mid_value
      then
         3
    end),
    1)                                            "QUARTILE",                        -- lookup: ben_cwb_quartile
    round (
    avg (
    ( (sal.salary - sal.grade_min)
    / case
         when (sal.grade_max - sal.grade_min) = 0 then 1
         else (sal.grade_max - sal.grade_min)
      end)
    * 100),
    2)
range_position
from
    (select day.effective_date effective_start_date,
    add_months (day.effective_date, 12) - 1 effective_end_date,
    asg.business_group_id,
    asg.assignment_id,
    asg.job_id job_id,
    loc.country country,
    asg.pay_basis_id,
    asg.grade_id,
    pgr.rate_id,
    hri_bpl_abv.calc_abv (asg.assignment_id,
            asg.business_group_id,
            'HEAD',
            pro.change_date)  headcount,
                 case
                    when ppb.pay_basis = 'HOURLY'
                         or fnd_profile.value ('PER_ANNUAL_SALARY_ON_FTE') =
                               'N'
                    then
                       (ppb.pay_annualization_factor * pro.proposed_salary_n)
                    else
                       (ppb.pay_annualization_factor * pro.proposed_salary_n)
                       / case
                            when per_saladmin_utility.get_fte_factor (
                                    asg.assignment_id,
                                    day.effective_date) = 0
                            then
                               1
                            else
                               per_saladmin_utility.get_fte_factor (
                                  asg.assignment_id,
                                  day.effective_date)
                         end
                 end
                    salary,
                 pgr.currency_code grade_currency,
                 case
                    when     pet.input_currency_code is not null
                         and pgr.currency_code is not null
                         and pgr.currency_code != pet.input_currency_code
                    then
                         per_saladmin_utility.get_currency_rate (
                            pgr.currency_code,
                            pet.input_currency_code,
                            day.effective_date,
                            asg.business_group_id)
                       * pgr.minimum
                       * ppb.grade_annualization_factor
                    else
                       pgr.minimum * ppb.grade_annualization_factor
                 end
                    grade_min,
                 case
                    when     pet.input_currency_code is not null
                         and pgr.currency_code is not null
                         and pgr.currency_code != pet.input_currency_code
                    then
                         per_saladmin_utility.get_currency_rate (
                            pgr.currency_code,
                            pet.input_currency_code,
                            day.effective_date,
                            asg.business_group_id)
                       * pgr.maximum
                       * ppb.grade_annualization_factor
                    else
                       pgr.maximum * ppb.grade_annualization_factor
                 end
                    grade_max,
                 case
                    when     pet.input_currency_code is not null
                         and pgr.currency_code is not null
                         and pgr.currency_code != pet.input_currency_code
                    then
                         per_saladmin_utility.get_currency_rate (
                            pgr.currency_code,
                            pet.input_currency_code,
                            day.effective_date,
                            asg.business_group_id)
                       * pgr.mid_value
                       * ppb.grade_annualization_factor
                    else
                       pgr.mid_value * ppb.grade_annualization_factor
                 end
                    grade_mid_value,
                 pet.input_currency_code currency_code
            from per_all_assignments_f asg,
            per_all_people_f ppf,
                 per_pay_bases ppb,
                 per_pay_proposals pro,
                 pay_input_values_f piv,
                 pay_element_types_f pet,
                 hr_locations_all loc,
                 pay_grade_rules_f pgr,
                 (select trunc (sysdate) effective_date from dual
                  union all
                  select add_months (trunc (sysdate), -12) effective_date
                    from dual
                  union all
                  select add_months (trunc (sysdate), -24) effective_date
                    from dual
                  union all
                  select add_months (trunc (sysdate), -36) effective_date
                    from dual
                  union all
                  select add_months (trunc (sysdate), -48) effective_date
                    from dual) day
           where day.effective_date between asg.effective_start_date
                                        and asg.effective_end_date
                 and asg.job_id is not null
                 and asg.person_id = ppf.person_id
                 and asg.grade_id = pgr.grade_or_spinal_point_id
                 and ppb.rate_id = pgr.rate_id
                 and asg.assignment_id = pro.assignment_id
                 and pro.change_date =
                        (select max (change_date)
                           from per_pay_proposals pro2
                          where     pro2.assignment_id = pro.assignment_id
                                and pro2.change_date <= day.effective_date
                                and pro2.approved = 'Y')
                 and asg.pay_basis_id = ppb.pay_basis_id
                 and ppb.input_value_id = piv.input_value_id
                 and piv.element_type_id = pet.element_type_id
                 and loc.location_id = asg.location_id
                 and pro.change_date between piv.effective_start_date
                                         and piv.effective_end_date
                 and pro.change_date between pet.effective_start_date
                                         and pet.effective_end_date
                 and pro.change_date between pgr.effective_start_date
                                         and pgr.effective_end_date
                 and ppf.employee_number = '1309') sal
where
    1=1
and sysdate between sal.effective_start_date and sal.effective_end_date
group by
    sal.effective_start_date,
    sal.effective_end_date,
    sal.job_id,
    sal.country,
    sal.pay_basis_id,
    sal.currency_code;

Tuesday, March 17, 2015

Query to get EIT and SIT in HRMS



Query to get Extra Information Types (EIT) and Special Information Types (SIT) values from HRMS Module:

Say 'Certification Course Details', 'Visa Information'...etc are SITs in HRMS. Below example is used to get 'Certification Course Details' of employees:

SELECT   papf.employee_number, papf.full_name, ppt.user_person_type emptype,
         SUBSTR (hsck.concatenated_segments,
                 1,
                 INSTR (hsck.concatenated_segments, '|') - 1
                ) company_name,
         paaf.effective_start_date,
         TO_CHAR (TO_DATE (pac.segment2, 'YYYY/MM/DD HH24:MI:SS'),
                  'DD-MON-YYYY'
                 ) paid_date,
         pac.segment3 amount, pac.segment4 amnt_type, pac.segment1 course
    FROM per_all_people_f papf,
         per_all_assignments_f paaf,
         hr_soft_coding_keyflex hsck,
         per_person_analyses ppa,
         fnd_id_flex_structures fifs,
         per_special_info_types psit,
         per_analysis_criteria pac,
         per_person_types ppt
   WHERE paaf.person_id = papf.person_id
     AND ppt.person_type_id = papf.person_type_id
     AND pac.id_flex_num = fifs.id_flex_num
     AND fifs.id_flex_structure_code = 'Certification Course Details'
     AND ppt.person_type_id(+) = papf.person_type_id
     AND psit.id_flex_num = pac.id_flex_num
     AND ppa.person_id (+) = papf.person_id
     AND pac.analysis_criteria_id (+) = ppa.analysis_criteria_id
     AND paaf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id(+)
     AND paaf.assignment_type = 'E'
     AND ppt.user_person_type <> 'Ex-employee'
     AND papf.business_group_id = :p_business_group_id
     AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
     AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
--and papf.effective_start_date between :p_from_date and :p_to_date
GROUP BY papf.full_name,
         papf.employee_number,
         ppt.user_person_type,
         paaf.effective_start_date,
         hsck.concatenated_segments,
         pac.segment2,
         pac.segment3,
         pac.segment4,
         pac.segment1;



Say 'Passport Details' is one the EITs in HRMS, then find the below query to get the passport information for particular employee

-- Data may have only in one field OR all fields
SELECT pei_information1,
       pei_information2,              
       pei_information3,
       pei_information4,
       pei_information5,
       pei_information6,
       pei_information7,
       pei_information8,
       pei_information9,
       pei_information10,
       pei_information11,
       pei_information12,
       pei_information13            
  FROM per_people_extra_info
 WHERE pei_information_category = 'Passport Details'    -- Could be any other EIT category
   AND person_id = :p_person_id;

Tuesday, March 10, 2015

Query to to find the Employee Supervisor name

SELECT
papf1.full_name supervisor_name
From apps.per_all_people_f papf,
apps.per_all_assignments_f paaf,
apps.per_all_people_f papf1
WHERE papf.person_id = paaf.person_id
AND paaf.primary_flag = ‘Y’
AND paaf.assignment_type = ‘E’
AND paaf.supervisor_id = papf1.person_id
AND papf1.current_employee_flag = ‘Y’
AND papf.business_group_id = paaf.business_group_id
AND SYSDATE BETWEEN papf.effective_start_date
and papf.effective_end_dateAND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND SYSDATE BETWEEN papf1.effective_start_date AND papf1.effective_end_date
AND papf.employee_number = :p_emp_number;

Employee with supervisor and Org detail Query


SELECT p.full_name,
       p.employee_number employee_number,
       p.last_name last_name,
       p.first_name first_name,
       p.original_date_of_hire hire_date,
       p.date_of_birth dob,
       p.sex gender,
       p.email_address email_address,
       (SELECT name
        FROM apps.hr_all_organization_units
        WHERE organization_id = p.business_group_id)
          organization,
       (SELECT location_code
        FROM apps.hr_locations_all_tl
        WHERE location_id = a.location_id AND language = USERENV ('LANG'))
          location_name,
       'A' status_flag,
       (SELECT concatenated_segments
        FROM apps.gl_code_combinations_kfv
        WHERE code_combination_id = a.default_code_comb_id)
          expense_account,
       (SELECT papf1.full_name supervisor_name
        FROM apps.per_all_people_f papf,
             apps.per_all_assignments_f paaf,
             apps.per_all_people_f papf1
        WHERE     papf.person_id = paaf.person_id
              AND paaf.primary_flag = 'Y'
              AND paaf.assignment_type = 'E'
              AND paaf.supervisor_id = papf1.person_id
              AND papf1.current_employee_flag = 'Y'
              AND papf.business_group_id = paaf.business_group_id
              AND SYSDATE BETWEEN papf.effective_start_date
                              AND  papf.effective_end_date
              AND SYSDATE BETWEEN paaf.effective_start_date
                              AND  paaf.effective_end_date
              AND SYSDATE BETWEEN papf1.effective_start_date
                              AND  papf1.effective_end_date
              AND papf.employee_number = p.employee_number
              AND papf.person_id = p.person_id)
          supervisor
FROM apps.per_all_people_f p,
     apps.per_all_assignments_f a,
     apps.pay_people_groups ppg,
     apps.hr_all_positions_f hap
WHERE     p.person_id = a.person_id
      AND SYSDATE BETWEEN p.effective_start_date AND p.effective_end_date
      AND SYSDATE BETWEEN a.effective_start_date AND a.effective_end_date
      AND a.people_group_id = ppg.people_group_id
      AND hap.position_id(+) = a.position_id

Query to Find All Active Employees and Current Salary

select
    EMPLOYEE_NUMBER,
    a.FULL_NAME,
    x.USER_PERSON_TYPE,
    c.PROPOSED_SALARY_n Basi_Salary,
    c.CHANGE_DATE–,c.*
from per_people_f A,per_assignments_f b,pER_PAY_pROposals c
,per_person_types x
, per_person_type_usages_f e
where a.PERSON_ID=b.PERSON_ID
and b.ASSIGNMENT_ID=C.ASSIGNMENT_ID
and a.EMPLOYEE_NUMBER is not null
–and a.EMPLOYEE_NUMBER=:emp_num
and c.CHANGE_DATE = (select max(d.CHANGE_DATE) from pER_PAY_pROposals d where d.ASSIGNMENT_ID=b.ASSIGNMENT_ID and d.approved = ‘Y’)
-- and c.CHANGE_DATE>=:change_date
and b.PAYROLL_ID=62
and :p_effective_date between a.EFFECTIVE_START_DATE and a.EFFECTIVE_END_DATE
and :p_effective_date between b.EFFECTIVE_START_DATE and b.EFFECTIVE_END_DATE
and a.PERSOn_id = e.PERSON_ID
and a.EFFECTIVE_START_DATE between e.EFFECTIVE_START_DATE and e.EFFECTIVE_END_DATE
and e.PERSON_TYPE_ID = x.PERSON_TYPE_ID
and x.SYSTEM_PERSON_TYPE = ‘EMP’

Postion Hierarchy Details with Superior in Oracle HRMS


SELECT peha.position_structure_id,
  peha.EMPLOYEE_ID,
  fndu.user_id,
  ppos.POSITION_ID,
  pps.name Hierarchy,
  fndu.USER_NAME UserName,
  papf.FULL_NAME Person,
  ppos.NAME Position,
  peha.SUPERIOR_LEVEL SuperiorPositionLevel,
  ppos2.NAME SuperiorPosition,
  papf2.FULL_NAME SuperiorPerson,
  fndu2.USER_NAME SuperiorUsername,
  peha.SUPERIOR_ID SuperiorPersonId,
  fndu2.user_id SuperiorUserId,
  ppos2.POSITION_ID SuperiorPosId
FROM PO_EMPLOYEE_HIERARCHIES_ALL peha,
  PER_POSITIONS ppos,
  PER_POSITIONS ppos2,
  per_all_people_f papf,
  per_all_people_f papf2,
  fnd_user fndu,
  fnd_user fndu2,
  per_position_structures pps
WHERE pps.business_group_id   = peha.business_group_id
   AND pps.position_structure_id = peha.position_structure_id
   AND fndu2.EMPLOYEE_ID         = papf2.PERSON_ID
   AND papf2.PERSON_ID           = peha.SUPERIOR_ID
   AND papf2.EFFECTIVE_END_DATE  > sysdate
   AND papf.PERSON_ID            = peha.employee_id
   AND papf.EFFECTIVE_END_DATE   > sysdate
   AND ppos2.POSITION_ID         = peha.SUPERIOR_POSITION_ID
   AND ppos.position_id          = peha.EMPLOYEE_POSITION_ID
   AND peha.superior_level       > 0
   AND peha.employee_id          = fndu.EMPLOYEE_ID
  --and fndu.USER_NAME = upper('&StartingUsername')
ORDER BY peha.position_structure_id,
  peha.superior_level,
  papf2.full_name
Best Blogger TemplatesBest Blogger Tips
Posted by Raju Ch at 5:58 PM 0 comments
Email This
BlogThis!
Share to Twitter
Share to Facebook
Share to Pinterest

Labels: HRMS, SCRIPTS


MONDAY, FEBRUARY 25, 2013
Employee Superviser Query


SELECT asg.organization_id,
       emp.employee_number,
       emp.full_name emp_name,
       pos.NAME POSITION,
       sup.employee_number sup_emp_no,
       sup.full_name sup_name,
       sup_pos.NAME sup_pos,
       sppt.user_person_type,
       emp.effective_start_date emp_esd,
       emp.effective_end_date emp_eed,
       asg.effective_start_date asg_esd,
       asg.effective_end_date asg_eed,
       sup.effective_start_date sup_esd,
       sup.effective_end_date sup_eed,
       sup_asg.effective_start_date sup_asg_esd,
       sup_asg.effective_end_date sup_asg_eed,
       sptu.effective_start_date sptu_esd,
       sptu.effective_end_date sptu_eed
  FROM per_all_people_f emp,
       per_all_assignments_f asg,
       per_all_positions pos,
       per_all_people_f sup,
       per_all_assignments_f sup_asg,
       per_all_positions sup_pos,
       per_person_type_usages_f sptu,
       per_person_types sppt
 WHERE asg.person_id = emp.person_id
   AND pos.position_id(+) = asg.position_id
   AND sup.person_id(+) = asg.supervisor_id
   AND sup_asg.person_id(+) = sup.person_id
   AND sup_pos.position_id(+) = sup_asg.position_id
   AND sptu.person_id = emp.person_id
   AND sppt.person_type_id = sptu.person_type_id
   AND emp.person_type_id = 1120

Oracle HRMS Scripts(Queries) - Entry Value


SELECT
entry.assignment_id, asg.assignment_number, TYPE.element_name,
     CASE
          WHEN pec.classification_name = 'Earnings'
             THEN 'Earnings'
         WHEN pec.classification_name = 'Supplemental Earnings'
             THEN 'Supplemental Earnings'
--
          WHEN INSTR (pec.classification_name, 'Deductions') >=1
             THEN 'Deductions'
          WHEN INSTR (pec.classification_name, 'Information') >=1
             THEN 'Information'
          ELSE pec.classification_name
       END classification,
       CASE
          WHEN INSTR (pec.classification_name, 'Earning') >=  1
             THEN '1'
          WHEN INSTR (pec.classification_name, 'Deductions') >=
                                                           1
             THEN '2'
          WHEN INSTR (pec.classification_name,
                      'Information') >= 1
             THEN '3'
          ELSE pec.classification_name
       END class_sort_order,
       --
       TYPE.processing_type,
       DECODE (TYPE.processing_type,
               'R', 'Recurring',
               'Non Recurring'
              ) processing_type_meaning,
       TYPE.post_termination_rule,
       DECODE (TYPE.post_termination_rule,
               'L', 'Last Standard Process',
               'F', 'Final Close',
               'A', 'Acutal Termination'
              ) termination_rule_meaning,
       TYPE.input_currency_code, TYPE.output_currency_code, inpval.uom,
       DECODE (inpval.uom,
               'M', 'Money',
               'N', 'Number',
               'D', 'Date',
               'ND', 'Day',
               'C', 'Character'
              ) unit_of_measure,
       NVL
          (DECODE (inpval.uom,
                   'M', fnd_number.canonical_to_number (VALUE.screen_entry_value),
                   'N', fnd_number.canonical_to_number (VALUE.screen_entry_value)
                  ),
           0
          ) e_value_num,
       NVL (VALUE.screen_entry_value, '0') e_value, inpval.NAME value_name,
       VALUE.element_entry_id, inpval.effective_start_date eft_st_date_inpval,
       inpval.effective_end_date eft_ed_date_inpval,
       LINK.effective_start_date eft_st_date_link,
       LINK.effective_end_date eft_end_date_link,
       TYPE.effective_start_date eft_st_date_type,
       TYPE.effective_end_date eft_end_date_type,
       entry.effective_start_date eft_st_date_entry,
       entry.effective_end_date eft_end_date_entry,
       asg.effective_start_date eft_st_date_asg,
       asg.effective_end_date eft_end_date_asg,
       TYPE.element_type_id element_type_id
  FROM pay_element_types_f TYPE,
       pay_element_links_f LINK,
       pay_element_entries_f entry,
       pay_element_entry_values_f VALUE,
       pay_input_values_f inpval,
       pay_element_classifications pec,
       APPS.PER_ASSIGNMENTS_F2 asg
 WHERE TYPE.element_type_id = LINK.element_type_id
   AND entry.element_link_id = LINK.element_link_id
--AND ENTRY.ENTRY_TYPE IN ('A', 'R')
   --AND VALUE.element_entry_id(+) = entry.element_entry_id
   AND VALUE.element_entry_id = entry.element_entry_id
   AND entry.effective_start_date between type.effective_start_date and type.effective_end_date
   AND entry.effective_start_date between link.effective_start_date and link.effective_end_date
   AND entry.effective_start_date between inpval.effective_start_date and inpval.effective_end_date
   AND entry.effective_start_date between value.effective_start_date and value.effective_end_date
   AND entry.effective_start_date between asg.effective_start_date and asg.effective_end_date
   --
   --AND VALUE.effective_start_date(+) = entry.effective_start_date
   --AND VALUE.effective_end_date(+) = entry.effective_end_date
   --AND inpval.input_value_id(+) = VALUE.input_value_id
   AND inpval.input_value_id = VALUE.input_value_id
   AND pec.classification_id = TYPE.classification_id
   AND asg.assignment_id = entry.assignment_id
   AND (UPPER (inpval.NAME) NOT LIKE '%FUTU%' OR inpval.NAME IS NOT NULL)
   and assignment_number not like 'XX%'

Oracle HRMS Scripts(Queries) - Employee Supervisor


SELECT asg.organization_id,
    emp.employee_number,
    emp.full_name emp_name,
    pos.NAME POSITION,
    sup.employee_number sup_emp_no,
    sup.full_name sup_name,
    sup_pos.NAME sup_pos,
    sppt.user_person_type,
    emp.effective_start_date emp_esd,
    emp.effective_end_date emp_eed,
    asg.effective_start_date asg_esd,
    asg.effective_end_date asg_eed,
    sup.effective_start_date sup_esd,
    sup.effective_end_date sup_eed,
    sup_asg.effective_start_date sup_asg_esd,
    sup_asg.effective_end_date sup_asg_eed,
    sptu.effective_start_date sptu_esd,
    sptu.effective_end_date sptu_eed    
  FROM per_all_people_f emp,
       per_all_assignments_f asg,
       per_all_positions pos,
       per_all_people_f sup,
       per_all_assignments_f sup_asg,
       per_all_positions sup_pos,
       per_person_type_usages_f sptu,
       per_person_types sppt
 WHERE asg.person_id = emp.person_id
   AND pos.position_id(+) = asg.position_id
   AND sup.person_id(+) = asg.supervisor_id
   AND sup_asg.person_id(+) = sup.person_id
   AND sup_pos.position_id(+) = sup_asg.position_id
   AND sptu.person_id = emp.person_id
   AND sppt.person_type_id = sptu.person_type_id
   and emp.person_type_id = 1120


Best Blogger TemplatesBest Blogger Tips
Posted by Raju Ch at 12:45 AM 0 comments
Email This
BlogThis!
Share to Twitter
Share to Facebook
Share to Pinterest

Labels: HRMS, SCRIPTS


Oracle HRMS Scripts(Queries) - Employee Elements
SELECT entry.element_entry_id, entry.assignment_id,
          entry.effective_start_date, entry.effective_end_date,
          entry.cost_allocation_keyflex_id, entry.updating_action_id,
          entry.element_link_id, entry.original_entry_id, entry.creator_type,
          entry.entry_type, DECODE (entry.entry_type, 'D', 'Y', 'N'),
          DECODE (entry.entry_type, 'S', 'Y', 'N'), entry.comment_id,
          entry.creator_id, entry.reason,
          hr_general.decode_lookup ('ELE_ENTRY_REASON', entry.reason),
          entry.target_entry_id, entry.attribute_category, entry.attribute1,
          entry.attribute2, entry.attribute3, entry.attribute4,
          entry.attribute5, entry.attribute6, entry.attribute7,
          entry.attribute8, entry.attribute9, entry.attribute10,
          entry.attribute11, entry.attribute12, entry.attribute13,
          entry.attribute14, entry.attribute15, entry.attribute16,
          entry.attribute17, entry.attribute18, entry.attribute19,
          entry.attribute20, ELEMENT.element_type_id, elementtl.element_name,
          SUBSTR (ELEMENT.processing_type, 1, 1),
          hr_general.decode_lookup ('PROCESSING_TYPE',
                                    ELEMENT.processing_type),
          ELEMENT.processing_priority,
          SUBSTR (ELEMENT.process_in_run_flag, 1, 1),
          SUBSTR (ELEMENT.closed_for_entry_flag, 1, 1),
          SUBSTR (ELEMENT.additional_entry_allowed_flag, 1, 1),
          SUBSTR (ELEMENT.multiple_entries_allowed_flag, 1, 1),
          ELEMENT.input_currency_code,
          SUBSTR (pay_paywsmee_pkg.overridden (LINK.element_link_id,
                                               entry.assignment_id,
                                               sesh.effective_date
                                              ),
                  1,
                  1
                 ),
          SUBSTR (pay_paywsmee_pkg.adjusted (LINK.element_link_id,
                                             entry.assignment_id,
                                             sesh.effective_date
                                            ),
                  1,
                  1
                 ),
          SUBSTR (pay_paywsmee_pkg.processed (entry.element_entry_id,
                                              entry.original_entry_id,
                                              ELEMENT.processing_type,
                                              entry.entry_type,
                                              sesh.effective_date
                                             ),
                  1,
                  1
                 ),
          DECODE (NVL (entry_proc.source_asg_action_id, -1),
                  -1, 'N',
                  'Y'
                 ) retroactive,
          ELEMENT.classification_id, SUBSTR (LINK.costable_type, 1, 1),
          entry.subpriority, benefit.contributions_used, entry.creation_date,
          entry.created_by, entry.last_update_login, entry.last_updated_by,
          entry.last_update_date, entry.date_earned,
          pay_paywsmee_pkg.get_original_date_earned
                                 (entry.element_entry_id)
                                                         original_date_earned,
          entry.personal_payment_method_id,
          SUBSTR
             (pay_paywsmee_pkg.personal_payment_method
                                            (entry.personal_payment_method_id,
                                             entry.assignment_id,
                                             sesh.effective_date
                                            ),
              1,
              255
             ),
          ELEMENT.third_party_pay_only_flag, entry.ROWID row_id,
          entry.entry_information_category, entry.entry_information1,
          entry.entry_information2, entry.entry_information3,
          entry.entry_information4, entry.entry_information5,
          entry.entry_information6, entry.entry_information7,
          entry.entry_information8, entry.entry_information9,
          entry.entry_information10, entry.entry_information11,
          entry.entry_information12, entry.entry_information13,
          entry.entry_information14, entry.entry_information15,
          entry.entry_information16, entry.entry_information17,
          entry.entry_information18, entry.entry_information19,
          entry.entry_information20, entry.entry_information21,
          entry.entry_information22, entry.entry_information23,
          entry.entry_information24, entry.entry_information25,
          entry.entry_information26, entry.entry_information27,
          entry.entry_information28, entry.entry_information29,
          entry.entry_information30, -999999999999999
     FROM pay_element_types_f_tl elementtl,
          pay_element_types_f ELEMENT,
          ben_benefit_classifications benefit,
          pay_element_entries_f entry,
          pay_element_links_f LINK,
          pay_entry_process_details entry_proc,
          fnd_sessions sesh                                  /* TABLE JOINS */
    WHERE ELEMENT.element_type_id = elementtl.element_type_id
      AND elementtl.LANGUAGE = 'AR'
      AND ELEMENT.element_type_id = LINK.element_type_id
      AND ELEMENT.benefit_classification_id = benefit.benefit_classification_id(+)
      AND entry.element_link_id = LINK.element_link_id
      AND entry.element_entry_id =
                         entry_proc.element_entry_id(+)
                            /* ONLY DISPLAY ENTRIES FOR CERTAIN SUB-SYSTEMS */
      AND entry.creator_type IN
             ('H',                                                   /* MIX */
              'P',                                               /* BACKPAY */
              'SP',                                      /* SALARY PROPOSAL */
              'F',                                                 /* OTHER */
              'M',                               /* STATUTORY MATERNITY PAY */
              'S',                                    /* STATUTORY SICK PAY */
              'A',                                               /* ABSENCE */
              'D',                                           /* ADVANCE PAY */
              'DF',                                     /* ADVANCE PAY FORM */
              'R',                                    /* RETROPAY BY ACTION */
              'EE',                                  /* RETROPAY/ELEMENT EE */
              'RR',                                  /* RETROPAY/ELEMENT RR */
              'AD',                                /* ADVANCEPAY/ELEMENT AD */
              'AE',                                /* ADVANCEPAY/ELEMENT AE */
              'PR',                                  /* RETROPAY ELEMENT PR */
              'NR',                                  /* RETROPAY/ELEMENT NR */
              'FL'                                            /* FLSA ENTRY */
             )                     /* ONLY DISPLAY ENTRIES OF CERTAIN TYPES */
      AND entry.entry_type IN
             ('E', /* NORMAL ENTRY */ 'S', /* OVERRIDE */ 'D' /* ADDITIONAL */)
                       /* ONLY DISPLAY ENTRIES CURRENT AS OF EFFECTIVE DATE */
      AND USERENV ('sessionid') = sesh.session_id
      AND sesh.effective_date BETWEEN ELEMENT.effective_start_date AND ELEMENT.effective_end_date
      AND sesh.effective_date BETWEEN LINK.effective_start_date AND LINK.effective_end_date
      AND sesh.effective_date BETWEEN entry.effective_start_date AND entry.effective_end_date
   UNION ALL
   SELECT DISTINCT entry.element_entry_id, entry.assignment_id,
                   entry.effective_start_date, entry.effective_end_date,
                   entry.cost_allocation_keyflex_id, entry.updating_action_id,
                   entry.element_link_id, entry.original_entry_id,
                   entry.creator_type, entry.entry_type,
                   DECODE (entry.entry_type, 'D', 'Y', 'N'),
                   DECODE (entry.entry_type, 'S', 'Y', 'N'), entry.comment_id,
                   entry.creator_id, entry.reason,
                   hr_general.decode_lookup ('ELE_ENTRY_REASON', entry.reason),
                   entry.target_entry_id, entry.attribute_category,
                   entry.attribute1, entry.attribute2, entry.attribute3,
                   entry.attribute4, entry.attribute5, entry.attribute6,
                   entry.attribute7, entry.attribute8, entry.attribute9,
                   entry.attribute10, entry.attribute11, entry.attribute12,
                   entry.attribute13, entry.attribute14, entry.attribute15,
                   entry.attribute16, entry.attribute17, entry.attribute18,
                   entry.attribute19, entry.attribute20,
                   ELEMENT.element_type_id, elementtl.element_name,
                   SUBSTR (ELEMENT.processing_type, 1, 1),
                   hr_general.decode_lookup ('PROCESSING_TYPE',
                                             ELEMENT.processing_type
                                            ),
                   ELEMENT.processing_priority,
                   SUBSTR (ELEMENT.process_in_run_flag, 1, 1),
                   SUBSTR (ELEMENT.closed_for_entry_flag, 1, 1),
                   SUBSTR (ELEMENT.additional_entry_allowed_flag, 1, 1),
                   SUBSTR (ELEMENT.multiple_entries_allowed_flag, 1, 1),
                   ELEMENT.input_currency_code,
                   SUBSTR (pay_paywsmee_pkg.overridden (LINK.element_link_id,
                                                        entry.assignment_id,
                                                        sesh.effective_date
                                                       ),
                           1,
                           1
                          ),
                   SUBSTR (pay_paywsmee_pkg.adjusted (LINK.element_link_id,
                                                      entry.assignment_id,
                                                      sesh.effective_date
                                                     ),
                           1,
                           1
                          ),
                   SUBSTR
                        (pay_paywsmee_pkg.processed (entry.element_entry_id,
                                                     entry.original_entry_id,
                                                     ELEMENT.processing_type,
                                                     entry.entry_type,
                                                     sesh.effective_date
                                                    ),
                         1,
                         1
                        ),
                   DECODE (NVL (entry_proc.source_asg_action_id, -1),
                           -1, 'N',
                           'Y'
                          ) retroactive,
                   ELEMENT.classification_id,
                   SUBSTR (LINK.costable_type, 1, 1), entry.subpriority,
                   benefit.contributions_used, entry.creation_date,
                   entry.created_by, entry.last_update_login,
                   entry.last_updated_by, entry.last_update_date,
                   entry.date_earned,
                   pay_paywsmee_pkg.get_original_date_earned
                                 (entry.element_entry_id)
                                                         original_date_earned,
                   entry.personal_payment_method_id,
                   SUBSTR
                      (pay_paywsmee_pkg.personal_payment_method
                                            (entry.personal_payment_method_id,
                                             entry.assignment_id,
                                             sesh.effective_date
                                            ),
                       1,
                       255
                      ),
                   ELEMENT.third_party_pay_only_flag, entry.ROWID row_id,
                   entry.entry_information_category, entry.entry_information1,
                   entry.entry_information2, entry.entry_information3,
                   entry.entry_information4, entry.entry_information5,
                   entry.entry_information6, entry.entry_information7,
                   entry.entry_information8, entry.entry_information9,
                   entry.entry_information10, entry.entry_information11,
                   entry.entry_information12, entry.entry_information13,
                   entry.entry_information14, entry.entry_information15,
                   entry.entry_information16, entry.entry_information17,
                   entry.entry_information18, entry.entry_information19,
                   entry.entry_information20, entry.entry_information21,
                   entry.entry_information22, entry.entry_information23,
                   entry.entry_information24, entry.entry_information25,
                   entry.entry_information26, entry.entry_information27,
                   entry.entry_information28, entry.entry_information29,
                   entry.entry_information30, assact.assignment_action_id
              FROM pay_element_types_f_tl elementtl,
                   pay_element_types_f ELEMENT,
                   ben_benefit_classifications benefit,
                   pay_element_entries_f entry,
                   pay_element_links_f LINK,
                   pay_entry_process_details entry_proc,
                   pay_assignment_actions assact,
                   pay_payroll_actions payact,
                   fnd_sessions sesh                         /* TABLE JOINS */
             WHERE ELEMENT.element_type_id = elementtl.element_type_id
               AND elementtl.LANGUAGE = USERENV ('LANG')
               AND ELEMENT.element_type_id = LINK.element_type_id
               AND ELEMENT.benefit_classification_id = benefit.benefit_classification_id(+)
               AND entry.element_link_id = LINK.element_link_id
               AND entry.element_entry_id =
                         entry_proc.element_entry_id(+)
                            /* ONLY DISPLAY ENTRIES FOR CERTAIN SUB-SYSTEMS */
               AND entry.creator_type IN
                      ('H',                                          /* MIX */
                       'P',                                      /* BACKPAY */
                       'SP',                             /* SALARY PROPOSAL */
                       'F',                                        /* OTHER */
                       'M',                      /* STATUTORY MATERNITY PAY */
                       'S',                           /* STATUTORY SICK PAY */
                       'A',                                      /* ABSENCE */
                       'D',                                  /* ADVANCE PAY */
                       'DF',                            /* ADVANCE PAY FORM */
                       'R',                           /* RETROPAY BY ACTION */
                       'EE',                         /* RETROPAY/ELEMENT EE */
                       'RR',                         /* RETROPAY/ELEMENT RR */
                       'AD',                       /* ADVANCEPAY/ELEMENT AD */
                       'AE',                       /* ADVANCEPAY/ELEMENT AE */
                       'PR',                         /* RETROPAY ELEMENT PR */
                       'NR',                         /* RETROPAY/ELEMENT NR */
                       'FL'                                   /* FLSA ENTRY */
                      )            /* ONLY DISPLAY ENTRIES OF CERTAIN TYPES */
               AND entry.entry_type IN
                      ('E', /* NORMAL ENTRY */ 'S', /* OVERRIDE */ 'D' /* ADDITIONAL */)
                       /* ONLY DISPLAY ENTRIES CURRENT AS OF EFFECTIVE DATE */
               AND USERENV ('sessionid') = sesh.session_id
               AND sesh.effective_date BETWEEN ELEMENT.effective_start_date
                                           AND ELEMENT.effective_end_date
               AND sesh.effective_date BETWEEN LINK.effective_start_date
                                           AND LINK.effective_end_date
               AND entry.assignment_id = assact.assignment_id
               AND assact.payroll_action_id = payact.payroll_action_id
               AND payact.date_earned BETWEEN ELEMENT.effective_start_date
                                          AND ELEMENT.effective_end_date
               AND payact.date_earned BETWEEN LINK.effective_start_date
                                          AND LINK.effective_end_date
               AND entry.effective_start_date <= payact.date_earned
               AND entry.effective_end_date >=
                      DECODE
                         (ELEMENT.proration_group_id,
                          NULL, payact.date_earned,
                          pay_interpreter_pkg.prorate_start_date
                                                 (assact.assignment_action_id,
                                                  ELEMENT.proration_group_id
                                                 )

                         )

Oracle HRMS Query - Absence


SELECT   /*+ rule*/
            xx.person_id, xx.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,
         
            --, LOCATION,
            b.admission_code, b.admission_date, b.amendment_date,
            b.amendment_reason, b.concatenated_segments, b.contact_grade,
            b.contact_type, b.CONTEXT, 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
       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 xx                      --xxhr_zainiq_mv  xx
      WHERE ABS.person_id = xx.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 Scripts(Queries) - Employee Relation



SELECT
rel.PERSON_ID Person_id ,
rel.CONTACT_PERSON_ID CONTACT_PERSON_ID,
per.full_name,
per.date_of_birth ,
hr_general.decode_lookup ('SEX', per.sex) gender ,
(SELECT
    look_up.meaning
 FROM hr_lookups look_up
 WHERE look_up.lookup_type = 'CONTACT'
    AND look_up.enabled_flag = 'Y'
    and look_up.lookup_code =  rel.CONTACT_TYPE
)  Relation
FROM
    per_contact_relationships rel,
    per_people_f per
WHERE
    rel.CONTACT_PERSON_ID = per.person_id and
    per.BUSINESS_GROUP_ID=hr_general.GET_BUSINESS_GROUP_ID

Oracle HRMS Scripts(Queries) - Contacts



SELECT /*+ rule */
  xx.employee_number empno,
  xx.full_name employee_full_name,
  per.effective_start_date,
  per.last_name contact_last_name,
  per.first_name contact_first_name,
  per.full_name contact_full_name,
  InitCap(per.title) Title,
  per.pre_name_adjunct  prefix,
  per.suffix,
  per.middle_names,
  hr_general.decode_lookup ('SEX', per.sex) gender,
  ppt.USER_PERSON_TYPE Person_type,
  per.national_identifier national_identifier,
  per.date_of_birth,
  per.town_of_birth,
  hr_general.decode_lookup ('MAR_STATUS',per.marital_status) marital_status,
  per.region_of_birth,
  hr_general.decode_lookup ('NATIONALITY', per.nationality) nationality,
  per.country_of_birth,
  per.registered_disabled_flag,
  per.email_address,
  per.honors,
  per.known_as preffered_name,
  per.previous_last_name,
  per.correspondence_language,
  --
  --
  per.attribute1 religion,
  per.attribute2 place_of_birth,
  per.attribute3 no_of_wife,
  per.attribute4 hajj_leave_taken,
  per.attribute5 citizenship,
  per.attribute6 marriage_leave_taken,
  per.attribute7 marriage_date,
  per.attribute8 xemployee_number,
  --
       pcr.date_start Relationship_start_date ,
       lkp.meaning Relationship_type ,
       --koc_get.emp(pcr.PERSON_ID) Relation_ship_from_employee,
       pcr.CONTACT_PERSON_ID Related_to_employee,
       --
       pcr.primary_contact_flag Primary_contact,
       pcr.third_party_pay_flag Payment_Recipient,
       pcr.rltd_per_rsds_w_dsgntr_flag Shared_Residence,
       pcr.personal_flag Personal_Relationship,
       pcr.beneficiary_flag Beneficiary,
       pcr.dependent_flag Dependent,
       pcr.sequence_number Sequence_Number,
       pcr.bondholder_flag Create_Mirror,
       pcr.contact_type    Mirror_relaion_type,
       --
       pcr.cont_attribute1 Disabled,
       pcr.cont_attribute2 isZain_Employee,
       pcr.cont_attribute5 Dependancy_ceased_date
--       pcr.cont_attribute3 Dependancy_restarted_date,
--       pcr.cont_attribute6 Name_of_school,
--       pcr.cont_attribute7 School_grade,
--       pcr.cont_attribute8 School_class,
--       pcr.cont_attribute9 School_year,
--       pcr.cont_attribute10 EAP_CAP,
--       pcr.cont_attribute20 EAP_CAP_reciepient_number,
--       pcr.cont_attribute11 School_fees_paid_by_emp,
--       pcr.cont_attribute12 School_fees_paid_currency,
--       pcr.cont_attribute13 Claimed_date,
--       pcr.cont_attribute14 Residnecy_expire_date,
--       pcr.cont_attribute15 Resident_in_kuwait,
--       pcr.cont_attribute16 Diceased_date,
--       pcr.cont_attribute17 Nationaliy_group,
--     pcr.cont_attribute18 Medical_squence_Number,
--     pcr.cont_attribute19 Dependent_number
FROM
       per_all_people_f per ,
       per_periods_of_service pps,
       per_person_types ppt,
       per_contact_relationships pcr,
       hr_lookups lkp,
       per_people_f  xx
WHERE
  pcr.person_id = xx.person_id AND
  TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE,-1))) BETWEEN per.effective_start_date AND  per.effective_end_date
  AND TRUNC(SYSDATE) BETWEEN xx.effective_start_date AND  xx.effective_end_date
  AND per.person_id = pps.PERSON_ID(+)
  AND per.person_type_Id = ppt.person_type_id(+)
  AND  lkp.lookup_type(+) = 'CONTACT'
  AND  lkp.lookup_code(+) = pcr.contact_type
  AND  pcr.CONTACT_PERSON_ID  = per.person_id
ORDER BY pcr.contact_person_id
/

Oracle HRMS Scripts (Queries) - Entry Value



SELECT   entry.assignment_id,
         asg.assignment_number,
         TYPE.element_name,
         CASE
            WHEN pec.classification_name = 'Earnings'
            THEN
               'Earnings'
            WHEN pec.classification_name = 'Supplemental Earnings'
            THEN
               'Supplemental Earnings'
            --
         WHEN INSTR (pec.classification_name, 'Deductions') >= 1
            THEN
               'Deductions'
            WHEN INSTR (pec.classification_name, 'Information') >= 1
            THEN
               'Information'
            ELSE
               pec.classification_name
         END
            classification,
         CASE
            WHEN INSTR (pec.classification_name, 'Earning') >= 1 THEN '1'
            WHEN INSTR (pec.classification_name, 'Deductions') >= 1 THEN '2'
            WHEN INSTR (pec.classification_name, 'Information') >= 1 THEN '3'
            ELSE pec.classification_name
         END
            class_sort_order,
         --
         TYPE.processing_type,
         DECODE (TYPE.processing_type, 'R', 'Recurring', 'Non Recurring')
            processing_type_meaning,
         TYPE.post_termination_rule,
         DECODE (TYPE.post_termination_rule,
                 'L',
                 'Last Standard Process',
                 'F',
                 'Final Close',
                 'A',
                 'Acutal Termination')
            termination_rule_meaning,
         TYPE.input_currency_code,
         TYPE.output_currency_code,
         inpval.uom,
         DECODE (inpval.uom,
                 'M',
                 'Money',
                 'N',
                 'Number',
                 'D',
                 'Date',
                 'ND',
                 'Day',
                 'C',
                 'Character')
            unit_of_measure,
         NVL (
            DECODE (
               inpval.uom,
               'M',
               fnd_number.canonical_to_number (VALUE.screen_entry_value),
               'N',
               fnd_number.canonical_to_number (VALUE.screen_entry_value)
            ),
            0
         )
            e_value_num,
         NVL (VALUE.screen_entry_value, '0') e_value,
         inpval.NAME value_name,
         VALUE.element_entry_id,
         inpval.effective_start_date eft_st_date_inpval,
         inpval.effective_end_date eft_ed_date_inpval,
         LINK.effective_start_date eft_st_date_link,
         LINK.effective_end_date eft_end_date_link,
         TYPE.effective_start_date eft_st_date_type,
         TYPE.effective_end_date eft_end_date_type,
         entry.effective_start_date eft_st_date_entry,
         entry.effective_end_date eft_end_date_entry,
         asg.effective_start_date eft_st_date_asg,
         asg.effective_end_date eft_end_date_asg,
         TYPE.element_type_id element_type_id
  FROM   pay_element_types_f TYPE,
         pay_element_links_f LINK,
         pay_element_entries_f entry,
         pay_element_entry_values_f VALUE,
         pay_input_values_f inpval,
         pay_element_classifications pec,
         APPS.PER_ASSIGNMENTS_F2 asg
 WHERE       TYPE.element_type_id = LINK.element_type_id
         AND entry.element_link_id = LINK.element_link_id
         --AND ENTRY.ENTRY_TYPE IN ('A', 'R')
         --AND VALUE.element_entry_id(+) = entry.element_entry_id
         AND VALUE.element_entry_id = entry.element_entry_id
         AND entry.effective_start_date BETWEEN TYPE.effective_start_date
                                            AND  TYPE.effective_end_date
         AND entry.effective_start_date BETWEEN link.effective_start_date
                                            AND  link.effective_end_date
         AND entry.effective_start_date BETWEEN inpval.effective_start_date
                                            AND  inpval.effective_end_date
         AND entry.effective_start_date BETWEEN VALUE.effective_start_date
                                            AND  VALUE.effective_end_date
         AND entry.effective_start_date BETWEEN asg.effective_start_date
                                            AND  asg.effective_end_date
         --AND VALUE.effective_start_date(+) = entry.effective_start_date
         --AND VALUE.effective_end_date(+) = entry.effective_end_date
         --AND inpval.input_value_id(+) = VALUE.input_value_id
         AND inpval.input_value_id = VALUE.input_value_id
         AND pec.classification_id = TYPE.classification_id
         AND asg.assignment_id = entry.assignment_id
         AND (UPPER (inpval.NAME) NOT LIKE '%FUTU%'
              OR inpval.NAME IS NOT NULL)
         AND assignment_number NOT LIKE 'XX%'