Created
October 25, 2019 14:48
-
-
Save nickdavies791/67ba9bc99d26ae3bb5c8b1fec3e967d3 to your computer and use it in GitHub Desktop.
Returns unsigned purchase orders over given date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------- | |
/** | |
* | |
* Returns unsigned POs over x days old | |
* | |
* ORDDAT (Order date) <= 'xxx' | |
* APPFLG (Signed) < 3 (No/Partly) | |
* CLEFLG (Closed) <> 2 (No) | |
* FLGSIG (Signature) = 3 (To be signed) | |
* | |
*/ | |
---------------------------------------- | |
SELECT | |
a.POHNUM_0, a.POHFCY_0, a.ZCCE4_0, ZITMREF_0, FORMAT(a.ORDDAT_0, 'dd/MM/yyyy') AS ORDER_DATE, FORMAT(a.CREDAT_0, 'dd/MM/yyyy') AS CREATED_DATE, a.BPSNUM_0, b.BPSNAM_0, | |
a.TOTORD_0, a.CUR_0, a.BUY_0, d.NOMUSR_0, c.DEST_0, FORMAT(c.DATENV_0, 'dd/MM/yyyy') AS EVENT_DATE, c.DELEGUE_0, c.FLGSIG_0, c.EMAIL_0 | |
FROM | |
PORDER a | |
JOIN | |
BPSUPPLIER b | |
ON | |
a.BPSNUM_0 = b.BPSNUM_0 | |
JOIN | |
AWRKHISSUI c | |
ON | |
a.POHNUM_0 = c.CLEDEC_0 | |
JOIN | |
AUTILIS d | |
ON | |
a.BUY_0 = d.USR_0 | |
WHERE | |
( a.APPFLG_0 < 3 AND a.CLEFLG_0 <> 2) | |
AND | |
c.FLGSIG_0 = 3 | |
AND | |
a.CREDAT_0 <= '2019-10-11' | |
ORDER BY | |
a.ORDDAT_0, a.POHNUM_0 ASC, c.DEST_0 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment