QUERY DE AUDITORIA DE STOCK DE INVENTARIO POR ARTÍCULOS A UNA FECHA DETERMINADA Y ALMACÉN ESPECIFICO.
SELECT T2.[ItemCode], T2.[ItemName], T1.[WhsCode], T1.WhsName,
ISNULL((SELECT (SUM(Y.InQty)-SUM(Y.OutQty))
FROM OINM Y
WHERE Y.ItemCode = T2.ItemCode AND Y.Warehouse = T1.WhsCode AND Y.DocDate<='2020-01-01'),0) 'Stock',
ISNULL((SELECT (SUM(Y.TransValue))
FROM OINM Y
WHERE Y.ItemCode = T2.ItemCode AND Y.Warehouse = T1.WhsCode AND Y.DocDate <='2020-01-01'),0)'Costo Total',
T3.ItmsGrpNam,T2.LastPurPrc as 'UltimoPrecioCompra',T0.AvgPrice as 'PrecioPromedio'
FROM OITM T2
INNER JOIN OITW T0 ON T0.ItemCode=T2.ItemCode
INNER JOIN OWHS T1 ON T1.WhsCode=T0.WhsCode
INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
WHERE (SELECT (SUM(Y.InQty)-SUM(Y.OutQty)) FROM OINM Y
WHERE Y.ItemCode = T2.ItemCode AND Y.Warehouse = T1.WhsCode AND Y.DocDate<='2020-01-01' ) != '0' AND T0.[WhsCode]='AGDL'
ORDER BY T2.[ItemCode], T1.[WhsCode]
Referencia: https://answers.sap.com/
QUERY AUDITORIA DE STOCK PARA SAPB1
Full Stack Web Developer && SDK SAPB1 Developer.
Melómano, Gamer (Xbox), Comprador compulsivo de Amazon y Posiblemente con TDAH.