Query Design by Sales Order

Hi all,
I have a query based on a Sales Order Number and Invoice. Since there are multiple invoices per sales order number i am getting the Total Sales Order amount in multiple line items. I only need to show the Result value and be able to sum it up with other Sales Order result values. How can i do this in the query?
Derired Output:
Sales Order     Invoice     Amount
10000008                     9110000002     3,690,000.00
10000008                     9110000003     3,690,000.00
10000008                     9110000003     3,690,000.00
10000008                     9110000004     3,690,000.00
10000008                     9110000005     3,690,000.00
                                          Result     3,690,000.00
10000006                       9110000006          5,000.00
10000006                       9110000007          5,000.00
10000006                       9110000008          5,000.00
                                           Result          5,000.00
                               Overall Result   3,695,000.00 (3,690,000.00+5,000.00)
Cheers

Hi,
I think its possible with the use of nested expection aggregation at query level.
Just give a try.
Make a new formula and put your kf(amount in it) select the exception aggregation tab and select maximum and characterstic choose your sales order number.
Hope it helps.
Regards
AL

Similar Messages

  • Select query help for Sales order

    Hi Experts,
    I have to write a select query to fetch sales orders which are open along with the quantities which are open ( not delivered). What would the best approach for this?
    Any help is appreciated. Expecting code samples....Thanks
    Thanks
    Ricky

    hi,
    do like this,
    write a select query for vbak and vbuk as follows.
    delivery status field is <b>lfstk</b> from <b>vbuk</b>,
    and relation field is <b>vbeln</b> from the both the tables.
    reward points if useful,
    regards,
    seshu.

  • Trying to create a query that shows Sales Order/Invoice Totals as well as Paid/Outstanding/Available Down Payments

    Currently working on SAP B1 v8.82
    I'm looking to generate a query that will give an overall report for a given customer that shows Sales Order No, Invoice No, Sales Order Total, Invoice Total, Amount Paid on Invoice, Amount Remaining on Invoice, Down Payments Available, Open on Sales Order.
    I'm not sure what the best way to select the columns in bold above.  Invoice Total should be self-explanatory.  Amount Paid should be any down payments or applied payments on the invoice.  The balance due on the invoice (which seems to be T0.DocTotal if I'm not mistaken) should = 'Invoice Total' - 'Amount Paid on Invoice'. In the Down Payments Available column I want the total amount of money on the account or on down payments that aren't tied to a Sales Order.  If a client overpaid in the past for instance and there's a credit on their account, then it should contribute to this sum.  Open on Sales Order should be pretty easy.  I guess it's just the sum of everything that is still open on the Sales Order.  I'm just not sure what the best way to sum all the un-delivered freight, tax, and line items is.  Here's what my query looks like so far.
    SELECT DISTINCT T4.[DocNum] [Sales Order No],
    T0.DocNum [Invoice No],
    T4.DocTotal [Sales Order Total]
    T0.DocTotal [Amount Outstanding],
    FROM OINV T0
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN DLN1 T2 ON T1.BaseEntry = T2.DocEntry AND T1.BaseLine = T2.LineNum
    INNER JOIN RDR1 T3 ON T2.BaseEntry = T3.DocEntry AND T2.BaseLine = T3.LineNum
    INNER JOIN ORDR T4 ON T3.DocEntry = T4.DocEntry
    INNER JOIN OSLP T5 ON T4.SlpCode = T5.SlpCode
    WHERE T0.CardName Like '%%[%0]%%'
    GROUP BY T4.DocNum, T0.DocNum, T0.DocTotal, T4.DocTotal
    I tried doing a little searching around for queries similar to what I need, but I could find exactly what I was looking for and I'm very unfamiliar with OJDT, JDT1, and ITR1 tables which I think might be important to finding unapplied payments...

    Thanks.  There's a few problems though.
    1)  It seems that OINV DocTotal != Balance Due.  I'm seeing a number of invoices where there was a balance due, but we applied additional money (either we took another incoming payment and applied it or applied money from the account balance, etc.) and yet it still shows a total.
    2)  It's pulling incoming payments from different customers.  I think this is because the table was joined based on "RCT2 T4 on T4.[DocEntry]  =  T3.[DocNum] and T4.[InvoiceId] = T2.[LineNum]"  In one example I have 2 incoming payments 446 and 614.  Both have the DocEntry 542, but one relates to A/R Invoice 542 (for a different client) while the other relates to Down Payment Invoice 542.  *I was able to fix this by adding WHERE T5.CardCode = [%0]*
    3)  I'm going to work with this a little bit and see if I can alter it to make it work for me.  Basically this query falls a little short on the following:
    -  Doesn't include incoming payments that aren't linked to a down payment invoice.
    -  Does not give the Invoice Total (I'd like to know how much of the SO was invoiced.  DocTotal seems to give me Amount Invoiced - Down Payments.  I'm not sure the best way to get this number.  Maybe I could do the sum of each line * tax + freight)
    -  Does not give the outstanding amount on an invoice.  The ARtotal [DocTotal] column gives me how much was owed when the invoice was created, but it doesn't tell me what is currently owed.
    -  Lastly it may complicate the query too much and could be left off, but it would be nice to see if they have any money from credits or incoming payments that has not been applied.  Perhaps this would be easily accomplished by simply pulling in their account balance.

  • A query to display sales orders with corresponding outbound deliveries

    Hi Experts,
    Don't know if this is the right place to post the question but i would like to know if a query, in SAP, can display sales orders with their corresponding outbound deliveries, i tried using table LIKP and VBAK, VBKD didn't help. the whole idea is to enter any specified sales order number and the query will return any outbound deliveries belong to the sales order.
    Thanks in advance!

    run the se16 transaction - table VBFA.
    This table gives the Sales document flow.
    Give the sales order nos. and in the subsequent document category select delivery.
    You will get all deliveries.
    Thanks
    Ajay

  • Query in creating Sales Order with BAPI_SALESORDER_CREATEFROMDAT2?

    Hi,
    I am trying to create a Sales Order with the BAPI and have a contract as a reference. Do I need to explicity mention the line item details in case I need the data from Contract to be copied here. If not how do I acheive this functionality.
    P.S: I am able to create the Sales Order with the reference and I can see the Sales Order in the contracts workflow but not the line items in the Sales Order.
    Any suggestions?
    Regards,
    Karthik

    Hello, Karthik,
    By reading the documentation of BAPI
    BAPI_SALESORDER_CREATEFROMDAT2
    the mandatory data to be supplied to the BAPI, in order to succesfuly create the the Sales Order are:
    "1. ORDER_HEADER_IN :
                    DOC_TYPE Sales document type
                    SALES_ORG Sales organization
                    DISTR_CHAN Distribution channel
                    DIVISION Division
    2. ORDER_PARTNERS..:
                    PARTN_ROLE Partner role, SP sold-to party
                    PARTN_NUMB Customer number
    3. ORDER_ITEMS_IN..: MATERIAL Material number"
    The OSS note 93091 basically re-states the same thing.
    After studying this BAPI's source code, the conclusion seems to be the one the documentation points to: <b>the BAPI can only be used to create a sales order by supplying (manually) all the necessary data.</b>
    BTW: How did you manage to create the empty Sales Order with reference, you mentioned in your mail? Just by providing a reference document number? <b>And nothing more?</b>
    Bye,
    Bogdan

  • Sales Order Text Lines in SAP Query

    I have a requirement to output several text lines into a SAP query based around sales orders.
    I have included some code to read the details into my query and get no syntax errors, however the report gives a blank output for each of the text fields included, despite there definitely being some text with the specified attribute ID and text object in the table STXL.
    Where am I going wrong?
    Please find the coding below for one of the text field I'm trying to extract:
    TABLES:STXL.
    DATA:
        VBELN LIKE VBAP-VBELN,
        POSNR LIKE VBAP-POSNR,
        TDNAME LIKE STXL-TDNAME,
        MYLINE LIKE TLINE-TDLINE,
        ZE18_LINE(1200) TYPE C.
    DATA:BEGIN OF LINES OCCURS 0.
            INCLUDE STRUCTURE TLINE.
    DATA:END OF LINES.
    DATA:BEGIN OF MYHEADER.
            INCLUDE STRUCTURE THEAD.
    DATA:END OF MYHEADER.
    CLEAR TDNAME.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT = VBAP-VBELN
    IMPORTING
      OUTPUT = VBELN.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      INPUT = VBAP-POSNR
    IMPORTING
      OUTPUT = POSNR.
      CONCATENATE VBELN POSNR INTO TDNAME.
    CALL FUNCTION 'READ_TEXT'
        EXPORTING
            ID = 'ZAT2'
            LANGUAGE = SY-LANGU
            NAME = TDNAME
            OBJECT = 'VBBP'
         IMPORTING
            HEADER = MYHEADER
         TABLES
            LINES  = LINES
    EXCEPTIONS
            ID = 1
            LANGUAGE = 2
            NAME = 3
            NOT FOUND = 4
            OBJECT= 5
            REFERENCE_CHECK = 6
            WRONG_ACCESS_TO_ARCHIVE = 7
            OTHERS = 8.
    IF SY-SUBRC = 0.
      LOOP AT LINES.
        MOVE LINES-TDLINE TO TEXT.
        ENDLOOP.
    ENDIF.

    Hi -
    Please check in debuging.
    check the value of TDNAME correctly populated with sales order no and sales order item.
    You can cross check with the table STXH with TDNAME and see if any entries is available for TDID 'ZAT2' as your case.
    Here are sample code.
    DATA :    lv_tdname TYPE tdobname,
                     lw_line TYPE tline,
                    li_line TYPE STANDARD TABLE OF tline.
    CLEAR : lv_tdname , li_line[],
    cocatenate w_vbak-vbeln w_vbap-posnr into lv_tdname.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        id                      = 'ZAT2'
        language                = 'E'
        name                    = lv_tdname
        object                  = 'VBBP'
      TABLES
        lines                   = li_line
      EXCEPTIONS
        id                      = 1
        language                = 2
        name                    = 3
        not_found               = 4
        object                  = 5
        reference_check         = 6
        wrong_access_to_archive = 7
        OTHERS                  = 8.
    IF sy-subrc = 0.
      CLEAR lw_line.
      loop at li_line INTO lw_line .
    * Put your logic
      endloop.
    ENDIF.

  • Query to find out the sales order

    Hi All,
    I need a query to find sales order number against which a serial number is transacted.
    Can ny one help onthis.
    Thanks ,

    hi,
    thanks you for your reply.
    its working but i am not able to see the required item serail number.
    Bit confused its their in mtl_serial_number but its not their in sales order.
    How is it possible.
    In mtl_serial_number its current_status is '4'
    Can you please hlep me.
    Thanks

  • Sales order and incoming payment query

    Hi experts,
                     I jus need a query that contains sales order doc num, date, cust name item description doc total and how much he paid towards the document and what is the balance due....pls help me...
    regards,
    Vignesh.R

    Hi Vignesh.......
    Are you using AR Downpayment based on Sales Order?
    If yes then try this.....
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardName], T0.[DocTotal], T0.[DpmAppl] FROM ORDR T0
    Regards,
    Rahul

  • 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

  • How to link Sales Order with Service Contract and then with Install Base?

    Hi Friends,
    1) I would like to know the integeration process from sales order to Service Contract and then with Install Base.
    2) I couldn't see anything enabled in Service Tab in Order Lines, its grayed out. Is there any set up/profile option to get it enabled?
    3) How can we create AR invoice from Service Contract?
    Please let me know if anyone has idea on this.
    Thanks in Adavance,
    Vara

    Dear Sid,
    Thanks for your promt response.
    Let me explain you what I did.
    1) I have booked a Bill Only sales order which has one order line, mentioned it as Service Item and provided the same details in Service Tab in Order lines. Now Line status is "Fulfilled"
    2) Then Submitted Workflow Back Ground Process for OM Order Lines and it has created an AR Invoice and closed the line
    3) And then submitted "Service Contracts Order Capture Integration Program" from SErvice Contracts Responsibility and it completed normal.
    4) Now I went in to Launch Contracts Window and queried with the sales order but couldn't see any contract created
    5) Then I went in to Reprocess Order Window and found this order shows an error message as "Referenced Product not present in the Installed Base", then I tried to reprocessed it, but the same error message again.
    Here I have few doubts:
    1) Are the AR invoice and Service Contract Billing Invoices same?
    2) In above scenario AR Invoice has been created, I would like to do the billing from SErvice Contracts and need to create an Invoice in AR? how can I do that?
    because as you explained in one of my questions earlier, A Single Invoice can be created for the whole duration of the contract. I want to do that and trying for the same.
    3) Regarding the above error message, how can I resolve it and create the service contract against that Order?
    Thank you so much for your helpful answers.
    Regards,
    Vara

  • Pending sales order with value

    Dear Experts
    Am using below query for Pending Sales order.I just want to multiple balance quantity with my price list 1.So  can anybody modify my query.
    SELECT T1.[DocNum] as 'Sales Order No', T1.[DocDate] as 'Sales Order Date',
    T1.[CardCode], T1.[CardName], T0.[ItemCode], T0.[Dscription], T0.[Quantity] as 'Sales Order Qty',
    T0.[Quantity]-T0.[OpenQty] as 'Delivered Qty', T0.[OpenQty] as 'Balance Qty' FROM RDR1 T0  INNER JOIN ORDR T1 ON T0.DocEntry = T1.DocEntry where T1.[DocDate] between [%0] and [%1]
    thanks in advance
    parikshit

    Hi Parikshit,
    Try this Query Report,
    SELECT T0.DocNum as 'Sales Order No', T0.DocDate as 'Sales Order Date',
    T0.CardCode, T0.CardName, T1.ItemCode, T1.Dscription,
    T1.Quantity AS 'Sales Order Qty', (T1.Quantity-T1.OpenQty) AS 'Delivered Qty',
    T1.OpenQty AS 'Balance Qty', T1.OpenQty*T2.Price AS 'Open Amount'
    FROM ORDR T0
    INNER JOIN RDR1 T1 ON T1.DocEntry = T0.DocEntry
    INNER JOIN ITM1 T2 ON T2.ItemCode = T1.ItemCode
    WHERE T2.PriceList = '1'
    AND
    T1.LineStatus = 'O'
    AND
    T0.DocDate BETWEEN '[%0]' AND '[%1]'
    Regards,
    Madhan.

  • Sales order stock does not exists

    Dear All:
    I have created a sales order with reference to a quotation. the line item in sales order is also with reference to the quotation. and the stock has been assigned to that quotation. But while creating delivery, it is giving the error that sales order stock does not exist. my query is why sales order stock is required when the article is with reference to a quotation?? should not the stock be with reference to quotation??

    Hi,
    Check the Item Category of the Sales order which your using to create the delivery.In the item category confuguration VOV7 the special stock indicator 'E' may be assigned.So without a sales order stock assignement it will not allow you to create a delivery.
    GO to Mb1b for the Sales order using 412 E create a stock and see whether the delivery is created or not.If it is creating than that means the sales order stock has to be generated through your process.
    If production order confirms then it may generate a sales order stock in MTO scenario.If in your case it has to generated then you have to use MB1B trnasactio code or create your own customized program to create the sales order stock.
    Regards,
    Saju.s

  • Cancel Open Sales Order

    Hi Guru's ,
    I had a query regarding open sales order . We want to cancel the open sales order daily .
    The requirement is to cancel the order if it is open for 3 working days automatically through a report .
    Can I directly update the entry in the table VBAP AND VBAK depending on the order status .
    Is there any other alternative for this .
    Please suggest .
    Regards,
    Archana W

    Never ever update a SAP db table directly.
    Find a relavant BAPI to do so, and write a report program which will be run in background. Schedule the job using SM36.
    If you don't find a relavant BAPI (after thorough research) create a BDC using SHD0.
    regards,
    Aabhas
    Edited by: Aabhas K Vishnoi on Sep 25, 2009 3:25 PM

  • Sales Order - Pick remarks copy to Production Order remarks field

    Hi All
    I need help with the query to copy sales order - pick remarks to Production Order when the Sales Order is linked with the production order.
    Thanks
    Bongani Dlamini

    Hi All
    I still need some help with this issue.
    Here's the scenario:-
    When a user captures a Sales Order , (s)he must enter remarks in the Logistics Tab --> Pick and Pack Remarks ( to be renamed to Production Remarks).
    This info must be copied when a production manager or supervisor creates a production order and links it to the Sales Order field on the header .
    Tried a couple or tricks but still nothing.
    SELECT $[ORDR.PickRmark]
    SELECT T1.[PickRmrk] FROM OWOR T0 , ORDR T1 WHERE T1.[DocNum] =  T0.[OriginNum]
    SELECT $[ORDR.PickRmrk]
    Please help.
    Thanks
    Bongani Dlamini

  • Query Designer - Rows between Columns

    Dear all,
    I've got the following requirement and I really cannot figure out if it is doable.
    I would appreciate your help.
    I shall create a query using Sap Query Designer regarding the actual and budet data of the assets (it's a financial report).
    I'll have 2 columns for the actual data and 2 columns for the budget data.
    Is there any way:
    a) to have the assets (the rows) in the middle of the report layout, and
    b) the actual data on the left side of the assets, and
    c) the budget data on the right side of the assets
    The goal is when drilling down the assets, both pairs of columns to be expanded as well.
    Is it doable? Is there any trick?
    Thanks in advance.

    Dear Riyez
    I do thank you for your response.
    I am wondering if there is something someone could possibly do on the Query Designer side in order to fool the system.
    For instance, to design a virtual structure (I do not know how - I am thinking loudly) which would be identical to the structure that holds the assets?
    In other words, is it designeable to have a row structure, then the column key figures and, finally, another row structure identical to the first one? And when the user expands the first structure, the second structure will follow accordingly?
    Or such a solution is out of question?

Maybe you are looking for

  • Error: While applying patch 5484000(Oracle E-Business Suite 12.0.2 Release)

    Hi all, I have R12 EBS on linux machine. Am trying to apply R12 CUP 2 patch in linux. While applying am getting the following error. ERROR: ======= ATTENTION: All workers either have failed or are waiting: FAILED: file FNDGFU on worker 1. FAILED: fil

  • Can't add effects to source quicktime files in FCP 5 Academic

    I'm working on a project for someone, and their source files are .mov files. They have already composed the files into the timeline and they need some color correction done to some of the clips. When I double-click the clips on the timeline and open

  • How to authorize computer for old purchases?

    My first macbook pro crashed. Most of the stuff was under my father's name who passed. I forgot all the information including the apple id. So I made a new apple id when I got my new macbook pro. My old one statred working and I got the id and have m

  • GetLocation - returning invalid coordinates - is this even possible?

    I am using getLocation on a panel based object to set the destination point for a line. I am getting incorrect coordinates. The Java source for Component.java states: * <p> * Due to the asynchronous nature of native event handling, this * method can

  • GUI not proper after installing skype.

    Hello, I am using latest skype version for on my Windows 8.1 Laptop.After installing skype i am getting the Login screen with no text formatting.Some times it is confusing for me to Login to skype.It is asking for login into both microsoft account an