Sales Order Query problem

Hi All,
This is Sales order with return, delivery, AR invoice query.....Query is working but it shows repetative records..pls check the query below......and just copy and paste it and give AR Invoice document no ...plz check query for minimum two item Nos...then you will understand it shows 8 records instead of 2 records(line items)........pls tell me what to do to show only 2 line items........
And one more doubt..if AR invoice does not have sales order or return or delivery then also it should show AR invoice details or other respective details........query is below
SELECT b.Doc_Num1 as 'SO. No.',
b.DocDate1   as      'SO. Date',
b.Doc_Num2   AS      'Del.Doc.No.',
b.DocDate2    AS      'Delivery Date',
b.Doc_Num3   as      'A/R Invoice No.',
b.DocDate3    as      'Inv. Date',
b.Doc_Num4   AS      'RETURN Doc.No.',
b.DocDate4    as      'Ret.Date',
b.CardName   as      'Vendor Name',
b.NumAtCard  as      'Bill No. & Date',
b.ItemCode   as      'Item Code',
b.Dscription as      'Dscription',
b.Quantity1  as      'AR Invoice Quantity',
b.Quantity2  as      'Sales Order Quantity',
b.Quantity3  as      'Delivery Quantity',
b.Quantity4  as      'Return Quantity',
b.LineTotal  as      'Base Amt.(Rs.)',
b.WTSum           AS      'TDS (Rs.)',
b.DocTotal    as     'Total (Rs.)',
sum(b.BED)    as           'Bed Value',
sum(b.EDCS)   as          'EDCS Value',
sum(b.HECS)   as          'HECS Value',
sum(b.VAT)        as           'VAT Value',
sum(b.CST)        as           'CST Value',
sum(b.CVD)        as           'CVD Value',
sum(b.SerTax)  as           'SERTAX Value',
sum(b.CSonSerTax) as      'CS Value',
sum(b.HECS_ST)      as      'HESC Value'

