CREATE VIEW XXX_INVTRANSFER_DRAFT_LINESBIN
AS
SELECT DRF1.DocEntry, DRF1.ItemCode, DRF1.LineNum
, fromBin.BinCode as FromBin, fromBinLine.Quantity as FromQuantity, toBin.BinCode as ToBin, toBinLine.Quantity as ToQuantity FROM ODRF, DRF1
LEFT OUTER JOIN DRF19 fromBinLine ON (fromBinLine.ObjType = 67 AND fromBinLine.DocEntry = DRF1.DocEntry AND fromBinLine.LineNum = DRF1.LineNum AND fromBinLine.BinActTyp = 2)
LEFT OUTER JOIN DRF19 toBinLine ON (toBinLine.ObjType = 67 AND toBinLine.DocEntry = DRF1.DocEntry AND toBinLine.LineNum = DRF1.LineNum AND toBinLine.BinActTyp = 1)
LEFT OUTER JOIN OBIN fromBin ON (fromBin.AbsEntry = fromBinLine.BinAbs)
LEFT OUTER JOIN OBIN toBin ON (toBin.AbsEntry = toBinLine.BinAbs)
WHERE 
ODRF.ObjType = 67 AND DRF1.ObjType = 67 AND toBinLine.ObjType = 67
AND ODRF.DocEntry = DRF1.DocEntry 
