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 will update the Accrued Purchases distribution on history receipts from Posting Account Master (SY01100) table. I think this script was created as a client created a new accrual account for purchase orders to split the value out of manual accruals and needed the distributions updated so invoices would post to the new account for the existing receipts.
/*
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).
*/
UPDATE
['Purchasing Distribution Work']
SET
ACTINDX = ['Posting Account Master'].ACTINDX
FROM
POP30390 AS ['Purchasing Distribution Work'] --Purchasing Distribution History (POP30390)
INNER JOIN
POP30300 AS ['Purchasing Receipt History'] --Purchasing Receipt History (POP30300)
ON
['Purchasing Receipt History'].POPRCTNM = ['Purchasing Distribution Work'].POPRCTNM
INNER JOIN
SY01100 AS ['Posting Account Master'] --Posting Account Master (SY01100)
ON
['Posting Account Master'].SERIES = 4
AND
['Posting Account Master'].PTGACDSC = 'Accrued Purchases'
WHERE
['Purchasing Receipt History'].POPTYPE = 1
AND
['Purchasing Distribution Work'].DISTTYPE = 9