跳至主要內容

库存收货报表

五六零网校大约 1 分钟

代码示例

SELECT T0.[JrnlMemo] AS 收货类型, T0.[DocNum], T0.[DocDate], T1.[ItemCode], T1.[Dscription]
	, T2.[FrgnName], T1.[UseBaseUn], T1.[Quantity], T1.[Price], T1.[LineTotal]
	, TS.[BatchNum] AS 批次号, TS.[Quantity] AS 批次数量, TS.[BinCode] AS 库位号, TS.[Quantity] AS 库位转入数量, T2.[OnHand]
	, T5.[AvgPrice]
FROM OIGN T0
	INNER JOIN IGN1 T1 ON T0.[DocEntry] = T1.[DocEntry]
	INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode]
	INNER JOIN OITB T3 ON T2.[ItmsGrpCod] = T3.[ItmsGrpCod]
	INNER JOIN OSLP T4 ON T0.[SlpCode] = T4.[SlpCode]
	INNER JOIN OITW T5
	ON T5.itemcode = t2.itemcode
		AND t5.whscode = t1.whscode
	LEFT JOIN (
		SELECT T2.[BinCode], T1.[Quantity], T1.[SnBMDAbs], T4.[BatchNum], T0.[LocCode]
			, T0.[DocEntry], T0.[ItemCode], T0.[TransType]
		FROM OILM T0
			INNER JOIN OBTL T1 ON T0.[MessageID] = T1.[MessageID]
			INNER JOIN OBIN T2 ON T1.[BinAbs] = T2.[AbsEntry]
			INNER JOIN OBTN T3 ON T3.ABSENTRY = T1.[SnBMDAbs]
			INNER JOIN IBT1 T4
			ON T4.[BatchNum] = T3.[DistNumber]
				AND T4.itemcode = t0.itemcode
				AND T4.[WhsCode] = T0.[LocCode]
				AND T4.[BaseEntry] = T0.[DocEntry]
	) TS
	ON Ts.[DocEntry] = t0.docentry
		AND Ts.[ItemCode] = t1.itemcode
		AND Ts.[LocCode] = t1.whscode
		AND TS.[TransType] = t0.objtype

WHERE
----物料编码 大于等于 A    AND  物料编码小于等于 B
 (T1.[ItemCode] >= '[%0]' or '[%0]'='') AND ( T1.[ItemCode] <= '[%1]' or '[%1]'='') 
----物料名称
AND ( T2.[FrgnName]>= '[%2]' or '[%2]'='') AND ( T2.[FrgnName]<= '[%3]' or '[%3]'='') 
----单据日期
AND  ( T0.[taxDate] >= '[%4]' or '[%4]'='')  AND  ( T0.[taxDate]<= '[%5]' or '[%5]'='')  
----单据状态
AND   ( T0.[DocStatus] = '[%6]' or '[%6]'='') 
----物料组
AND (T3.[ItmsGrpNam]  >= '[%7]' or '[%7]'='') AND (T3.[ItmsGrpNam]  <= '[%8]' or '[%8]'='') 
----单据编号
AND (T0.[DOCNUM]  >=[%17] or [%17]='')  AND (T0.[DOCNUM]  <=[%18] or [%18]='')
AND T1.[BaseType]='-1'
ORDER BY T0.[DocNum] DESC