Hi Sonal,
Try this,
SELECT b.Doc_Num1 as 'SO. No.',
b.DocDate1   as      'SO. Date',
b.Doc_Num2   AS      'Del.Doc.No.',
b.DocDate2    AS      'Delivery Date',
b.Doc_Num3   as      'A/R Invoice No.',
b.DocDate3    as      'Inv. Date',
b.Doc_Num4   AS      'RETURN Doc.No.',
b.DocDate4    as      'Ret.Date',
b.CardName   as      'Vendor Name',
b.NumAtCard  as      'Bill No. & Date',
b.ItemCode   as      'Item Code',
b.Dscription as      'Dscription',
b.Quantity1  as      'SO_Qty',
b.Quantity2  as      'DLN_Qty',
b.Quantity3  as      'A/R Inv_Qty',
b.Quantity4  as      'Return_Qty',
b.LineTotal  as      'Base Amt.(Rs.)',
b.WTSum           AS      'TDS (Rs.)',
b.DocTotal    as     'Total (Rs.)',
sum(b.BED)    as           'Bed Value',
sum(b.EDCS)   as          'EDCS Value',
sum(b.HECS)   as          'HECS Value',
sum(b.VAT)        as           'VAT Value',
sum(b.CST)        as           'CST Value',
sum(b.CVD)        as           'CVD Value',
sum(b.SerTax)  as           'SERTAX Value',
sum(b.CSonSerTax) as      'CS Value',
sum(b.HECS_ST)      as      'HESC Value' 
from (
select *,( a.Bed + a.EDCS + a.HECS + a.VAT + a.CST +a.CVD + a.SerTax + a.CSonSerTax  + a.HECS_ST ) as Filter from (SELECT distinct
T0.DocNum as 'Doc_Num1',
T0.DocDate as 'DocDate1',
T2.DocNum as 'Doc_Num2',
T2.DocDate as 'DocDate2',
M.DocNum as 'Doc_Num3',
M.DocDate as 'DocDate3',
M.CardName,
M.NumAtCard,
L.ItemCode,
L.Dscription,
T1.Quantity as  'Quantity1',
T3.Quantity as  'Quantity2',
L.Quantity as  'Quantity3',
X.Quantity as  'Quantity4',
S.DocNum 'Doc_Num4',
S.DocDate as 'DocDate4',
L.LineTotal ,
M.DocEntry,
M.[DiscSum],
M.WTSum,
M.DocTotal,
Regards,
Madhan.
Edited by: Madhan Babu C on Aug 28, 2009 2:12 PM

Similar Messages

  • Monthly Sales Order query Doc Status problem

    Hi Experts,
    I am having an problem while making a total monthly sales order query in which I am not getting the document status which are Open - Printed. Also note that these document which are open printed are not having any target document.
    SELECT T0.[DocStatus],T1.[TargetType],T0.[CANCELED],T0.[CardCode], T0.[CardName], T0.[NumAtCard], T5.[SeriesName], T0.[DocNum], T0.[DocDate], T0.[DocDueDate], T0.[DocTotal],T0.[Max1099]'Total Before Discount',T0.[TotalExpns],T4.[descript]'Territory',T2.[SlpName]'Employee Name'
    ,T0.[discsum]  FROM ORDR T0  ,RDR1 T1,OSLP T2,OCRD T3,OTER T4,NNM1 T5  where  T0.DocEntry = T1.DocEntry AND T0.SlpCode = T2.SlpCode AND T0.CardCode = T3.CardCode
    AND T3.Territory = T4.territryID AND T0.Series = T5.Series and T0.[CANCELED]='N' and T1.[TargetType] is not null
    My mission for the above query is to have Total Monthly Sales Orders with value exluding the cancelled and closed sales sales ( close here means - which are manually done by right click on sales order screen and selecting Close )
    Please guied how to solve this issue because in the back end for Sales Order which have turned to deleivery are showing doc status as closed and the sales order which are manually closed are also showing doc status as closed. How to diffrentiate between them.
    Waiting for a positve feedback.
    Regards,
    Rahul

    Try this one:
    SELECT DISTINCT T0.[DocStatus],T0.[CardCode], T0.[CardName], T0.[NumAtCard], T5.[SeriesName],
    T0.[DocNum], T0.[DocDate], T0.[DocDueDate], T0.[DocTotal],T0.[Max1099]'Total Before Discount',
    T0.[TotalExpns],T4.[descript]'Territory',T2.[SlpName]'Employee Name',T0.[discsum]
    FROM DBO.ORDR T0
    INNER JOIN DBO.RDR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN DBO.OSLP T2 ON T0.SlpCode = T2.SlpCode
    INNER JOIN DBO.OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN DBO.OTER T4 ON T3.Territory = T4.territryID
    INNER JOIN DBO.NNM1 T5 ON T0.Series = T5.Series
    where  T0.[CANCELED]='N' and T1.[TargetType] != -1
    Thanks,
    Gordon

  • Combined Purchase Order and Sales Order Query. (Including Stand Alone Docs)

    Hi,
    I need some help please!
    I am looking for a query that will show all the Purchase Orders with all their base document Sales Orders. However I also need to show those stand alone Purchase orders and Sales Orders.
    What I have is two queries, one for the PO fields en one for The SO fields. I would like a way to combine these two so I have one query with the relevant PO and SO info next to each other.
    The final query will have a top heading structure like this:
    Status,Purchase No.,Supplier No.,Supplier Name,Week,Month,Del Method,Country,Method,Rep.|Status,Rep.,Sales No.,Customer No.,Customer Name,Customer Order no.,Cust. Del date,Doc total,Del Method
    +(The first part is for the purchase order section, the second part starting at the second 'Status' is the sales order section)
    +Purchase Order Query:
    SELECT
      T0.DocStatus 'Status',
      T0.DocNum'Purchase Order No.',
      T0.CardCode 'Supplier No.',
      T0.CardName'Supplier Name',
      DATEPART(ww,T0.DocDuedate)'Week',
      DATEPART(mm,T0.DocDuedate) 'Month',
      T1.TrnspName 'Delivery Method',
      T2.Country 'Country',
      T0.JrnlMemo 'Method',
      T3.SlpName 'Rep.'
    FROM OPOR T0 
    INNER JOIN OSHP T1 ON T0.TrnspCode = T1.TrnspCode
    INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
    INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode
    Sales Order Query:
    SELECT
      T0.DocStatus 'Status',
      T2.SlpName 'Rep.',
      T0.DocNum 'Sales Order No.',
      T0.CardCode 'Customer No.',
      T0.CardName 'Customer Name',
      T0.NumAtCard 'Customer Order no.',
      T0.DocDueDate 'Cust. Delivery date',
      T0.DocTotal ' Doc total',
      T1.TrnspName ' Delivery Method'
    FROM ORDR T0 
    INNER JOIN OSHP T1 ON T0.TrnspCode = T1.TrnspCode
    INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    The problem I am having is that if I combine these queries it excludes all those records with blank/empty data fields.
    I do not mind having to go to crystal reports to get what I want.
    Any suggestions?
    Thanks!

    Hi thanks GordonDu,
    I have tried a union before, and yours works great. However my problem is to display the  PO en SO columns next to each other and not underneath each other.
    Something like this:
    Po No          Supplier          SO No           Customer
    1234           Sup 1             9876              Cust 1
    1235           Sup 2             no SO             Cust 2
    1236           Sup 3             9877              Cust 3
    1237           Sup 4             9878              Cust 4
    1238           Sup 5             no SO             Cust 4
    I have this query, but with this it drops all those Purchase Orders made Stand Alone and without a SO number.
    SELECT
      T2.DocNum AS 'Purchase Order No.',
      T0.DocNum AS 'Sales Order No.',
      T2.CardCode AS 'Supplier No.',
      T2.CardName AS 'Supplier Name'
    FROM ORDR T0 
       INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
       INNER JOIN OPOR T2 ON T2.DocEntry = T1.PoTrgEntry
    Though using your Union gives me all the information I want and the ability to expand on that, my problem is the "Display" part. I am sure I am doing something stupid somwhere 
    Edited by: Desmond Moll on Mar 7, 2012 8:03 AM

  • Problem in Sales Order Query

    Hi All,
    I have problem....This is query which ic combination of Sales Order, Return, Delivery and AR Invoice.....Please tell me why this query is not working ......I want Document No, Quantity, Doc Date from Sales Order, Return, Delivery and AR Invoice and Tax bifergation also.....I per my view this query there should not be any problem but it is not working...please tell me where I am wrong....Just copy and paste this query and check in ur system.......
    SELECT b.Doc_Num1 as 'SO. No.',
    b.DocDate    as      'SO. Date',
    b.Doc_Num2   AS      'Del.Doc.No.',
    b.DocDate    AS      'Delivery Date',
    b.Doc_Num3   as      'A/R Invoice No.',
    b.DocDate    as      'Inv. Date',
    b.Doc_Num4   AS      'RETURN Doc.No.',
    b.DocDate    as      'Ret.Date',
    b.CardName   as      'Vendor Name',
    b.NumAtCard  as      'Bill No. & Date',
    b.ItemCode   as      'Item Code',
    b.Dscription as      'Dscription',
    b.Quantity1  as      'AR Invoice Quantity',
    b.Quantity2  as      'Sales Order Quantity',
    b.Quantity3  as      'Delivery Quantity',
    b.Quantity4  as      'Return Quantity',
    b.LineTotal  as      'Base Amt.(Rs.)',
    b.WTSum           AS      'TDS (Rs.)',
    b.DocTotal    as     'Total (Rs.)',
    sum(b.BED)    as           'Bed Value',
    sum(b.EDCS)   as          'EDCS Value',
    sum(b.HECS)   as          'HECS Value',
    sum(b.VAT)        as           'VAT Value',
    sum(b.CST)        as           'CST Value',
    sum(b.CVD)        as           'CVD Value',
    sum(b.SerTax)  as           'SERTAX Value',
    sum(b.CSonSerTax) as      'CS Value',
    sum(b.HECS_ST)      as      'HESC Value' 
    from (
    select *,( a.Bed + a.EDCS + a.HECS + a.VAT + a.CST +a.CVD + a.SerTax + a.CSonSerTax  + a.HECS_ST ) as Filter from (SELECT distinct
    T0.DocNum,
    T0.DocDate,
    T2.DocNum,
    T2.DocDate,
    M.DocNum,
    M.DocDate,
    M.CardName,
    M.NumAtCard,
    L.ItemCode,
    L.Dscription,
    L.Quantity,
    T1.Quantity,
    T3.Quantity,
    S.DocNum,
    S.DocDate,
    X.Quantity,
    L.LineTotal,
    M.DocEntry,
    M.[DiscSum],
    M.WTSum,
    M.DocTotal,
    M.WTSum,
    M.DocTotal,

    Hi Sonal,
    Try this,
    SELECT  T0.DocNum as 'SO. No.',
    T0.DocDate as 'SO. Date',
    T2.DocNum AS 'Del.Doc.No.',
    T2.DocDate AS 'Delivery Date',
    M.DocNum as 'A/R Invoice No.',
    M.DocDate as 'Inv. Date',
    T4.DocNum AS 'Return No.',
    T4.DocDate AS 'Return Date',
    M.CardName as 'Vendor Name',
    M.NumAtCard as 'Bill No. & Date',
    ISNULL(L.ItemCode,'Service Item') as 'Item Code',
    L.Dscription,
    L.Quantity,
    (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From INV3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN ODLN T2 ON T2.DocEntry = T1.TrgetEntry
    INNER JOIN DLN1 T3 on T3.DocEntry = T2.Docentry
    INNER JOIN OINV M ON M.DocEntry = T3.TrgetEntry
    LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
    LEFT JOIN ORDN T4 ON T4.DocEntry = L.TrgetEntry
    LEFT JOIN RDN1 T5 ON T5.DocEntry = T4.DocEntry
    LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
    WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
    GROUP BY
    T0.DocNum,T0.DocDate,T2.DocNum,T2.DocDate, M.DocNum,M.DocDate,T4.DocNum, T4.DocDate, M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    ORDER BY
    T0.DocNum,T0.DocDate,T2.DocNum,T2.DocDate, M.DocNum,M.DocDate,T4.DocNum,T4.DocDate, M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Regards,
    Madhan.

  • Sale order Query

    SELECT T0.[DocNum], T1.[Project], T2.[PrjName], T1.[CogsOcrCod] as Region, T1.[CogsOcrCo2] as Branch,T1.[WhsCode],  T1.[Dscription],T1.[LineStatus],T1.[Quantity], T1.[OpenQty],T0.[DocCur], T1.[Price], T0.[U_OrderStatus], T3.[DocNum],T3.[cardname],T3.[DocStatus] FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OPRJ T2 ON T1.Project = T2.PrjCode,OPOR T3 INNER JOIN POR1 T4 ON T3.DocEntry = T4.DocEntry
    WHERE T4.BaseRef = T0.DocNum and T0.[DocStatus] = 'O'
    i have this query it is working fine but there is problem. that is  it is showing only that sale order wich purchase order is posted my client want all sale order if his purchase order is poted or not

    Hi Ajit,
    See if this one works. A few fields were removed as they don't exist in my db, you should be able to add them again.
    SELECT
    T0.DocNum, T1.Project, T2.PrjName, T1.CogsOcrCod as Region,
    T1.WhsCode, T1.Dscription,T1.LineStatus,T1.Quantity, T1.OpenQty,T0.DocCur,
    T1.Price, 'No Purchase Order','No Purchase Order','No Purchase Order'
    FROM
    ORDR T0 INNER JOIN
    RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
    OPRJ T2 ON T1.Project = T2.PrjCode
    WHERE T0.DocStatus = 'O'
    Union
    SELECT
    T0.DocNum, T1.Project, T2.PrjName, T1.CogsOcrCod as Region,
    T1.WhsCode, T1.Dscription,T1.LineStatus,T1.Quantity, T1.OpenQty,T0.DocCur,
    T1.Price, cast(t3.docnum as varchar),
    T3.cardname,T3.DocStatus
    FROM
    ORDR T0 INNER JOIN
    RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
    OPRJ T2 ON T1.Project = T2.PrjCode, OPOR T3 INNER JOIN
    POR1 T4 ON T3.DocEntry = T4.DocEntry
    WHERE T4.BaseRef = T0.DocNum and T0.DocStatus = 'O'
    Hope it helps,
    Jesper

  • Sales Order Query Join

    Hi I have a query which returns the sum of linetotals from sales orders related to a specific Business Partner and also related to a specific Item Code.
    The problem which I'm having is that when I am testing the reports I am finding out that some of the amounts are being multiplied for a number of times.
    I think that it is a join problem.
    The query is the below:
    select distinct
              t0.cardcode
    ,          t0.cardname
    ,          sum(t2.linetotal) as 'Total'
    ,          sum(t3.linetotal) as 'GATEWAY - IPLCS'
    ,          sum(t4.linetotal) as 'GATEWAY - IP TERMINATING CHRGS & LINKS'
    ,          sum(t5.linetotal) as 'Dedicated Symmetric International IP Bandwidth'
    ,          sum(t6.linetotal) as 'Dedicated Symmetric International IP Bandwidth Daily'
    ,          sum(t7.linetotal) as 'Shared IP Transit'
    ,          sum(t8.linetotal) as 'Premium IP'
    ,          sum(t9.linetotal) as 'IP Addresses'
    ,          sum(t10.linetotal) as 'DDos Service'
    ,          sum(t11.linetotal) as 'MIX'
    ,          sum(t12.linetotal) as 'PVC'
    ,          sum(t13.linetotal) as 'Short term IP Transit'
    ,          sum(t14.linetotal) as 'Shared Premium IP'
    ,          sum(t15.linetotal) as 'Shared Rack Co-Location - Setup And Installation Charge'
    ,          sum(t16.linetotal) as 'Shared Rack Co-Location'
    ,          sum(t17.linetotal) as 'Remote Hands / Engineering Support'
    ,          sum(t18.linetotal) as 'Rack Co-Location- Setup & Installation Charge'
    ,          sum(t19.linetotal) as 'Rack Co-Location Space'
    ,          sum(t20.linetotal) as 'Power'
    ,          sum(t21.linetotal) as 'Wireless Ip Microwave Link - Single-Homed Setup & Installation Charge'
    ,          sum(t22.linetotal) as 'Wireless Ip Microwave Link - Dual-Homed Setup & Installation Charge'
    ,          sum(t23.linetotal) as 'Wireless Ip Microwave Link - Recurring Charge Including Mca Fees'
    ,          sum(t24.linetotal) as 'Local Connectivity - Vlan'
    ,          sum(t25.linetotal) as 'Local Connectivity - Bandwidth Access Cost (Traffic)'
    ,          sum(t26.linetotal) as 'Local Connectivity - Activation And Installation Charges For Fibre-Based Ethernet Business Plus'
    ,          sum(t27.linetotal) as 'Local Connectivity - Ethernet Over Fibre'
    ,          sum(t28.linetotal) as 'International Private Leased Circuit'
    ,          sum(t29.linetotal) as 'International Private Leased Circuit Setup Fee'
    ,          sum(t30.linetotal) as 'Wireless link operating on the Unlicensed Band - Setup fee'
    ,          sum(t31.linetotal) as 'Wireless link operating on the Unlicensed Band - Recurring Charge'
    ,          sum(t32.linetotal) as 'GIGE LX SFP Module'
    ,          sum(t33.linetotal) as 'PSAX 1000 Fan/Alarm Module'
    ,          sum(t34.linetotal) as '-48 VDC PS PSAX 2300 4500'
    ,          sum(t35.linetotal) as 'Stratum/-48VDC PS PSAX 1000'
    ,          sum(t36.linetotal) as 'Alcatel Equipment TNEs FOR INVOICE POSTING ONLY'
    ,          sum(t37.linetotal) as 'Tower Site Works'
    from
              ocrd t0 left outer join ordr t1 on t0.cardcode = t1.cardcode
                        left outer join rdr1 t2 on t2.docentry = t1.docentry
                        left outer join rdr1 t3 on t3.docentry = t1.docentry and t3.itemcode = 'DSC000001'
                        left outer join rdr1 t4 on t4.docentry = t1.docentry and t4.itemcode = 'FLC000001'
                        left outer join rdr1 t5 on t5.docentry = t1.docentry and t5.itemcode = 'RVL000001'
                        left outer join rdr1 t6 on t6.docentry = t1.docentry and t6.itemcode = 'RVL000002'
                        left outer join rdr1 t7 on t7.docentry = t1.docentry and t7.itemcode = 'RVL000003'
                        left outer join rdr1 t8 on t8.docentry = t1.docentry and t8.itemcode = 'RVL000004'
                        left outer join rdr1 t9 on t9.docentry = t1.docentry and t9.itemcode = 'RVL000005'
                        left outer join rdr1 t10 on t10.docentry = t1.docentry and t10.itemcode = 'RVL000006'
                        left outer join rdr1 t11 on t11.docentry = t1.docentry and t11.itemcode = 'RVL000007'
                        left outer join rdr1 t12 on t12.docentry = t1.docentry and t12.itemcode = 'RVL000008'
                        left outer join rdr1 t13 on t13.docentry = t1.docentry and t13.itemcode = 'RVL000009'
                        left outer join rdr1 t14 on t14.docentry = t1.docentry and t14.itemcode = 'RVL0000010'                    
                        left outer join rdr1 t15 on t15.docentry = t1.docentry and t15.itemcode = 'RVM000001'
                        left outer join rdr1 t16 on t16.docentry = t1.docentry and t16.itemcode = 'RVM000002'
                        left outer join rdr1 t17 on t17.docentry = t1.docentry and t17.itemcode = 'RVM000003'
                        left outer join rdr1 t18 on t18.docentry = t1.docentry and t18.itemcode = 'RVM000004'
                        left outer join rdr1 t19 on t19.docentry = t1.docentry and t19.itemcode = 'RVM000005'
                        left outer join rdr1 t20 on t20.docentry = t1.docentry and t20.itemcode = 'RVM000006'
                        left outer join rdr1 t21 on t21.docentry = t1.docentry and t21.itemcode = 'RVN000001'
                        left outer join rdr1 t22 on t22.docentry = t1.docentry and t22.itemcode = 'RVN000002'
                        left outer join rdr1 t23 on t23.docentry = t1.docentry and t23.itemcode = 'RVN000003'
                        left outer join rdr1 t24 on t24.docentry = t1.docentry and t24.itemcode = 'RVN000004'
                        left outer join rdr1 t25 on t25.docentry = t1.docentry and t25.itemcode = 'RVN000005'                    
                        left outer join rdr1 t26 on t26.docentry = t1.docentry and t26.itemcode = 'RVN000006'
                        left outer join rdr1 t27 on t27.docentry = t1.docentry and t27.itemcode = 'RVN000007'
                        left outer join rdr1 t28 on t28.docentry = t1.docentry and t28.itemcode = 'RVN000008'
                        left outer join rdr1 t29 on t29.docentry = t1.docentry and t29.itemcode = 'RVN000009'
                        left outer join rdr1 t30 on t30.docentry = t1.docentry and t30.itemcode = 'RVN0000010'
                        left outer join rdr1 t31 on t31.docentry = t1.docentry and t31.itemcode = 'RVN0000011'
                        left outer join rdr1 t32 on t32.docentry = t1.docentry and t32.itemcode = 'TNE000001'
                        left outer join rdr1 t33 on t33.docentry = t1.docentry and t33.itemcode = 'TNE000002'
                        left outer join rdr1 t34 on t34.docentry = t1.docentry and t34.itemcode = 'TNE000003'
                        left outer join rdr1 t35 on t35.docentry = t1.docentry and t35.itemcode = 'TNE000004'
                        left outer join rdr1 t36 on t36.docentry = t1.docentry and t36.itemcode = 'TNE000005'
                        left outer join rdr1 t37 on t37.docentry = t1.docentry and t37.itemcode = 'TNE000006'
    where
              t0.groupcode in (100,114)
    group by
              t0.cardcode
    ,          t0.cardname
    Can you help please?
    Thanks,
    vankri
    Edited by: vankri on Nov 10, 2009 1:02 PM

    Try something like this with all your required items:
    Select  t0.cardcode , t0.cardname , sum(t2.linetotal) as 'Total'
      ,(select sum(r.linetotal) from rdr1 r join ordr o on r.docentry=o.docentry
              where o.cardcode=t0.Cardcode and r.ItemCode= u2019DSC000001')
                        as 'GATEWAY - IPLCS'
      ,(select sum(r.linetotal) from rdr1 r join ordr o on r.docentry=o.docentry
              where o.cardcode=t0.Cardcode and r.ItemCode= u2019FLC000001u2019)
                        as 'GATEWAY - IP TERMINATING CHRGS & LINKS'
    From ocrd t0 left outer join ordr t1 on t0.cardcode = t1.cardcode
                      left outer join rdr1 t2 on t2.docentry = t1.docentry
    group by t0.cardcode ,t0.cardname

  • Sale Order Query Print layout/Crystal Report Query required

    Hi Experts,
    I created a Sale Order. Items included in it are service and material.
    (I created a BOM, bound the child material item to the parent service item. Moreover child item will have unit price where as parent item will not have unit price)
    I need the report on it please let me know how i can do it.
    I tried with below query
    select a.DocEntry, a.DocNum, a.CardCode, a.CardName, b.DocEntry,b.ItemCode, b.Dscription, b.Quantity, b.Price, b.LineTotal, a.DocTotal, a.VatSum 
    from ORDR a inner join RDR1 b on a.DocEntry = b.DocEntry
    --and b.TreeType <> 'N'
    where a.docnum = '14240621'
    output of above query is
    DocEntry
    DocNum
    CardCode
    CardName
    DocEntry
    ItemCode
    Description
    Qty
    Unit Price
    Line Total
    DocTotal
    Tax Amount
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    302010001
    PROVIDING & LAYING
    17.62
    2493.76
    43940.05
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    MT0001
    Material for PROVIDING & LAYING
    17.62
    2800
    49336
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    305010005
    BM CM INCLUDING CEMENT
    10.055
    1980
    19908.9
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    MT0002
    Material for BM CM  INCLUDING CEMENT
    10.055
    1650
    16590.75
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    302040001
    P/APPLYING
    65
    116.5
    7572.5
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    MT0003
    Material for P/APPLYING
    65
    65
    4225
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    301000001
    P& FIXING
    2.233
    31625.05
    70618.74
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    MT0004
    Material for P& FIXING
    2.233
    44000
    98252
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    306010001
    PROVIDING RMC
    3
    3593
    10779
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    MT0005
    Material for PROVIDING RMC
    3
    4847
    14541
    354652
    18888.46
    and my desired output is
    Unit price of both child item and parent item should be display in single column. ie. cumulative in Unit Price Column and Linetotal respectively.
    DocEntry
    DocNum
    CardCode
    CardName
    DocEntry
    ItemCode
    Description
    Qty
    Unit Price
    Line Total
    DocTotal
    Tax Amount
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    302010001
    PROVIDING & LAYING
    17.62
    5293.76
    93276.05
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    305010005
    BM CM  INCLUDING CEMENT
    10.055
    3630
    36499.65
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    302040001
    P/APPLYING
    65
    181.5
    11797.5
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    301000001
    P& FIXING
    2.233
    75625.05
    168870.7
    354652
    18888.46
    621
    14240621
    CDR0001
    ABCDEFGH
    621
    306010001
    PROVIDING RMC
    3
    8440
    25320
    354652
    18888.46
    please let me know the update on this.
    with regards

    Hi Nagarajan,
    thanks for reply..
    1) Yes, i.e i have taken into BomType: Template
    2) i did not get any helpful output by using treetype by keeping 'S' and 'N', i kept in comment.
    3) Actually MT0001-05 - these are material item- unit prices are fixed. see in attached image
         for parent item, unit prices are not fixed. I give the price for them in Sale Order.
         I want unit price for parent and child should be summed/cumulative for Sale Order print.
         (in my above post, first matrix exactly same as sale order line items plz check it)
    Please help me, how i can achieve this by query(for PLd or Crystal report)
    With Regards

  • Open Sales Order Query

    Hello Experts,
    I would like to pull all Open Sales Orders that do not have purchase orders and are more than 180 days old.
    I tried the following query but does not seems to work exactly:
    select t0.DocNum
    ,t0.DocDate
    ,DateAdd(Day,180,t0.DocDate) as Due180Days
    , t0.DocDueDate
    , t1.PymntGroup
    , t0.OwnerCode
    , t2.firstName
    , t2.lastName from ordr t0
    inner join OCTG t1 on t0.GroupNum = t1.GroupNum
    inner join OHEM t2 on t0.OwnerCode = t2.empID
    where (t1.PymntGroup like '%prepaid%'
    or t1.PymntGroup like '%deposit%')
    and t0.DocStatus ='O'and t0.PoPrss='N' and DATEADD(Day,180,t0.DocDate)>180
    and t0.OwnerCode=18
    Any hlep would be appreciated.
    Regards,
    Praneeth

    Hello Praneeth,
    You may try this:
    select t0.DocNum,t0.DocDate,DateAdd(Day,180,t0.DocDate) as Due180Days,
    t0.DocDueDate, t1.PymntGroup, t0.OwnerCode, t2.firstName, t2.lastName
    from ordr t0
    inner join OCTG t1 on t0.GroupNum = t1.GroupNum
    inner join OHEM t2 on t0.OwnerCode = t2.empID
    where (t1.PymntGroup like '%prepaid%'
    or t1.PymntGroup like '%deposit%')
    and t0.DocStatus ='O'and t0.PoPrss='N' and DATEDIFF(DD,t0.DocDate,GetDate())>180
    and t0.OwnerCode=18
    What is exactly the issue not seems to work?
    Thanks,
    Gordon

  • Sale order change problem.-Variant configration

    Dear All,
    After  sale  order  configration and  material transfered  to  sale  order  stock ,  then when i  trying  to  change   mode  in  sale  order  i  am  getting  the  error  "Internal error in communication between  configuration and sales doc.GET_CONFIG_MODE"
    Please  give  the  correct  solution    above  problem
    Regards
    SVR
    Edited by: sunitha p on Apr 30, 2008 9:24 AM

    closed

  • Sales Order Query for  in SAP B1

    Hi,
    I Need  to generate a report to Calculate the net sales orders for a particular customer in a given period. i can able to calculate the total sales order details itemwise but my query not works when the customer returns the particular products.( ie) I need to subtract the credit memo value from the order value of the particular product when the customer returns the product.
    Here is my Query Please any one Help me... what mistake in this query
    SELECT     A.CardName AS 'Customer Name', A.Address, A.DocNum AS 'Ord.No', CONVERT(varchar, A.DocDate, 3) AS 'Date', B.Dscription AS 'Item Name',
                          CASE WHEN B.itemcode = F .itemcode and A.CardCode = G.CardCode and A.Slpcode = F.Slpcode THEN B.quantity - F .quantity ELSE B.quantity END AS Quantity,
                          CASE WHEN B.itemcode = F .itemcode and  A.CardCode = G.CardCode and A.slpcode = F.slpcode THEN B.price - F .price ELSE B.price END AS Price, B.DiscPrcnt,
                          CASE WHEN B.itemcode = F .itemcode and A.CardCode = G.CardCode THEN B.linetotal - F .linetotal ELSE B.linetotal END AS Amount, B.VatPrcnt,F.ItemCode,E.Itemcode,D.Itemcode,C.Itemcode
    FROM
    ORDR A INNER JOIN
    RDR1 B ON A.Docentry = B.Docentry LEFT JOIN
    INV1 C ON A.Docentry = C.Baseref and C.Basetype=17 LEFT JOIN
    DLN1 D ON A.Docentry = D.BaseRef and D.Basetype=17 or C.Docentry=D.BaseRef and D.Basetype =13 LEFT JOIN
    RDN1 E ON D.Docentry = E.BaseRef and E.Basetype =15 LEFT JOIN
    RIN1 F ON C.Docentry =F.BaseEntry and F.Basetype = 13 or E.Docentry = F.BaseRef and F.BaseType = 16 or E.TrgetEntry = F.Docentry and F.Targettype= 14 LEFT JOIN
    ORIN G ON G.Docentry =F.Docentry Left join
    OSLP H ON A.Slpcode = H.Slpcode
    WHERE     (A.CardName = 'SHASUN CHEMICAL AND DRUGS') AND (A.DocDate >= '2000/9/30') AND (A.DocDate <= '2009/10/10')
    group by A.CardName , A.Address, A.DocNum , A.DocDate, B.Dscription,B.Itemcode,
    F.Itemcode,A.cardcode,G.cardcode,A.slpcode,
    F.Slpcode,B.quantity,F.quantity,B.Price,F.price,B.vatprcnt,B.discprcnt,B.Linetotal,F.linetotal,F.ItemCode,E.Itemcode,D.Itemcode,C.Itemcode
    ORDER BY 'Date'
    Thanks,
    vasanthapraba.

    Maybe this will help you further?
    SELECT A.CardCode, DocNum AS 'Ord.No', CONVERT(varchar, A.DocDate, 3) AS 'Date', B.Dscription AS 'Item Name', B.ItemCode AS 'Item Code'
    , SUM(B.quantity - D.quantity) AS 'Quantity'
    , SUM(B.price - D.price) AS 'Price'
    , SUM(B.LineTotal - D.LineTotal) AS 'Amount'
          FROM ORDR A
    INNER JOIN RDR1 B ON (A.DocEntry = B.DocEntry)
    LEFT JOIN DLN1 C ON (B.DocEntry = C.BaseEntry AND B.LineNum = C.BaseLine)
    LEFT JOIN RDN1 D ON (C.DocEntry = D.BaseEntry AND C.LineNum = D.BaseLine)
    WHERE (A.DocDate >= '20090925') AND (A.DocDate <= '20090925') AND (A.CardName = 'SHASUN CHEMICAL AND DRUGS')
    GROUP BY A.CardCode, A.DocNum, A.DocDate, B.Itemcode, B.Dscription
    ORDER BY 'Date'

  • Sales Order Stock - Problem with Schedule line

    Hi guru,
    I have a problem with my schedules line.
    We use the Sales order stock ( using MB1B with good movement  412/E) for some specific customers.
    Even if the sales order reservation works well, there is an issue with the schedule line in the order.
    Indeed when i enter the material in the order the schedule line display an availibily in 8 days even if the material is out of stock or available now....
    When i enter the same materila in a standard order(with item category without special stock E) the schedules line are good...
    What is it the most weird is that i have done the customizing by copying the standard item and i have just added the special stock E in the item category.
    If anyone can help me!!
    Thanks a lot

    hello Lakshmipathi,
    Thanks a lot for your reply.
    I tried to change the requierement class in order to put one with special stock E as you explained, but i still have my weird schedule line. When i put the item in the order it is 0 stock for today, but stock find in 12 days either if there is stock or no(unrestricted stock i mean).
    If i change the RDD in more than 12 days the stock is available for the date requested.
    If you have an idea of what could be wrong because on my case i want the schedule line to be at 0 while the sales order reservation has not been processed (via MB1B/412/E) and once the stock movement is done the schedule line has to be find.
    I dont know if im clear enought..
    To be more clear,  i want the schedule line based on the "sales order stock" and not on the "unrestricted stock".
    thanks for your help!
    Guillaume

  • Send Sales Order Query

    Hi ,
    I want Query for Sales order with quantity and sales return in one query. Following are parameters I want
    Customer from Sales Order,  Posting Date  from Sales Order,  Delivery Date  from Sales Order , Document Date  from Sales Order
      Document No from Delivery ,  Item No. and respective tax bifergation from Delivery , Item No. and respective tax bifergation from Return,  Document No from Return,  Item No from AR Invoice,  Item Description , quantity, Unit price  and document no from AR Invoice
    Thanks in advance

    Hi Sonal,
    Try this, it will be work exactly and get the require details,
    SELECT  T0.DocNum as 'SO. No.',
    T0.DocDate as 'SO. Date',
    T2.DocNum AS 'Del.Doc.No.',
    T2.DocDate AS 'Delivery Date',
    M.DocNum as 'A/R Invoice No.',
    M.DocDate as 'Inv. Date',
    M.CardName as 'Vendor Name',
    M.NumAtCard as 'Bill No. & Date',
    ISNULL(L.ItemCode,'Service Item') as 'Item Code',
    L.Dscription,
    L.Quantity,
    (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=10 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
    (SELECT Sum(TaxSum) FROM INV4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
    (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
    (Select Sum(LineTotal) From INV3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN ODLN T2 ON T2.DocEntry = T1.TrgetEntry
    INNER JOIN DLN1 T3 on T3.DocEntry = T2.Docentry
    INNER JOIN OINV M ON M.DocEntry = T3.TrgetEntry
    LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
    WHERE M.DocDate >= '[%0]' AND M.DocDate <= '[%1]'
    GROUP BY
    T0.DocNum,T0.DocDate,T2.DocNum,T2.DocDate, M.DocNum,M.DocDate,M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    ORDER BY
    T0.DocNum,T0.DocDate,T2.DocNum,T2.DocDate, M.DocNum,M.DocDate,M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Regards,
    Madhan.

  • Sales order query - display invoice date and invoice number

    I have a query that is reading information from both the ORDR and RDR1. How do I link to AR invoice to get the invoice number and invoice date if the line item of the sales order has been shipped (we do not use deliveries so the AR invoice is the next document after the sales order.
    Thanks

    Hi Keith,
    The link between ORDR and RDR1 to invoice:
    RDR1.trgetentry = OINV.DocEntry
    or
    INV1.BaseEntry = ORDR.DocEntry
    Use which is more appropriate to your query
    Regards,
    David

  • Getting last changed by in a sales order query

    Hi there,
    I'm creating a query to show sales orders. I need to output to show the "last changed by" username.
    This isn't stored in the VBAK or VBAP tables. As far as i can see from results on google and i can see in SE16N, the table needed is CDHDR, but i cant join this with the VBAK table.
    I'm trying to join them by using the objectvalue and Salesorder number.
    Does anyone know which other table or how to join the tables above?

    Hi,
    1. In the CDHDR - pass the below values
    Object:VERKBELEG     
    Object value - ASales order number.
    T.code - VA02.
    2. here you will have the Name, Date time - on which you can get the lsast changed date
    3. This CDHDR / CDPOS are the tables that will have the values for all the changes.
    Reg
    Dsk

  • Sales Order conditions problem

    HI Folks,
    I am stuck up with a scenario where i need to copy the sales order condition of line item and update the newly spiltted line items.
    When i am doing the copy of it for some condition types iam facing problem
    for example
    I have one condition type say ZTEST and it currency  maintained as %. Now when i look up in table KONV it is showing the value of KBETE(Condition value) as 200 , but if i view through va03 it is showing 20. I think there is some conversion that SAP is doing.So when i am copying i am doing the value that is  there in KONV table and finally the new split item  is showing in va03 as 200 instead of 20.
    Can anyone help me out how to solve this issue. Let me know if any one wants any further information on it.
    Regards,
    Nagaraj

    Hi,
           check the table TCRUX  for the currencies you are using it will give information about how many
    decimal places for every currency based on the decimal places you have to multiply or divide .
    Thanks & regards,
    Sateesh.

Maybe you are looking for

  • Change Profit Center in FI/CO document for Network or WBs

    The client does not want to change the profit center assignment on the network or WBS. Finance would like the ability to change the profit center when the FI/CO document is created. When trying a FI or CO substitution , we keep getting an error messa

  • Quicktime Pro on Mavericks

    Where can I find Quicktime Pro on Mac OS 10.9.1?

  • No Fix for Dreamweaver CS4 not loading?

    I am seeing more and more recently that people are experiencing the crashing DW effect. Does anyone have a fix for this, or are we stuck until adobe finally corrects the issue? I have read tons of posts on here and other forums, but nothing seems to

  • Php5 static class method access syntax error

    Dreamweaver is complaining about this syntax $class = 'ClassName'; $class::method(); // static method Is there a way to omit these error warnings?

  • Conky - Display available pacman updates

    This is a python script I found and modified to display package update info with conky. The original was written by Majkhii and Sabooky which I found here via the wiki entry for conky: https://bbs.archlinux.org/viewtopic.php?id=37284 This one is much