RB_CAL_DR_VW

(SQL View)
Index Back

Sales Rep Direct Mgr View

This view retrieves information from territory tree tables to find the next level manager for a sales rep.

SELECT DISTINCT A.PERSON_ID , E.SYNCID , E.SYNCDTTM , MAX(A.PERSON_ID_MANAGER) FROM PS_RSF_ACC_SUSER A , PSTREENODE B , PSTREENODE C , PS_RSF_TR_TEAM D , PS_RSF_TR_TEAM D1 , PS_RD_PERSON E WHERE A.PERSON_ID > ' ' AND A.PERSON_ID <> A.PERSON_ID_MANAGER AND A.PERSON_ID = E.PERSON_ID AND A.TREE_NAME = B.TREE_NAME AND B.TREE_NODE = A.TERRITORY_ID AND B.PARENT_NODE_NAME = A.TERRITORY_PARENT AND B.EFFDT = C.EFFDT AND B.PARENT_NODE_NAME = C.TREE_NODE AND B.TREE_LEVEL_NUM = C.TREE_LEVEL_NUM + 1 AND D.TREE_NAME = A.TREE_NAME AND D.PERSON_ID = A.PERSON_ID_MANAGER AND ( D.PRIMARY_USER = 'Y' OR NOT EXISTS ( SELECT 'X' FROM PS_RSF_TR_TEAM D1 WHERE D.TREE_NAME = D1.TREE_NAME AND D.TERRITORY_ID = D1.TERRITORY_ID AND D.EFFDT = D1.EFFDT AND D1.PRIMARY_USER = 'Y')) AND B.EFFDT = ( SELECT MAX(EFFDT) FROM PSTREENODE E WHERE E.TREE_NAME = B.TREE_NAME AND EFFDT <= %CurrentDateIn) GROUP BY A.PERSON_ID, E.SYNCID, E.SYNCDTTM

# PeopleSoft Field Name PeopleSoft Field Type Database Column Type Description
1 PERSON_ID Character(15) VARCHAR2(15) NOT NULL Person ID
2 SYNCID Number(10,0) DECIMAL(10) NOT NULL The Synchronization ID field stores a value generated by the sync processor. The value is used to identify the type of object that the sync processor is about to handle.
3 SYNCDTTM DateTime(26) TIMESTAMP Synchronization Last Update Date Time
4 PERSON_ID_MANAGER Character(15) VARCHAR2(15) NOT NULL Contact Identifier for Treasury Contacts