Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Re: Need to consider an additional query scenario related to purchasing!

$
0
0

Hi David,

 

Try:

 

SELECT

    Case WHEN T0.ItemCode in (SELECT ItemCode FROM IPF1) THEN 'Oversea' ELSE 'Domestic' END AS 'Type'

    ,T5.DocNum AS 'Purchase Order #'

--    , T5.DocDate AS 'PO Date'

    , T3.DocNum AS 'Goods Receipt PO #'

    --, T1.DocNum AS 'A/P Invoice #'

    , T3.DocDate AS 'GRPO Date'

    , DATEDIFF(DD, T5.DocDate, T3.DocDate) AS 'Lead Time'

    , T2.Quantity

    , T0.Currency AS 'Currency'

    , T0.Price AS 'Buy Price'

    , 'N/A' AS 'Ex.Rate'

    , 'N/A' AS 'Landed Cost'

    , 'N/A' AS 'Import %'

    , 'N/A' AS 'Duty Rate'

    , ISNULL(T4.U_INE_FreightType, '') AS 'Freight Type'

    , ISNULL(T4.U_A1WMS_Comments, '') AS 'Warehouse Comments'

    , T5.CardCode

    , T5.CardName

 

    FROM PCH1 T0

    INNER JOIN OPCH T1 ON T1.DocEntry = T0.DocEntry

    INNER JOIN PDN1 T2 ON T2.DocEntry = T0.BaseEntry AND T2.ItemCode = T0.itemCode

    INNER JOIN OPDN T3 ON T3.DocEntry = T2.DocEntry

    INNER JOIN POR1 T4 ON T4.DocEntry = T2.BaseEntry AND T4.LineNum = T2.BaseLine

    INNER JOIN OPOR T5 ON T5.DocEntry = T4.DocEntry

 

    WHERE T0.ItemCode = '[%0]'

        AND T5.Canceled = 'N'

 

    ORDER BY T3.DocDate DESC

 

Thanks,

Gordon


Viewing all articles
Browse latest Browse all 9159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>