Tuesday 21 May 2019

Query to fetch Legal Employer and Payroll of an employee in Oracle Cloud HCM

PER_LEGAL_EMPLOYERS consists the Legal Employer details

select papf.person_number,
ppnf.full_name,
PAP.PAYROLL_NAME,
PAP.PAYROLL_NAME,
PLE.NAME LE_NAME
from
per_all_people_f papf,
per_person_names_f ppnf,
per_all_assignments_f paaf,
PER_PERIODS_OF_SERVICE ppos,
pay_payroll_assignments ppasg,
PAY_ASSIGNED_PAYROLLS_DN papd,
pay_all_payrolls_f pap,
per_legal_employers ple
where 1=1
and papf.person_id = paaf.person_id
and papf.person_id = ppnf.person_id
and papf.person_id = ppos.person_id
and paaf.period_of_service_id = ppos.period_of_service_id
and paaf.assignment_id = ppasg.hr_assignment_id(+)
--and paaf.person_id = ppasg.person_id
and ppasg.payroll_term_id = papd.payroll_term_id(+)
and papd.payroll_id = pap.payroll_id(+)
and paaf.legal_entity_id = ple.organization_id
and ple.status = 'A'
and paaf.PRIMARY_FLAG ='Y'
--and paaf.ASSIGNMENT_TYPE = 'E'
AND PPOS.date_start = (SELECT max(date_start) FROM PER_PERIODS_OF_SERVICE PPOS_IN WHERE PPOS_IN.person_id = PAPF.person_id)
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and trunc(sysdate) between ppnf.effective_start_date and ppnf.effective_end_date
and trunc(sysdate) between paaf.effective_start_date and paaf.effective_end_date
and trunc(sysdate) between ppasg.start_date(+) and ppasg.end_date(+)
and trunc(sysdate) between papd.start_date(+) and papd.end_date(+)
and trunc(sysdate) between pap.effective_start_date(+) and pap.effective_end_date(+)
and trunc(sysdate) between ple.effective_start_date and ple.effective_end_date
and ppnf.name_type='GLOBAL'--'US'
and paaf.assignment_type IN ('E','C','P','N')
and papf.person_number='21029'

No comments:

Post a Comment