I want to exclude all cancelled good receipt P.O and incorporate in this below query. The InQTY is showing all the cancelled GRPO as well.
/*select T0."DocDate" from OINM T0 where T0."DocDate">=[%0] and T0."DocDate"<=[%1] */
select DISTINCT T1."ItemCode" ,T1."ItemName",T2."WhsCode",
(Select IFNULL((Sum("InQty"-"OutQty")),0) from OINM where "DocDate" < [%0] and "ItemCode"=T0."ItemCode" and "Warehouse" = T2."WhsCode") as "Opening Qty",
(select IFNULL ((Sum("InQty")),0) From OINM where "DocDate">=[%0] and "DocDate"<=[%1] and "ItemCode"=T0."ItemCode" and "Warehouse" = T2."WhsCode" ) as "Receipt Qty",
((select IFNULL((Sum("OutQty")),0) From OINM where "DocDate">=[%0] and "DocDate"<=[%1] and "ItemCode"=T0."ItemCode" and "Warehouse" = T2."WhsCode" and "TransType"='67'))as "Issue Qty",
(Select IFNULL((Sum("InQty"-"OutQty")),0) from OINM where "DocDate" <=[%1] and "ItemCode"=T0."ItemCode" and "Warehouse" = T2."WhsCode" ) as "Closing Qty"
FROM OINM T0 INNER JOIN OITM T1 ON T0."ItemCode" = T1."ItemCode"LEFT JOIN OWHS T2 ON T0."Warehouse" = T2."WhsCode" WHERE T2."WhsCode" = '[%2]'Group by T1."ItemCode" ,T1."ItemName",T2."WhsCode",T0."ItemCode"ORDER BY T1."ItemCode"
The Goods Receipt P.O Table has a field CANCELED which will either be a 'Y' or and 'N'