This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script returns payables transactions at a status of open or history after a specified date.
/*
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
PMOPEN.VCHRNMBR AS [Voucher Number],
PMOPEN.DOCNUMBR AS [Document Number],
CASE
WHEN PMOPEN.DOCTYPE = 1 THEN 'Invoice'
WHEN PMOPEN.DOCTYPE = 2 THEN 'Invoice'
WHEN PMOPEN.DOCTYPE = 3 THEN 'Invoice'
WHEN PMOPEN.DOCTYPE = 4 THEN 'Credit'
WHEN PMOPEN.DOCTYPE = 5 THEN 'Credit'
ELSE ''
END 'Document Type',
PMOPEN.DOCDATE AS [Document Date],
PMOPEN.POSTEDDT AS [Posted Date],
PMOPEN.VENDORID,
VM.VENDNAME AS [Vendor Name],
PMOPEN.PRCHAMNT AS [Net Amount],
PMOPEN.TAXAMNT AS [Tax Amount],
PMOPEN.DOCAMNT AS [Gross Amount],
PMOPEN.CURTRXAM AS [Outstanding Amount]
FROM PM20000 PMOPEN --PM Transaction OPEN File (PM20000)
INNER JOIN PM00200 VM --PM Vendor Master File (PM00200)
ON PMOPEN.VENDORID = VM.VENDORID
WHERE DOCTYPE IN (1, 2, 3, 4, 5)
AND DOCDATE > '2016-04-30 00:00:00.000'
AND VOIDED = 0
AND CURTRXAM > 0
AND CURTRXAM = 0
UNION ALL
SELECT
PMHIST.VCHRNMBR AS [Voucher Number],
PMHIST.DOCNUMBR AS [Document Number],
CASE
WHEN PMHIST.DOCTYPE = 1 THEN 'Invoice'
WHEN PMHIST.DOCTYPE = 2 THEN 'Invoice'
WHEN PMHIST.DOCTYPE = 3 THEN 'Invoice'
WHEN PMHIST.DOCTYPE = 4 THEN 'Credit'
WHEN PMHIST.DOCTYPE = 5 THEN 'Credit'
ELSE ''
END 'Document Type',
PMHIST.DOCDATE AS [Document Date],
PMHIST.POSTEDDT AS [Posted Date],
PMHIST.VENDORID,
VM.VENDNAME AS [Vendor Name],
PMHIST.PRCHAMNT AS [Net Amount],
PMHIST.TAXAMNT AS [Tax Amount],
PMHIST.DOCAMNT AS [Gross Amount],
PMHIST.CURTRXAM AS [Outstanding Amount]
FROM PM30200 PMHIST --PM Paid Transaction History File (PM30200)
INNER JOIN PM00200 VM --PM Vendor Master File (PM00200)
ON PMHIST.VENDORID = VM.VENDORID
WHERE DOCTYPE IN (1, 2, 3, 4, 5)
AND DOCDATE > '2016-04-30 00:00:00.000'
AND VOIDED = 0
ORDER BY DOCDATE
Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index
What should we write about next?
If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.
Looking for support or consultancy with Microsoft Dynamics GP?
I no longer work with Microsoft Dynamics GP, but the last company I worked for was ISC Software in the UK; if you’re looking for support or consultancy services with Microsoft Dynamics GP you can contact them here.