来自InventSum的MSDAX 2012 Onhand计算& InventTrans表

时间:2016-08-23 11:24:53

标签: axapta dynamics-ax-2012 dynamics-ax-2012-r2 dynamics-ax-2012-r3

我使用下面的查询来计算InventTrans表中的上手数量,但这个数量与InventSum表的AvailPhysical和/或PhysicalInvent不匹配。我也尝试过与其他数量相匹配但是手头不匹配。请指导我在这里缺少什么

SELECT T1.ITEMID AS ITEMID
            ,T1.QTY
            ,T1.INVENTDIMID AS INVENTDIMID
            ,DATEDIFF(dd, T3.TRANSDATE, getdate()) AS Age
            ,t19.price as RetailPrice
            ,t1.CurrencyCode AS CurrencyKey
            ,T1.DATAAREAID AS DATAAREAID
            ,T1.PARTITION AS PARTITION
        FROM INVENTTRANS T1
        LEFT JOIN INVENTTRANSORIGIN T2 ON (
                T1.INVENTTRANSORIGIN = T2.RECID
                AND (T1.DATAAREAID = T2.DATAAREAID)
                AND (T1.PARTITION = T2.PARTITION)
                )
        INNER JOIN INVENTTRANSPOSTING T3 ON (
                (
                    (
                        (
                            T1.VOUCHERPHYSICAL = T3.VOUCHER
                            AND (T1.DATAAREAID = T3.DATAAREAID)
                            AND (T1.PARTITION = T3.PARTITION)
                            )
                        )
                    AND (
                        T1.DATEPHYSICAL = T3.TRANSDATE
                        AND (T1.DATAAREAID = T3.DATAAREAID)
                        AND (T1.PARTITION = T3.PARTITION)
                        )
                    )
                AND (
                    T1.INVENTTRANSORIGIN = T3.INVENTTRANSORIGIN
                    AND (T2.DATAAREAID = T3.DATAAREAID)
                    AND (T2.PARTITION = T3.PARTITION)
                    )
                ) and t3.INVENTTRANSPOSTINGTYPE in (0)
        LEFT JOIN INVENTDIM t4 ON (
                t4.inventdimid = t1.inventdimid
                AND t4.PARTITION = t1.PARTITION
                AND t4.dataareaid = t1.dataareaid
                )

                LEFT OUTER JOIN INVENTTABLEMODULE T19 ON T19.ItemID = T1.ItemID AND T19.DataAreaID = T1.DataAreaID and T19.Partition = T1.Partition AND T19.MODULETYPE=0
                LEFT OUTER JOIN INVENTTABLE T20 ON T1.ITEMID = T20.ITEMID AND T1.DATAAREAID = T20.DATAAREAID 
                where T20.ITEMTYPE <> 2

非常感谢任何帮助。

0 个答案:

没有答案