I have been working on this for awhile and have been unable to get a solution that appears to have correct data. Essentially, I am trying to create a report that can tell me how much stock I had on hand on any given day in the past. I have tried writing a SQL query using the IV30300 table but if I add the inventory numbers together from eternity past, grouped by month, or if I take current stock levels and subtract the inventory change info in that table, I quickly end up with having too little stock. Below is a copy of the SQL query that I wrote to calculate historical inventory adds, unsuccessfully (the one that added from the past data and groups by month).
select month(docdate) as TransMonth, year(docdate) as TransYear, a.itemnmbr, trxloctn, max(uscatvls_1) as mfr,sum(trxqty * unitcost) + isnull((select sum(trxqty * unitcost) from iv30300 where itemnmbr = a.itemnmbr and trxloctn = a.trxloctn and docdate < cast((cast(month(a.docdate) as varchar(4)) + '/1/' + cast(year(a.docdate) as varchar(4))) as datetime)), 0)from iv30300 a inner join iv00101 b on a.itemnmbr = b.itemnmbrwhere a.unitcost > 0group by month(docdate), year(docdate), a.itemnmbr, trxloctn
Any help is appreciated!
*This post is locked for comments
I have the same question (0)