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.

Similar Messages

  • Error while sending sales order form by fax

    hi,
    Sending Sales order by fax is not working. While adding output type for Sales order choosing device as 'FAX' is throwing an error saying that 'Error while sending fax with SO_OBJECT_SEND, return code 9'.  Anything needs to be configured or we have to code anything in SAPScript program. Please advise.

    Hi Harry,
    You don't need to write any particular code for sending FAX in SAPscript. But you may need to check some configurations regarding it.
    We configure SCOT to send Fax and mails to outside SAP. Check SAP Note 455140 for the configuration of SCOT tcode.
    Please refer this link [Sending FAX |Sending FAX from SAP;
    It might be helpful.
    Thanks,
    Daya.

  • 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

  • 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

  • How to send sales orders through XI  to non sap system

    Hello Experts,
    i need to send Sales order details from ECC to non sap system.
    anybody can help me to proceed with this in detailed way.
    i know how to send idoc through xi between sap systems.
    But i need between sap to non sap system.
    Thanks & Regards,
    Lakshmi..

    Hi !!
    Check this weblog on how to enable SSL:
    /people/gregor.wolf3/blog/2005/10/11/setup-https-ssl-for-the-sneak-preview-sap-netweaver-04-abap-edition-on-windows
    refer this realtive thread which shows the .NETnet integration with XI
    Re: .NET Client Integration with SAP XI
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2131 [original link is broken] [original link is broken] [original link is broken]
    for idoc related settings in r/3 refer the below link...
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/73527b2c-0501-0010-5398-c4ac372c9692
    IDoc to File scenario
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
    check this out ..
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFAALEQS/CABFAALEQS.pdf
    http://www.thespot4sap.com/Articles/SAP_ALE_Introduction.asp
    Also go thru this Blogs
    ALE Configuration for Pushing IDOC's from SAP to XI by Swaroopa Vishwanath
    Configuration Steps for Posting IDOC's by Ravikumar Allampalam.
    IDOC - File scenario
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
    configuring IDOCS
    /people/sravya.talanki2/blog/2006/12/27/aspirant-to-learn-sap-xiyou-won-the-jackpot-if-you-read-this-part-iii
    IDOC scenarios
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cdded790-0201-0010-6db8-beb9bb2b2660
    Idoc related setting
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/73527b2c-0501-0010-5398-c4ac372c9692
    refer this thread also
    Integration between sap and non-sap
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/5651.. [original link is broken] [original link is broken] [original link is broken]
    also referthe concept of SSO
    To undersand SSO scenarios gothro the links in my reply in the following thread:
    SSO scenarios and configuring steps
    Check the following link to know the procedure for user mapping:
    Procedure to follow for user mapping.
    The following link gives you more idea on User Mapping:
    More Info on User Mapping
    Pls reward if useful

  • Sending Sales Order via Outlook

    Apologies if this is not the correct forum to post this question.
    We are trying to use outlook as the default email system to send Sales Order, PO's, Invoices, etc.
    We have tried the Outlook Integration to get a not so complete solution.
    We are now trying to  B1 Print & Delivery from Boyum, and we can make the document be saved in the drafts folder in Outlook. This is again a half solution.
    Is there a macro  that we can use to open the outlook window with the attachment and the send to: address and be able to actually see what is going to get be sent via email and add any text?
    Thank you,
    Eddy

    Third Wave have an add on that does this. Advanced Productivity Pack

  • Sending sale order data

    hi,
    how can we send sale order data from sapxisap.
    are there any standard tcode like BD10 BD12 BD14.
    plz help me.
    thanks and regards
    vijender

    For creating sales documents (sales order) through IDOCS you will have to use the T code WE19.  In that click basic type and enter order05(IDOC type) and select via message type then enter ORDERS(message type), click execute.
    You will get to see many fields.here you have to enter the datas that you enter in the VA01 screen in order to create sales order. The datas such as material name, date, qty, P.O no etc.  After entering all the datas, you click standard inbound the IDOC would be created by the system.You can see the created order by going in to VA03 screen.
    Next time when you create the IDOC, in same tcode WE19 screen, click existing IDOC and enter the IDOC which you created in the above step and just change the P.O no.Sytem will create new sales order through new IDOC
    Before doing all you need to maintain the partner profile in T code WE20

  • 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

  • Sending sales order through idoc

    hai,
    Is it possible to send IDOC of sales order in IDES.
    If so can anyone pls let me the solution

    Yes, You can send IDOC's in IDES for Testing (Client to Client 800 to 000).
    For Configuration related you can search in ABAP General Forum
    Regards,
    Ramesh

  • 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.

  • 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'

  • 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

  • Sending sales order details through ALE to External system

    hi folks,
             i have a simple scenario to do with ALE/IDOCS. i have to create sales order in SAP. And when ever that SO is created the sales orders details should be sent to an external system (here, notepad). could any one suggest me teh step by step proceduer for the same......or atleast some brief procedure hw to acheive this...i also have one more doubt....can we send IDOCS from ECC 5.O to IDES 4.6. if i am trying to do the same it showing some error mentioning that basic idoc type does not exist in 4.6c......can any one resolve my doubt,
                            thnx in advance,
                                santosh.

    Thanks for your quick response, Sarathy.
    Yes I am referring to SAP ECC to third party system but using ALE.
    Here is the scenario, a sales order will be created in SAP CRM and that sales order will be replicated to ECC as a sales order. Now I need to generate an Idoc for this sales order to send it to a third party system.
    Regards

  • To send sales order header text in mail description

    Hi all,
    my requirement is to send the sales order header texts(which have text ids as 0001,002,003 and text object :VBBK) as the description in the mail step.
    Please help me.
    Regards,
    Sravanthi Chilal

    thank u swami,it is working.
    but in the sales order i have maintained 3 texts(0001,0002,0003). while i execute the method individually,i am able to see all 3 texts.
    i created a background activity before calling the decision step for determining the texts.iam displaying that container element in the description of the decision step.
    my problem is that iam able to see only one text,i should be able to see all three.
    i hope iam clear.
    Regards,
    Sravanthi Chilal

Maybe you are looking for

  • Simple button AS help

    I'm learning Action Script. I adapted the graphics from premade Flash script from Flashkit.com. I'm trying to write the script to made the buttons active and get a URL. It uses a rotating graphic with six buttons positioned like on the spokes of a fe

  • Bootcamp - the disk cannot be partition because some files cannot be moved

    Hi, I have been using boot camp for a while and everything was working fine but over time, windows were picking up some virus so I did a stupid thing of removing the whole partition thinking that I can re-partition again and install a clean windows s

  • Cs6 raw plugin not recognizing lumix g5 raw files

    I just installed cs6 on my computer which is not connected to the internet. The camera raw plugin does not recognize my lumix G5 camera raw files. I tried downloading and installing what i think is the most recent raw plugin, but it still does not re

  • Dbms_xmldom and xmldom

    what is the difference between xmldom and dbms_xmldom packages? Has anyone worked with dbms_xmldom? if so does it still uses JVM inside the database?

  • Silent install instructions for Photoshop Elements 8 (AOO volume license version on Windows)

    Hello, Does anyone know if the silent installation of Photoshop Elements 8 works the same way the versions 6/7 work? I can't find any article in the support site that states that is does... Thanks in advance for answering this question. Joost Brenter