Search This Blog

Monday, September 4, 2023

Apps R12 Employee Change Organization Query


SELECT PPF.EMPLOYEE_NUMBER,

            PPF.FULL_NAME,

            (SELECT NAME

               FROM HR_ALL_ORGANIZATION_UNITS

              WHERE ORGANIZATION_ID = PAAF.ORGANIZATION_ID) NEW_ORG,

            PAAF.ORGANIZATION_ID NEW_ORG_ID,

            PAAF.EFFECTIVE_START_DATE CHANGE_DATE,

--            PAAF_PREV.EFFECTIVE_START_DATE,

            PAAF_PREV.ORGANIZATION_ID OLD_ORG_ID,

            (SELECT NAME

               FROM HR_ALL_ORGANIZATION_UNITS

              WHERE ORGANIZATION_ID = PAAF_PREV.ORGANIZATION_ID) OLD_ORG

              ,PAAF.PAYROLL_ID 

       FROM PER_ALL_ASSIGNMENTS_F PAAF,

            PER_ALL_ASSIGNMENTS_F PAAF_PREV,

            PAY_PEOPLE_GROUPS PPG,

            PAY_PEOPLE_GROUPS PPG_PREV,

            PER_ALL_PEOPLE_F PPF

      WHERE     PAAF_PREV.EFFECTIVE_END_DATE + 1 = PAAF.EFFECTIVE_START_DATE

            AND PAAF_PREV.ASSIGNMENT_ID = PAAF.ASSIGNMENT_ID

            AND PAAF_PREV.ASSIGNMENT_TYPE = 'E'

            --AND PPF.EMPLOYEE_NUMBER = '1451'

            AND PAAF.ASSIGNMENT_TYPE = 'E'

            AND PAAF.ORGANIZATION_ID <> PAAF_PREV.ORGANIZATION_ID

            AND PAAF.PEOPLE_GROUP_ID = PPG.PEOPLE_GROUP_ID

            AND PAAF_PREV.PEOPLE_GROUP_ID = PPG_PREV.PEOPLE_GROUP_ID

            AND PAAF.EFFECTIVE_START_DATE BETWEEN PPF.EFFECTIVE_START_DATE

                                              AND PPF.EFFECTIVE_END_DATE

            AND PAAF.PERSON_ID = PPF.PERSON_ID

            AND PPF.BUSINESS_GROUP_ID = 81

--            AND PAAF.PAYROLL_ID IN (61,62,63,64,81)

--            AND PAAF.EFFECTIVE_START_DATE BETWEEN TO_DATE('01-JAN-2020') AND TO_DATE('31-DEC-2020')

--            ORDER BY TO_NUMBER(EMPLOYEE_NUMBER)

   ORDER BY PAAF.EFFECTIVE_START_DATE ASC;

No comments:

Post a Comment