oracle hr and payroll related queries

6
ORACLE HR AND PAYROLL RELATED QUERIES Posted October 26th, 2010 by faisal & filed under HR / Payroll Related Queries . Oracle EBS/Apps R12. ( Oracle HR / Payroll ) Important Queries Note: All following queries are customized and may not fit in your setup but can give you some idea to get appropriate results. Thanks Costing Detail Query: select paf.ASSIGNMENT_NUMBER, ppf.FULL_NAME ,pet.element_name,pca.CONCATENATED_SEGMENTS, decode(pc.DEBIT_OR_CREDIT,’D’,pc.COSTED_VALUE) Debit, decode(pc.DEBIT_OR_CREDIT,’C’,pc.COSTED_VALUE) Credit from per_people_f ppf, per_assignments_f paf, pay_assignment_actions pav, pay_payroll_actions ppa, pay_costs pc, PAY_COST_ALLOCATION_KEYFLEX pca, pay_element_types_f pet, pay_run_results prr, pay_run_result_values prrv where ppf.PERSON_ID=paf.PERSON_ID and paf.ASSIGNMENT_ID=pav.ASSIGNMENT_ID and paf.PRIMARY_FLAG=’Y’ and ppf.EMPLOYEE_NUMBER=:p_emp_no and pav.PAYROLL_ACTION_ID=ppa.PAYROLL_ACTION_ID and trunc(ppa.EFFECTIVE_DATE) between :p_start_date and :p_end_date and pav.ASSIGNMENT_ACTION_ID=pc.ASSIGNMENT_ACTION_ID and pc.COST_ALLOCATION_KEYFLEX_ID=pca.COST_ALLOCATION_KEYFLEX_ID and pet.ELEMENT_TYPE_ID=prr.ELEMENT_TYPE_ID and prr.RUN_RESULT_ID=prrv.RUN_RESULT_ID and pc.RUN_RESULT_ID=prrv.RUN_RESULT_ID and pc.INPUT_VALUE_ID=prrv.INPUT_VALUE_ID and :p_end_date between pet.EFFECTIVE_START_DATE and pet.EFFECTIVE_END_DATE and ppf.EFFECTIVE_END_DATE = (select max(effective_end_date) from per_people_f where person_id=ppf.PERSON_ID) and paf.EFFECTIVE_END_DATE = (select max(effective_end_date) from per_assignments_f where assignment_id=paf.ASSIGNMENT_ID)

Upload: balaoracleapps

Post on 18-Jul-2016

30 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Oracle Hr and Payroll Related Queries

ORACLE HR AND PAYROLL RELATED QUERIESPosted October 26th, 2010 by faisal  & filed under HR / Payroll Related Queries .Oracle EBS/Apps R12. ( Oracle HR / Payroll ) Important Queries

Note: All following queries are customized and may not fit in your setup but can give you some idea to get appropriate results. Thanks

Costing Detail Query:selectpaf.ASSIGNMENT_NUMBER, ppf.FULL_NAME ,pet.element_name,pca.CONCATENATED_SEGMENTS,decode(pc.DEBIT_OR_CREDIT,’D’,pc.COSTED_VALUE) Debit,decode(pc.DEBIT_OR_CREDIT,’C’,pc.COSTED_VALUE) Creditfromper_people_f ppf,per_assignments_f paf,pay_assignment_actions pav,pay_payroll_actions ppa,pay_costs pc,PAY_COST_ALLOCATION_KEYFLEX pca,pay_element_types_f pet,pay_run_results prr,pay_run_result_values prrvwhere ppf.PERSON_ID=paf.PERSON_IDand paf.ASSIGNMENT_ID=pav.ASSIGNMENT_IDand paf.PRIMARY_FLAG=’Y’and ppf.EMPLOYEE_NUMBER=:p_emp_noand pav.PAYROLL_ACTION_ID=ppa.PAYROLL_ACTION_IDand trunc(ppa.EFFECTIVE_DATE) between :p_start_date and :p_end_dateand pav.ASSIGNMENT_ACTION_ID=pc.ASSIGNMENT_ACTION_IDand pc.COST_ALLOCATION_KEYFLEX_ID=pca.COST_ALLOCATION_KEYFLEX_IDand pet.ELEMENT_TYPE_ID=prr.ELEMENT_TYPE_IDand prr.RUN_RESULT_ID=prrv.RUN_RESULT_IDand pc.RUN_RESULT_ID=prrv.RUN_RESULT_IDand pc.INPUT_VALUE_ID=prrv.INPUT_VALUE_IDand :p_end_date between pet.EFFECTIVE_START_DATE and pet.EFFECTIVE_END_DATEand ppf.EFFECTIVE_END_DATE = (select max(effective_end_date) from per_people_f where person_id=ppf.PERSON_ID)and paf.EFFECTIVE_END_DATE = (select max(effective_end_date) from per_assignments_f where assignment_id=paf.ASSIGNMENT_ID)

 

 

