Skip to Content

Production Usage Report

Hello All

I need a query that will display the total purchased quantity purchased & total issued in a production order

I have written the below, but I don't get any results

Can someone please help me figure out where I am going wrong

SELECT

T2.[ItemCode],

T0.[ItemName],

T1.[InQty],

T3.[IssuedQty]

FROM OITM T0 INNER JOIN OINM T1 ON T0.ItemCode = T1.ItemCode, OWOR T2 INNER JOIN WOR1 T3 ON T2.DocEntry = T3.DocEntry

WHERE

T2.[ItemCode] =[%0] AND

T2.[ItemCode] =[%1] AND

T1.[DocDate] >=[%2] AND

T1.[DocDate] <=[%3]

GROUP BY T2.[ItemCode], T0.[ItemName], T1.[InQty], T3.[IssuedQty]

Thanks and Regards

Rahul

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 16, 2015 at 05:01 AM

    Hi Rahul,

    Try this

    Declare @FromDate Date

    Declare @ToDate Date

    Set @FromDate =/* SELECT Max(T0.DocDate) FROM OINM T0 WHERE T0.DocDate > */ '[%0]'

    Set @ToDate = /* SELECT Max(T0.DocDate) FROM OINM T0 WHERE T0.DocDate > */ '[%1]'

    SELECT T0.ItemCode as 'Item Code', t2.Itemname as 'Item Name',t3.itmsgrpnam as 'Item

    Group',(Select

    SUM(T110.InQty) FROM OINM T110 where T110.itemcode = t0.itemcode and

    T110.DocDate>=@FromDate and T110.DocDate<=@ToDate and

    T110.TransType in (20,18)) as 'Purchase Quantity'

    ,(Select SUM(T110.OutQty) FROM OINM T110 where T110.itemcode = t0.itemcode and

    T110.DocDate between @FromDate and @ToDate and

    T110.TransType=60) as 'Issued Quantity'

    FROM OINM T0 inner join oitm t2 on t2.itemcode = t0.itemcode

    left outer JOIN OITB T3 ON t3.ItmsGrpCod = T2.ItmsGrpCod

    GROUP BY

    T0.ItemCode,t3.itmsgrpnam,t2.Itemname

    for browse

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.