This is a script I’ve had a few months now and, like the one I posted yesterday, thought it might be useful to others.
This script was created for a client who changed some of their account codes on some Item Classes and had rolled them down to the Items themselves but there were many Sales Transactions already on the system which had the old code on and needed to be updated to the new one.
A relatively simple SQL script later and I had a method which would update all Quotes and Orders at a status of Work in Sales Order Processing with the new codes from the Item where the Item Class was within a required range;
UPDATE
['Sales Transactions Amounts Work']
SET
INVINDX = ['Item Master'].IVIVINDX -- Inventory
,CSLSINDX = ['Item Master'].IVCOGSIX -- Cost of Goods Sold
,SLSINDX = ['Item Master'].IVSLSIDX -- Sales
FROM
SOP10200 AS ['Sales Transactions Amounts Work']
INNER JOIN
IV00101 AS ['Item Master']
ON ['Item Master'].ITEMNMBR = ['Sales Transactions Amounts Work'].ITEMNMBR
WHERE
['Sales Transactions Amounts Work'].SOPTYPE IN (1, 2)
AND
['Item Master'].ITMCLSCD IN ('MASONRY', 'ROOFING', 'WINDOWS')
If Invoices, Returns or Fulfillment Orders also need to be updated then another script which updates Sales Transaction Distributions Work (SOP10102) would be needed in addition to the above.
If you use this script then, as always when running a script, please make sure you have a good backup of your company database (I define a good backup as one you have restored to ensure it backed up correctly) and know what you are doing in Management Studio with SQL Statements.
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.
2 thoughts on “Update Sales Transactions Distributions From Item”