Skip to Content

ORIN AND ORDR

Hi

I have to create two queries

1. I need to display credit memo detail with SO Number

2. I need to display Return detail with SO Number.

I used below query for Credit memo and SO Number.

SELECT distinct t12.docnum, t1.docnum, t3.docnum, t5.docnum, t7.docnum, t12.numatcard, T12.CardCode [BP Code], T11.ItemCode, T11.Dscription, T11.LineTotal, t1.docnum, T1.DocDate [SO Date], T12.Comments, T12.U_ReturnReason FROM RDR1 T0 INNER JOIN ORDR T1 ON T0.DocEntry = T1.DocEntry left outer join DLN1 T2 on T2.BaseEntry = T0.DocEntry and T2.BaseLine = T0.Linenum left outer join ODLN T3 on T2.DocEntry = T3.DocEntry left Outer join INV1 T4 on T4.BaseEntry = T3.DocEntry and T4.BaseLine = T2.Linenum and T4.BaseType = 15 OR (T4.Basetype=17 and T4.BaseEntry=T0.DocEntry and T4.BaseLine=T0.LineNum) LEFT outer join RDN1 T11 on T11.BaseEntry = T2.DocEntry and T11.BaseLine = T2.LineNum LEFT outer join ORDN T12 on T11.DocEntry = T12.DocEntry left outer join OINV T5 on T5.DocEntry = T4.DocEntry left Outer join RIN1 T6 on T6.BaseEntry = T5.DocEntry and T6.BaseLine = T4.Linenum left outer join ORIN T7 on T6.DocEntry = T7.DocEntry Where T7.DocDate between '01/01/2019' and '12/21/2019' ---between [%0] and [%1] and

It displays correct info of Invoice, Delivery, so number but it displays wrong Credit memo. Can you guide me on relation of tables for Credit memo

Thanks

Naman

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Nov 08, 2019 at 04:47 AM

    Try this query

    SELECT T1."DocEntry" AS "Link",
    CASE
    WHEN T1."DocStatus" = 'C' THEN 'Close'
    ELSE 'Open'
    END AS "SO Status",
    T1."CardName" AS "Customer Name",
    T1."DocNum" AS "SO No.",
    T1."DocDate" AS "SO Date",
    t8."InvntryUom" as " Inv UOM",
    t0."InvQty" AS "SO Qty",
    T3."DocNum" AS "Delivery No",
    T3."DocDate" AS "Delivery Date",
    T5."DocNum" AS "Invoice No",
    T5."DocDate" AS "Invoice Date",
    T15."DocNum" AS "AR Credit No",
    T15."DocDate" AS "AR Credit Date",
    T0."ItemCode" AS "Product Code",
    T0."Dscription" AS "Product Name",
    t4."unitMsr" as "Sale UOM",
    T4."Quantity" as "No of Pack",
    T4."NumPerMsr" as "Items Unit",
    t4."InvQty" as "Delivered Qty(Nos)",
    T0."OpenQty" as "SO Open Qty"
    FROM RDR1 T0
    INNER JOIN ORDR T1 ON T0."DocEntry" = T1."DocEntry"
    LEFT OUTER JOIN DLN1 T2 ON T2."BaseEntry" = T0."DocEntry" AND T2."BaseLine" = T0."LineNum"
    LEFT OUTER JOIN ODLN T3 ON T2."DocEntry" = T3."DocEntry"
    LEFT OUTER JOIN INV1 T4 ON T4."BaseEntry" = T3."DocEntry" AND T4."BaseLine" = T2."LineNum" AND T4."BaseType" = '15'
    LEFT OUTER JOIN OINV T5 ON T5."DocEntry" = T4."DocEntry"
    LEFT OUTER JOIN RIN1 T14 ON T14."BaseEntry" = T4."DocEntry" AND T14."BaseLine" = T4."LineNum" AND T14."BaseType" = '13'
    LEFT OUTER JOIN ORIN T15 ON T15."DocEntry" = T14."DocEntry"
    LEFT OUTER JOIN OITM T8 ON T0."ItemCode" = T8."ItemCode"
    LEFT OUTER JOIN OITB T18 ON T8."ItmsGrpCod" = T18."ItmsGrpCod"
    WHERE T1."DocDate" >='[%0]'
    and T1."DocDate" <='[%1]'
    and t18."ItmsGrpNam" ='[%2]'
    order by T1."DocNum" ,T1."DocDate"

    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.