Query to to find the Employee Supervisor name

Page 2: Oracle Hr and Payroll Related Queries

SELECT papf1.full_name supervisor_nameFrom apps.per_all_people_f papf,apps.per_all_assignments_f paaf,apps.per_all_people_f papf1WHERE papf.person_id = paaf.person_idAND paaf.primary_flag = ‘Y’AND paaf.assignment_type = ‘E’AND paaf.supervisor_id = papf1.person_idAND papf1.current_employee_flag = ‘Y’AND papf.business_group_id = paaf.business_group_idAND SYSDATE BETWEEN papf.effective_start_date and papf.effective_end_dateAND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_dateAND SYSDATE BETWEEN papf1.effective_start_date AND papf1.effective_end_dateAND papf.employee_number = :p_emp_number;

Query to find out payroll Costing Detail  /  “How to find out payroll costed accounts” / “Query to find out Payroll Charged Accounts”.SELECT distinct d.EMPLOYEE_NUMBER,d.FULL_NAME,a.CONCATENATED_SEGMENTS, a.element_name,decode(a.debit_or_credit,’Debit’,COSTED_VALUE,”) Debit  ,decode(debit_or_credit,’Credit’,COSTED_VALUE,”) CreditFROM  pay_costs_v a, pay_assignment_actions_v b,per_assignments_x c,per_people_x dwhere     d.EMPLOYEE_NUMBER= nvl(:p_emp_no,d.EMPLOYEE_NUMBER)and   trunc (b.EFFECTIVE_DATE)  between :p_from_date and :p_to_dateand a.ASSIGNMENT_ACTION_ID=b.ASSIGNMENT_ACTION_IDand  b.ASSIGNMENT_ID=c.ASSIGNMENT_IDand c.PERSON_ID=d.PERSON_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 ewhere a.PERSON_ID=b.PERSON_IDand b.ASSIGNMENT_ID=C.ASSIGNMENT_IDand a.EMPLOYEE_NUMBER is not null–and a.EMPLOYEE_NUMBER=:emp_numand 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_dateand b.PAYROLL_ID=62and :p_effective_date between a.EFFECTIVE_START_DATE and a.EFFECTIVE_END_DATEand :p_effective_date between b.EFFECTIVE_START_DATE and b.EFFECTIVE_END_DATEand a.PERSOn_id = e.PERSON_IDand a.EFFECTIVE_START_DATE between e.EFFECTIVE_START_DATE and e.EFFECTIVE_END_DATEand e.PERSON_TYPE_ID = x.PERSON_TYPE_IDand x.SYSTEM_PERSON_TYPE = ‘EMP’

 

 

 

Page 3: Oracle Hr and Payroll Related Queries

Query fo Find out all Earning and Deduction Elements and values after Payroll RunSELECT ppf.employee_number,ppf.person_id,ppf.full_name,ppa.TIME_PERIOD_ID,ppa.EFFECTIVE_DATE,TP.PERIOD_NAME,paf.ORGANIZATION_ID,sum(decode(pec.CLASSIFICATION_NAME,’Earnings’,to_number(rrv.result_value),0)) Earnings,sum(decode(pec.CLASSIFICATION_NAME,’Voluntary Deductions’,to_number(rrv.result_value),‘Involuntary Deductions’,to_number(rrv.result_value),‘Employer Charges’,to_number(rrv.result_value),0)) Deductions–ety.element_name,ety.CLASSIFICATION_ID— PD.SEGMENT5  POSITION_NO,PD.SEGMENT6 POSITION_NAME,FROM per_people_x ppf,per_assignments_x paf,pay_assignment_actions pas,pay_payroll_actions ppa,pay_run_results rr,pay_run_result_values rrv,pay_element_types_f ety,pay_input_values_F I,PER_TIME_PERIODS TP,PAY_ELEMENT_CLASSIFICATIONS_VL pecWHERE ppf.person_id = paf.person_idAND paf.assignment_id = pas.assignment_idAND pas.assignment_action_id = rr.assignment_action_idAND ppa.payroll_action_id = pas.payroll_action_idAND rr.element_type_id = ety.element_type_idAND i.element_type_id = ety.element_type_idAND rrv.run_result_id = rr.run_result_idAND rrv.input_value_id = i.input_value_idand  TP.TIME_PERIOD_ID = PPA.TIME_PERIOD_IDand ety.CLASSIFICATION_ID=pec.CLASSIFICATION_IDAND i.name = ‘Pay Value’—   AND HR_GENERAL.DECODE_LATEST_POSITION_DEF_ID(PAF.POSITION_ID) = PD.POSITION_DEFINITION_IDand ppa.EFFECTIVE_DATE  BETWEEN    :p_st_effect_date  AND  :p_end_effect_dateand ppf.employee_number  = nvl(:p_emp_number,ppf.employee_number)group by  ppf.full_name,ppa.TIME_PERIOD_ID,effective_date,–To_Number(Wassa_HR_PACKAGE.Nid_Salary_By_Date(paf.assignment_id,ppa.EFFECTIVE_DATE,’N’)),ppf.employee_number,ppf.person_id ,–PD.SEGMENT5 ,PD.SEGMENT6,TP.period_name,paf.ORGANIZATION_ID

Query for Oracle Payroll Salary Slip /  Salary Slip Detail Report Query / How to find out detail of salary slip/ Element wise Landscape Salary Slip at Payroll Run Levle  or quick pay levelNote:  I have hardcoded element names. You can also hardcode your elements to get Landscaped salary slip.

SELECT ppf.employee_number,ppf.person_id,ppf.full_name,ppa.TIME_PERIOD_ID,ppa.EFFECTIVE_DATE  ,TP.PERIOD_NAME,

Page 4: Oracle Hr and Payroll Related Queries

