Skip to content

Instantly share code, notes, and snippets.

@nickdavies791
Created October 25, 2019 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickdavies791/67ba9bc99d26ae3bb5c8b1fec3e967d3 to your computer and use it in GitHub Desktop.
Save nickdavies791/67ba9bc99d26ae3bb5c8b1fec3e967d3 to your computer and use it in GitHub Desktop.
Returns unsigned purchase orders over given date
----------------------------------------
/**
*
* 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