Sales Query using SQ01

I would like to create a query or maybe two queries that return the following.
1. All Sales orders that have been invoiced in a particular time period. We must be able to show sales orders, net value and invoce number.
2. All Sales orders that have not been invoiced but are setup to be delivered within the specified time period.
Have been struggling with this one any help would be appreciated.
Thank you

Dear Clifton,
In my opinion, the ABAP query is not the tool that meets your requirements for the following reasons:
1. The tables to consider are too many :
    Query1  VBUK, VBUP, LIPS, VBFA, VBAK, VBAP, VBRK, VBRP
    Query2: VEPVG (Trigger Delivery), VBUK, VBUP, VBAK, VBAP
2. You must also consider the customization of your system, because in some cases, the blocked orders (delivery block) and the unconfirmed orders (confirmed qty = 0 in availability check) not appear as entries in VEPVG table.
3. Join of all these tables using ABAP Query or quick viewer, has low performance, in other words kneel the system.
I think that you should seriously consider the possibility of developing 2 new ABAP programs ($$$) without underestimating the aspect of performance which is crucial in this case.
Thanks.
Kind regards.
Andrea

Similar Messages

  • Order Query in SQ01 using Table Joins in CRM

    Hello Experts,
    I am trying to create a query using table joins in SQ01 in CRM because I need a report that will give me all transactions for a selected Business Partner.  I am unable to display any results when running my query.  I have found other threads which give a list of possible tables to join together, but the fields used in the joins were not described. 
    The tables I have joined in my query are as follows:
    CRMD_ORDERADM_H
    CRMD_ORDER_INDEX
    CRMD_PARTNER
    BUT_000
    I have used SE16 to try to search for additional tables to use for linking the Business Partner with a transaction, but I have been unsuccessful.
    Would anyone please give advice as how to proceed? 
    Reward points are available!
    Thank you in advance,
    David

    David
    The link with be the GUID.
    CRMD_ORDERADM_H = Document Header Table
    CRMD_ORDERADM_I = Document Line item Table
    CRMD_LINK = Lists various ‘link’ GUIDs, to
    access order Information
    The Table CRMD_ORDERADM_H will contain you transactions , once you find the GUID of your sales transaction in the table CRMD_ORDERADM_H.
    You then need to check the table CRMD_LINK.
    In this table you will then find a number in 11 = sales. This refers to the table CRMD_SALES. There are also links to many other tables ie Shipping, pricing, org etc.
    CRMM_BUT_SET0140 - for Sales Group, Sales Office, District
    CRMM_BUT_LNK0141 - for Sales Area data
    Transaction CRMD_BUS2000115 allows you to see all sales transactions for a BP. CRMD_BUS2000126 shows you activities for selected BP.
    Regards
    M

  • Transport Query generated program using SQ01

    Dear All,
    Please let me know how to transport a query generated program using SQ01. I have created a program from SQ01 query creation and assign a tcode to this program. When the program was generated there was no request create so how to make a request to transport this generated program to PRD.
    Thanks in advance.

    Hi,
    for query transport (export/import or download/upload (which I prefer because it can be done between different SAP systems where no transport mechanism exists)) go to SQ02 and tick the button that looks like a car.
    The t-code assignment (and maybe the the T-code is added in an area menu using SE43) needs to be transported seperately (if you use downlaod/upload as this does not create a transport request.
    best regards, Christian

  • Sap query report sq01

    Hello all
    I want to create new sap query in sq01 , the requirement is like this eg:- customer a/b/c , I want to generate the  list of last created sales order for the customers a/b/c here I have given 3 customers but I have to execute for 1500 customers
    If customer A creates 3 sales order in that 3 sales orders I want to pick last sales order on 12.09.2010 / 15.09.2010 /17.09.2010 in that I wnat to pick the last sales order 17.09.2010
    So in query report sq01 how to create, plz provide step by step procedure with this logic
    With regards
    Rahul
    Moderator Message: Search.
    Edited by: kishan P on Sep 17, 2010 4:47 PM

    Hi,
      better search in Google with the keyword 'SAP query tutorials',
    you will get lots of tutorials in the net with step by step approach.

  • In the output list Repeating one line always when generating query by sq01

    Hi,
    I have generated a query in sq01 for list material document for movment type 301 (Transfer posting) using below tables :
    MSEG          Material No. MATNR, Movt. - BWART, Qty. -MENGE
    MKPF          Material doc. field  MBLNR
    MARC          Stock in Transit UMLMC
    some times it is generating the output as i want i.e.
    Material document          material no.      qty.     movt.      stock in transit
    4001               1xx          1     301     0
    4002               2xx          2     301     0
    but some time it is repeating the same line in output ie..
    Material document          material no.      qty.     movt.      stock in transit
    4001               1xx          1     301     0
    4001               1xx          1     301     0
    4001               1xx          1     301     0
    4001               1xx          1     301     0
    Please let me know the reason. is there any control in sq01.
    Thanks

    Yeah it is clear visible that, the same combination might have available in different plants.
    So to avoid the duplicate entries, always select all the primary key fields available in all the tables in the output.
    If not atleast try restricting based on plant in the selection screen or any possible duplicate entreis.
    So add the key fields at Infoset level in SQ02

  • Issue With Query In SQ01

    Hi All,
      We are Using SQ01 query to Generate On report, But the Problem is when iam Trying to Retrive Large amount of data, Few Commercial Contracts are not printing on the query out put, But if i execute to retrive small amount of Data That time iam Getting proper out put with out missing any commercial contract numbers..... Could any body suggest us what could be the problem,
    Thank you very much
    Bhupal

    There is no reason for the query to miss any record but nothing happens by chance and it must be our program which is causing this.
    Just to help me understand, when you debug possibly put a breakpoint on select <main table> and check if the commercial contract which is not appearing in the list is being selected. if it is being selected in select then is it being dropped before Endselect or it is not being selected by select query.
    Regards

  • How to change infoset for a query in SQ01?

    hi,
    I have created a Infoset which I have assigned to the user group.  Now  for creating the query using this infoset, how can i
    proceed?? Its not giving me the option to change  the infoset
    and whenever I clicks on 'Create' it shows me the field group
    of some other infoset. how can i change it to my infoset which I have created.

    Hi,
    In SQ01 first you press shift+F7 then find your user group. then from infoset query tab ,select ur infoset.
    and do the further processing.
    i hope this information will help you.
    regards
    saurabh

  • ABAP query using IHPA--need partner address

    I am using SQ01 to create a query.  I amusing the EQUI and IHPA.  I need the partner address for Partner function = EC.  I have the parner number but not the address number, so I cannot join to table ADRC.

    Hi Priyank,
    First you need to check whether all the required fields are available there in the LDB PNPCE(I guess you are using the same).
    I think old department, old division must not be available there. Then you need to add it in your Infoset and write custom code for these fields. Once you are done with custom coding, you can use this infoset for creating queries.
    Use trnx SQ02 to create queries, either SAP or Infoset.
    Hope it helps. Let me know if you need some more help.
    Raveesh

  • Create query in SQ01

    Hello Abap Experts,
    What are the steps to create and execute query in SQ01. I have to create a query for a selected fields on top of vbak, vbap, vbrk, vbrp tables.
    Any suggestions suggestions / pointers / links are highly appreciated.
    Thanks,
    BWer

    First you need to create the infoset which will tie your tables together. Use SQ02 to do this.   Then in SQ01, when you create your query, you specify the infoset that you want to use.  Then its just a matter of pulling in the fields that you want in the output list and setting the selection fields.  Check out SQ02 to create your infoset, then use SQ03 to assign it to a user group.
    Regards,
    Rich Heilman

  • Crosstab query using pure SQL only

    Hi all,
    Found a lot of threads on crosstab, but none seems to address what I need. I need to perform crosstab query using pure SQL only & the number of columns are dynamic. From a query, I obtained the below table:
    Name Date Amount
    Alex 2005-06-10 1000
    Alex 2005-06-20 1000
    Alex 2005-07-10 1000
    Alex 2005-07-20 1000
    Alex 2005-08-10 1000
    Alex 2005-08-20 1000
    John 2005-06-10 2000
    John 2005-06-20 2000
    John 2005-07-10 2000
    John 2005-07-20 2000
    John 2005-08-10 2000
    John 2005-08-20 2000
    And I need to transform it into:
    Name 06-2005 07-2005 08-2005
    Alex 2000 2000 2000
    John 4000 4000 4000
    Reason for the columns being dynamic is because they'll be a limit on the date ranges to select the data from. I'd have a lower & upper bound date say June-2005 to August-2005, which explains how I got the data from the above table.
    Please advise.
    Thanks!

    Hi,
    I couldn't resist the intellectual challenge of a pure SQL solution for a pivot table with a dynamic number of columns. As Laurent pointed out, a SQL query can only have a fixed number of columns. You can fake a dynamic number of columns, though, by selecting a single column containing data at fixed positions.
    <br>
    <br>
    If it were me, I'd use a PL/SQL solution, but if you must have a pure SQL solution, here is an admittedly gruesome one. It shows the sum of all EMP salaries per department over a date range defined by start and end date parameters (which I've hardcoded for simplicity). Perhaps some of the techniques demonstrated may help you in your situation.
    <br>
    <br>
    set echo off
    set heading on
    set linesize 100
    <br>
    select version from v$instance ;
    <br>
    set heading off
    <br>
    column sort_order noprint
    column sal_sums format a80
    <br>
    select -- header row
      1        as sort_order,
      'DEPTNO' as DEPTNO ,
      sys_connect_by_path
        ( rpad
            ( to_char(month_column),
              10
          ' | '
        ) as sal_sums
    from
        select
          add_months( first_month, level - 1 ) as month_column
        from
          ( select
              date '1981-01-01' as first_month,
              date '1981-03-01' as last_month,
              months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
            from dual
        connect by level < total_months + 1
      ) months
    where
      connect_by_isleaf = 1
    connect by
      month_column = add_months( prior month_column, 1 )
    start with
      month_column = date '1981-01-01'
    union all
    select -- data rows
      2 as sort_order,
      deptno,
      sys_connect_by_path( sum_sal, ' | ' ) sal_sums
    from
      select
        dept_months.deptno,
        dept_months.month_column,
        rpad( to_char( nvl( sum( emp.sal ), 0 ) ), 10 ) sum_sal
      from
          select
            dept.deptno,
            reporting_months.month_column
          from
            dept,
            ( select
                add_months( first_month, level - 1 ) as month_column
              from
                ( select
                    date '1981-01-01' as first_month,
                    date '1981-03-01' as last_month,
                    months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
                  from
                    dual
              connect by level < total_months + 1
            ) reporting_months
        ) dept_months,
        emp
      where
        dept_months.deptno = emp.deptno (+) and
        dept_months.month_column = trunc( emp.hiredate (+), 'MONTH' )
      group by
        dept_months.deptno,
        dept_months.month_column
    ) dept_months_sal
    where
      month_column = date '1981-03-01'
    connect by
      deptno = prior deptno and
      month_column = add_months( prior month_column, 1 )
    start with
      month_column = date '1981-01-01'
    order by
      1, 2
    <br>
    VERSION
    10.1.0.3.0
    <br>
    DEPTNO      | 81-01-01   | 81-02-01   | 81-03-01
    10          | 0          | 0          | 0
    20          | 0          | 0          | 0
    30          | 0          | 2850       | 0
    40          | 0          | 0          | 0
    <br>
    Now, if we substitute '1981-03-01' with '1981-06-01', we see 7 columns instead of 4
    <br>
    DEPTNO      | 81-01-01   | 81-02-01   | 81-03-01   | 81-04-01   | 81-05-01   | 81-06-01
    10          | 0          | 0          | 0          | 0          | 0          | 2450
    20          | 0          | 0          | 0          | 2975       | 0          | 0
    30          | 0          | 2850       | 0          | 0          | 2850       | 0
    40          | 0          | 0          | 0          | 0          | 0          | 0
    <br>To understand the solution, start by running the innermost subquery by itself and then work your way outward.

  • How to convert SQVI to a normal query in SQ01 under client-specific query

    Dear all,
    I would like to know how to perform the following. Can you show me step by step as I don't know how to use SQ01 nor SQVI.
    Convert SQVI to a normal query in SQ01 under client-specific query area
    Thanks
    tuffy
    Thien is right. Invest some time into researching the above mentioned topics before turning to the forums for help.
    Edited by: kishan P on Aug 25, 2010 10:24 AM

    Hi,
    If you don;t know any of them. I think you should take a little time to research or search from Google, SDN wiki,...
    regards,

  • Select Query using Joins

    Hi,
    Please give me the Select query
    I have to fetch   EBELN,BUKRS,LIFNR,BSART,EKORG,EKGRP,WAERS,WKURS  from EKKO and
                          EBELP,LGORT,MATKL ,WERKS,BEDNR,IDNLF,BPRME,NETPR   from EKPO and
                         MENGE, SAKTO,AUFNR,ANLN1,GSBER,PS_PSP_PNR                from EKKN and
                         LPEIN,EINDT,SLFDT,                                                                    from EKET.
    I have to fetch all the data into an single internal table(Mandatory) by a select query using Joins.
    EKKO is having EBELN as primary key
    EKPO is having EBELN,EBELP as primary key
    EKKN is having EBELN,EBELP as primary key
    EKET is having EBELN,EBELP as primary key
    Can anybody Please give me the Select query.
    With Regards
    Ajay

    Hi ,
    I am sending this sample coed for the Inner joins .Hope this will help you:
    Inner joins using 3 tables 
    Try this :-
    SELECT stpostlnr stpoidnrk mastmatnr maramtart stpo~menge 
    INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast 
    JOIN stpo ON stpostlnr = maststlnr 
    JOIN mara ON maramatnr = mastmatnr 
    WHERE stpostlty = 'M' "AND stpoidnrk IN s_matnr 
    AND mast~werks = 1000. 
    Here s_matnr is a select-options on the selection-screen. 
    Or this. 
    Code: 
         Select single VbrkBukrs VbrkKunrg    Vbrk~Vbeln 
                       VbrkFkdat VbrkBstnk_Vf Vbrk~Zterm 
                       Tvzbt~Vtext 
                       VbakVbeln VbakBstdk 
                       LikpVbeln Likplfdat    Likp~Lfuhr 
           into w_vbrk 
           from vbrk 
          inner join       Tvzbt on TvzbtZterm        = VbrkZterm      and 
                                    Tvzbt~Spras        = sy-langu 
          Inner join       Vbfa  as SalesLnk 
                                 on SalesLnk~vbeln     = pu_vbeln        and 
                                    SalesLnk~vbtyp_v   = c_order 
                inner join Vbak  on VbakVbeln           = SalesLnkVbelv
          Inner join       Vbfa  as DeliveryLnk 
                                 on DeliveryLnk~vbeln   = pu_vbeln       and 
                                    DeliveryLnk~vbtyp_v = c_Delivery 
                inner join Likp  on LikpVbeln          = DeliveryLnkVbelv 
          where vbrk~vbeln = pu_Vbeln. 
    This code locates sales, delivery and payment terms info from a billing document number. 
    or
    Here, this one also works fine :
    select zfpcdcadivi zfpcdproforma zfpcdfactura zfpcdaniofactura 
    zfpcdmontousd zfpcdmontoap zfpcdebeln zfpcdinco1 
    zfpcdlifnr lfa1name1 zcdvsstatus zfpcdconint 
    into it_lista 
    from zfpcd inner join zcdvs 
    on zfpcdebeln = zcdvsebeln 
    and zfpcdproforma = zcdvsproforma 
    and zfpcdlifnr = zcdvslifnr 
    inner join lfa1 
    on zfpcdlifnr = lfa1lifnr 
    where zcdvs~status = '04'. 
    Also Here is another solution that just uses inner joins:
    SELECT vbakvbeln vbfaerdat INTO (itab-vbeln, itab-wadat)
    FROM ( vbak INNER JOIN vbap
    ON vbapvbeln = vbakvbeln )
    INNER JOIN vbfa ON vbakvbeln = vbfavbelv
    WHERE vbak~kunnr = m_wm AND
    vbak~vbtyp = 'C' AND
    vbfa~erdat IN s_date AND
    vbap~matnr = 'MZ1807F' AND
    vbfaposnv = vbapposnr AND
    vbfa~vbtyp_n = 'J'.
    <REMOVED BY MODERATOR>
    Cheers,
    Chandra Sekhar.
    Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:20 PM

  • SQVI transfer the query to SQ01

    Dear all
    I have created one query through SQVI,now i want to transfer that query to SQ01 .
    is it possible? if yes plz give me detail .
    thx

    Dear Surendra Patil,
    I dont think there's an option for doing this.
    What's the issue in SQVI? why do you want to transfer that to SQ01?
    Also check this link for creating a Query using SQ02 - Info set creation and SAP query creation in SQ01
    and if required user group creation using SQ03.
    [SAP Query|SAP Query]
    Regards
    Mangalraj.S

  • How to Create RMA Based on Sales order using OE_ORDER_PUB api

    Hi,
    Can any one pls help me how to create a RMA based on the sales order using oe_order_pub.process_order APi.
    Thanks.

    Creating RMA is very similar to creating an Order. You need to make sure you're passing the correct order_type, line_type which'll be setup as 'RETURN' (or 'MIXED') category in transaction type definition.
    For the API to automatically create a reference on your RMA lines to the original Order lines, you need to pass the following
    l_line_tbl (l_line_tbl.COUNT).return_reason_code := 'RETURN'; -- Mandatory for RMA
    l_line_tbl (l_line_tbl.COUNT).reference_line_id := v_ref_line_id; -- Original order line_id
    l_line_tbl (l_line_tbl.COUNT).reference_header_id := v_ref_header_id; -- Original order header_id
    l_line_tbl (l_line_tbl.COUNT).return_context := 'ORDER';
    l_line_tbl (l_line_tbl.COUNT).return_attribute1 := v_ref_header_id; -- Original order header_id
    l_line_tbl (l_line_tbl.COUNT).return_attribute2 := v_ref_line_id; -- Original order line_id
    Once the RMA gets created, query the order and navigate to Lines>Returns tab. You can see the original order number and line number.
    Thanks
    Gopal

  • How to generate mdx query using C#

    I am new to mdx query and i am very curious about mdx query generation using c# so i searched for any demo or open source then i found
    Ranet.olap, which is providing what i need. After taking the dlls i tried to incorporate them in my code. I am pasting my full
    console code which should generate mdx query but it's not doing so, Am i doing something wrong.
    using System;
    using System.Collections.Generic;
    using Microsoft.AnalysisServices.AdomdClient;
    using Ranet.Olap.Core.Managers;
    using Ranet.Olap.Core.Metadata;
    using Ranet.Olap.Core.Types;
    namespace MDX
        class Program
            static void Main(string[] args)
                startWork();
            public static void startWork()
                string connString = "Provider=MSOLAP.3; Data Source=localhost;Initial Catalog=AdventureWorkDW2008R2;Integrated Security=SSPI;";
                CubeDef cubes;
                AdomdConnection conn = new AdomdConnection(connString);
                conn.Open();
                cubes = conn.Cubes.Find("AdventureWorkCube");
                Ranet.Olap.Core.Managers.MdxQueryBuilder mdx = new Ranet.Olap.Core.Managers.MdxQueryBuilder();
                mdx.Cube = cubes.Caption;
                List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listColumn = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
                List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listRow = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
                List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listData = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
                //Column area
                Dimension dmColumn = cubes.Dimensions.Find("Dim Product");
                Microsoft.AnalysisServices.AdomdClient.Hierarchy hColumn = dmColumn.Hierarchies["English Product Name"];
                //hierarchy properties
                List<PropertyInfo> lPropInfo = new List<PropertyInfo>();
                foreach (var prop in hColumn.Properties)
                    PropertyInfo p = new PropertyInfo();
                    p.Name = prop.Name;
                    p.Value = prop.Value;
                    lPropInfo.Add(p);
                Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIColumn = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
                areaIColumn.AreaItemType = AreaItemWrapperType.Hierarchy_AreaItemWrapper;
                areaIColumn.Caption = hColumn.Caption;
                areaIColumn.CustomProperties = lPropInfo;
                listColumn.Add(areaIColumn);
                //Rows Area
                Dimension dmRow = cubes.Dimensions.Find("Due Date");
                Microsoft.AnalysisServices.AdomdClient.Hierarchy hRow = dmRow.Hierarchies["English Month Name"];
                List<PropertyInfo> lRowPropInfo = new List<PropertyInfo>();
                foreach (var prop in hRow.Properties)
                    PropertyInfo p = new PropertyInfo(prop.Name,prop.Value);
                    lRowPropInfo.Add(p);
                Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIRow = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
                areaIRow.AreaItemType = AreaItemWrapperType.Hierarchy_AreaItemWrapper;
                areaIRow.Caption = hRow.Caption;
                areaIRow.CustomProperties = lRowPropInfo;
                listRow.Add(areaIRow);
                //Measure Area or Data Area
                Measure ms = cubes.Measures.Find("Order Quantity");
                Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIData = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
                areaIData.AreaItemType = AreaItemWrapperType.Measure_AreaItemWrapper;
                areaIData.Caption = ms.Caption;
                List<PropertyInfo> lmpropInfo = new List<PropertyInfo>();
                foreach (var prop in ms.Properties)
                    PropertyInfo p = new PropertyInfo(prop.Name, prop.Value);
                    lmpropInfo.Add(p);
                areaIData.CustomProperties = lmpropInfo;
                listData.Add(areaIData);
                mdx.AreaWrappersColumns = listColumn;
                mdx.AreaWrappersRows = listRow;
                mdx.AreaWrappersData = listData;
                string mdxQuery = mdx.GenerateMdxQuery();
                conn.Close();

    Hi mkm1,
    According to your description, you want to use C# code to generate MDX Query. Right?
    In Analysis Servcies, we just need to use "Microsoft.AnalysisServices.AdomdClient.dll" to open connection to SSAS database and retrieve data from cube. Here are some sample code about executing MDX query using C#.
    Dim objConnection As New AdomdConnection("Data Source=localhost;Initial Catalog=Adventure Works DW 2008;")
    Dim objCommand As New AdomdCommand()
    Dim objDatatable As New DataTable
    Dim strCommand As String
    strCommand = "SELECT [Measures].[Internet Sales Amount] ON COLUMNS, "
    strCommand = strCommand & " [Date].[Calendar].[Calendar Year] ON ROWS"
    strCommand = strCommand & " FROM [Adventure Works]"
    objConnection.Open()
    objCommand.Connection = objConnection
    objCommand.CommandText = strCommand
    Dim objDataAdapter As New AdomdDataAdapter(objCommand)
    objDataAdapter.Fill(objDatatable)
    objConnection.Close()
    Since your code is more related to a third party API, we suggest you post your question to Rnet.
    Reference:
    Microsoft.AnalysisServices.AdomdClient Namespace
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

Maybe you are looking for