sum(decode(ety.element_name,’Basic Salary’                         ,TO_NUMBER(rrv.result_value),‘Basic Sick Leave Payment’             ,TO_NUMBER(rrv.result_value),‘Basic Out Work Incident Leave Payment’,TO_NUMBER(rrv.result_value),0)) Earned_salary,/********************************************************************************************************/sum(decode(ety.element_name,’Transportation Allowance’                      ,TO_NUMBER(rrv.result_value),‘Transportation Sick Leave Payment’             ,TO_NUMBER(rrv.result_value),‘Transportation Out Work Incident Leave Payment’,TO_NUMBER(rrv.result_value),0)) Transportation_allowance,/*************************************************************************************************************/sum(decode(ety.element_name,’Work Type Allowance’                      ,TO_NUMBER(rrv.result_value),‘Work Type Sick Leave Payment’             ,TO_NUMBER(rrv.result_value),‘Work Type Out Work Incident Leave Payment’,TO_NUMBER(rrv.result_value),0)) worktype_allowance,/***************************************************************************************************************/sum(decode(ety.element_name,’Damages Allowance’                      ,TO_NUMBER(rrv.result_value),‘Damages Sick Leave Payment’             ,TO_NUMBER(rrv.result_value),‘Damages Out Work Incident Leave Payment’,TO_NUMBER(rrv.result_value),0)) Damage_allowance,/*****************************************************************************************************************/sum(decode(ety.element_name,’Danger Allowance’                      ,TO_NUMBER(rrv.result_value),‘Danger Sick Leave Payment’             ,TO_NUMBER(rrv.result_value),‘Danger Out Work Incident Leave Payment’,TO_NUMBER(rrv.result_value),0)) Danger_allowance,/*************************************************************************************************************/sum(decode(ety.element_name,’Inflation Allowance’    ,TO_NUMBER(rrv.result_value),0)) Inflation_Allowance,/*********************************************************  Deductions  ************************************************/sum(decode(ety.element_name,’Loan Recovery’         ,TO_NUMBER(rrv.result_value),0)) Loan_recovery,sum(decode(ety.element_name,’Loan Recovery Housing’ ,TO_NUMBER(rrv.result_value),0)) Loan_Recovery_Housing,sum(decode(ety.element_name,’Loan Recovery Others’  ,TO_NUMBER(rrv.result_value),0)) Loan_Recovery_Others,sum(decode(ety.element_name,’Housing Deduction’     ,TO_NUMBER(rrv.result_value),0)) Housing_Deduction,sum(decode(ety.element_name,’Penalty’               ,TO_NUMBER(rrv.result_value),0)) Penalty,/***********************************************************************************************************************/sum(decode(ety.element_name,’Civil Pension’                      ,TO_NUMBER(rrv.result_value),‘Social Insurance’             ,TO_NUMBER(rrv.result_value),0)) Civil_pension,/************************************************************************************************************************************/sum(decode(ety.element_name,’In Out Leave Deduction’ ,TO_NUMBER(rrv.result_value),0)) In_Out_Leave_Deduction,sum(decode(ety.element_name,’Unpaid Leave Deduction’ ,TO_NUMBER(rrv.result_value),0)) Unpaid_Leave_Deduction,

Page 5: Oracle Hr and Payroll Related Queries

sum(decode(ety.element_name,’Retrieve Mony Recovery’ ,TO_NUMBER(rrv.result_value),0)) Retrieve_Mony_RecoveryFROM per_people_x ppf,per_assignments_x paf,pay_assignment_actions pas ,pay_payroll_actions ppa,pay_run_results rr,pay_run_result_values rrv,pay_element_types_f ety,pay_input_values_F I ,PER_TIME_PERIODS TP—     PER_POSITION_DEFINITIONS PD— PAY_INPUT_VALUES_FWHERE ppf.person_id = paf.person_idAND paf.assignment_id = pas.assignment_idAND pas.assignment_action_id = rr.assignment_action_idAND ppa.payroll_action_id = pas.payroll_action_idAND rr.element_type_id = ety.element_type_idAND i.element_type_id = ety.element_type_idAND rrv.run_result_id = rr.run_result_idAND rrv.input_value_id = i.input_value_idand  TP.TIME_PERIOD_ID = PPA.TIME_PERIOD_IDAND i.name = ‘Pay Value’—   AND HR_GENERAL.DECODE_LATEST_POSITION_DEF_ID(PAF.POSITION_ID) = PD.POSITION_DEFINITION_IDand ppa.EFFECTIVE_DATE  BETWEEN    :P_FROM_DATE      AND  :P_TO_DATEand ppf.employee_number    = :P_Employee_number–in(34000/*1546014859,14666,35343,15201,15202*/)group by  ppf.full_name,ppa.TIME_PERIOD_ID,effective_date,ppf.employee_number,ppf.person_id ,–PD.SEGMENT5 ,PD.SEGMENT6,TP.period_nameorder  by  ppa.EFFECTIVE_DATE