HI,
I would like to get the cost of items issued for production with the batch information. Below is my query. If I use the same item more than one time from different batches (when I issue to production) this query is returning duplicate results. Can anyone help on what went wrong here?
SELECT T0.DocNum as [Prod Num],
T1.[ItemCode] as [Item No.],
T1.PlannedQty as [Planned QTY],
T3.Quantity as [Qty Issued], T3.LineTotal as [Total Cost], T3.LineTotal / T3.Quantity as [Cost / KG],
T6.[DistNumber] as [RM Batch]
FROM OWOR T0
Inner join WOR1 T1 on T0.DocEntry=T1.DocEntry
/* Raw Material Information */
INNER JOIN IGE1 T3 ON T0.DocEntry = T3.BaseEntry and T3.BaseType=202 and T3.BaseLine=T1.LineNum
INNER JOIN OITL T4 ON T3.DocEntry = T4.DocEntry
INNER JOIN ITL1 T5 On T4.LogEntry = T5.LogEntry AND T3.ItemCode = T5.ItemCode
INNER JOIN OBTN T6 ON T5.MdAbsEntry = T6.AbsEntry AND T4.DocType = 60
where T0.docnum = '200295'