This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script returns a list of open purchase orders.
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
SELECT
PONUMBER AS 'PO Number'
,CASE WHEN POSTATUS = 1 THEN
'New'
WHEN POSTATUS = 2 THEN
'Released'
WHEN POSTATUS = 3 THEN
'Change Order'
WHEN POSTATUS = 4 THEN
'Received'
WHEN POSTATUS = 5 THEN
'Closed'
ELSE
'Cancelled'
END AS 'PO Status'
,CASE WHEN STATGRP = 0 THEN
'Voided'
WHEN STATGRP = 1 THEN
'Active' -- Includes New, Open & Modified
ELSE
'Closed' -- Includes Cancelled & Closed
END AS 'Status Group'
,CASE WHEN POTYPE = 1 THEN
'Standard'
WHEN POTYPE = 2 THEN
'Drop Ship'
WHEN POTYPE = 3 THEN
'Blanket'
ELSE
'Blanket Drop Ship'
END AS 'PO Type'
,DOCDATE AS 'Document Date'
,REMSUBTO AS 'Remaining Subtotal'
,SUBTOTAL AS 'Subtotal'
,TRDISAMT AS 'Trade Discount Amnt'
,FRTAMNT AS 'Freight Amnt'
,MSCCHAMT AS 'Misc Charge Smnt'
,TAXAMNT AS 'Tax Amnt'
,VENDORID AS 'Vendor ID'
,VENDNAME AS 'Vendor Name'
,PYMTRMID AS 'Payment Terms ID'
,DUEDATE AS 'Due Date'
,CREATDDT AS 'Created Date'
,MODIFDT AS 'Modified Date'
,BUYERID AS 'Buyer ID'
,CASE WHEN HOLD = 1 THEN
'On Hold'
ELSE
'Open'
END AS 'Hold Status'
,ONHOLDDATE AS 'Hold Date'
,Revision_Number AS 'Revision Number'
,TAXSCHID AS 'Tax Schedule ID'
FROM
POP10100 --Purchase Order Work (POP10100)
WHERE
STATGRP = 1
AND
POSTATUS IN (1,2,3)
AND
REMSUBTO <> 0