Showing posts with label composite. Show all posts
Showing posts with label composite. Show all posts

Saturday, April 17, 2021

Composite Query

Composite Query enables us to combine data from existing queries and then apply filters, aggregates, and so on before presenting the report results, which show the combined data set. Composite Query retrieves multiple levels of related information on existing queries and presents the combined data as a single and flattened query result. There is good amount of info on how these work, limitation etc so I am not going to cover those here. I found them pretty useful to create inline SQL or query which isn't  possible via the regular PS Query (Query Manager) or even via Connected query feature in PeopleSoft.

So for this POC I am running PT 8.58.05 on HCM 9.2 (PUM 35). The SQL or output that I am trying to re-produce is as follows. 

I am listing employees from PS_JOB but I want to list their min ORIG_HIRE_DT value regardless of their current relationship in the orignatization. 

So I created two simple queries in Query Manager as follows.

Parent_Query

SELECT A.EMPLID, A.EMPL_RCD, (CONVERT(CHAR(10),A.EFFDT,121)), A.EFFSEQ,  (CONVERT(CHAR(10),A.LAST_HIRE_DT,121))
  FROM PS_JOB A, PS_EMPLMT_SRCH_QRY A1
  WHERE ( A.EMPLID = A1.EMPLID
    AND A.EMPL_RCD = A1.EMPL_RCD
    AND A1.OPRID = 'PS'
    AND ( A.EFFDT =
        (SELECT MAX(A_ED.EFFDT) FROM PS_JOB A_ED
        WHERE A.EMPLID = A_ED.EMPLID
          AND A.EMPL_RCD = A_ED.EMPL_RCD
          AND A_ED.EFFDT <= SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10))
    AND A.EFFSEQ =
        (SELECT MAX(A_ES.EFFSEQ) FROM PS_JOB A_ES
        WHERE A.EMPLID = A_ES.EMPLID
          AND A.EMPL_RCD = A_ES.EMPL_RCD
          AND A.EFFDT = A_ES.EFFDT) ))


Inline_Query 

SELECT A.EMPLID, A.ORG_INSTANCE_ERN, MIN( (CONVERT(CHAR(10),A.ORIG_HIRE_DT,121)))
  FROM PS_PER_ORG_INST A, PS_PERS_SRCH_QRY A1
  WHERE ( A.EMPLID = A1.EMPLID
    AND A1.OPRID = 'PS')
  GROUP BY  A.EMPLID,  A.ORG_INSTANCE_ERN

Navigated to Reporting Tools > Composite Query > Composite Query Manager and stepped through the wizard.

1. Gave a name to the composite query

2. Provided the Query 1 and Query values. So in my case Query 1 = Parent_Query and Query 2 = Inline_Query. Unfortunately we cannot have more than one inline SQLs, so this looks like a limitation.




3.   Sepcified Query Joins as shown below.


4. On the Output fields page I made the selections as shown below.



5.  On the final page set the status as active and saved the page.



Hovering over the gear icon next to the SQL button presents the option to Run/Preview the data or ouput.