Can I build a query to show monthly sales by item by business partner?

Hi all
Is it possible to build a query to show monthly sales (quantity not value) by item by business partner?
So the table would look something like this.
               Jan     Feb     Mar     Apr
Item 1      10       4         8         7
Item 2      4         3         5         6
Item 3      4        12        9         3
Item 4      1         0         1         2
Etc...
As you can see, the monthly figure needs to be quantity of the item and not sales value.
Would be grateful for any help.
Many thanks.
Wendy

Hi,
Try this:
declare @code as varchar(15)
set @code = ( select max(ta.cardcode) from OINV ta where ta.cardcode = [%0])
Select [a] as Cardcode, [B] as Cardname, [c] as Item#, [D] as Descr,[1] as Jan,[2] as Feb,[3]as Mar,[4] as April,[5] as May,[6] as June,[7] as July ,[8] as Aug,[9] as Sept,[10] as Oct ,[11]as Nov,[12] as Dec
from(
SELECT T0.[CardCode] as  A , T0.[CardName] as  B, T1.[ItemCode] as C, T1.[Dscription] as D, sum(T1.[Quantity]) as t,month(T0.[DocDate]) as month FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE year( T0.[DocDate]) = 2014 and t0.cardcode = @code GROUP BY T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription],T0.[DocDate] ) S
pivot
(sum(t) for month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
Thanks & Regards,
Nagarajan

Similar Messages

  • Run Query report showing only PO block item, yet to be received.

    Hi,
    Out GR process involves putting the material in (PO block) first using the movement type 903 and t-coden MB0. Next step is GR in unrestricted use using  M Type 905 and t-code MB01 as well.
    I have to enhance a query report so that only those items should show up which have been completed for 903 (PO clock), but not completed for mtype 905. In other words, run a report to list all outstanding itmes in the PO.
    I could run a report to show mtype 903 only but it shows even those items too which are pur in unrestricted us (m typw 905).
    I thanks in advance for help.
    Jaan

    Hi
    903 and 905 are specific to company not SAP standard. Difficult for forum to comment. Why ur company is not using 103 and 105? Normally in standard SAP accounting entries happenes after 105/905. You need to check your quiry. even 103/903 updates EKBE table. You need to pick from there and calculate open PO based on that. In standard ME2M with selection parameter WE101 will do this. You can configure similar to WE101 in below config with your requirement in case if you wish to use standard report
    spro>MM>purchasing>reporting>maintain purchasing list-->selection parameter
    Regards
    Antony

  • Monthly Sale By Item

    Hello,
    We are looking for a Query that will show all of our items and monthly sale by Qty and Amt.  This includes items that do not have sales for that month - those fields would just be left blank.
    So, header would be...
    Item #...Jan Qty...Feb Qty...Mar Qty...etc...Jan Amt...Feb Amt...etc...
    Does anyone know a Query that can do this?
    Sales analysis will just show only items that have sold. 
    This is similar to Queries we have asked for in the past that shows all items. 
    Thanks!
    Mike

    creo que nececitan algo como esto:
    DECLARE @FECHAINI DATE = '2015-01-01';
    DECLARE @FECHAFIN DATE = '2015-02-28';
    DECLARE @sql nvarchar(MAX) = '';
    DECLARE @columns_1 nvarchar(MAX) = '';
    DECLARE @columns_2 nvarchar(MAX) = '';
    SET @columns_1 = STUFF(
    SELECT DISTINCT
        ',Piezas_Mes' + cast( MONTH(DocDate) as varchar) + '_año_' + cast( YEAR(DocDate) as varchar)
    FROM
        (SELECT DocDate FROM OINV where DocDate BETWEEN @FECHAINI AND @FECHAFIN) AS P
    FOR XML PATH('')
    ), 1, 1, '');
    SET @columns_2 = STUFF(
    SELECT DISTINCT
        ',Monto_Mes' + cast( MONTH(DocDate) as varchar)  + '_año_' + cast( YEAR(DocDate) as varchar)
    FROM
        (SELECT DocDate FROM OINV where DocDate BETWEEN @FECHAINI AND @FECHAFIN) AS P
    FOR XML PATH('')
    ), 1, 1, '');
    SET @sql = N'
    select
        Z.PRODUCTO,
        Z.DESCRIPCION,
        ' + @columns_1 + ',' + @columns_2 + N'
    from
            select
            FROM
                    SELECT
                        a.ItemCode AS PRODUCTO,
                        a.Dscription AS DESCRIPCION,
                        ''Piezas_Mes'' + cast( MONTH(b.DocDate) as varchar) + ''_año_'' + cast( YEAR(b.DocDate) as varchar) AS MES,
                        a.Quantity AS CANTIDAD
                    FROM INV1 AS a
                        INNER JOIN OINV AS b
                        ON a.DocEntry=b.DocEntry
                        INNER JOIN OCRD AS c ON b.CardCode = c.CardCode
                    WHERE b.DocType = ''I'' AND b.DocDate BETWEEN ''' + CAST( @FECHAINI AS VARCHAR) + ''' AND ''' + CAST( @FECHAFIN AS VARCHAR) + '''
                UNION ALL
                    SELECT
                        d.ItemCode AS PRODUCTO,
                        d.Dscription AS DESCRIPCION,
                        ''Piezas_Mes'' + cast( MONTH(e.DocDate) as varchar) + ''_año_'' + cast( YEAR(e.DocDate) as varchar) AS MES,
                        (d.Quantity * -1) AS CANTIDAD
                    FROM RIN1 AS d
                        INNER JOIN ORIN AS e
                        ON d.DocEntry = e.DocEntry
                        INNER JOIN OCRD AS f ON e.CardCode = f.CardCode
                    WHERE e.DocType = ''I'' AND e.DocDate BETWEEN ''' + CAST (@FECHAINI AS VARCHAR) + ''' AND ''' + CAST( @FECHAFIN AS VARCHAR) + '''
            ) as TABLADATOS
            pivot
            SUM(TABLADATOS.CANTIDAD) for TABLADATOS.MES IN(' + @columns_1 + N')
            ) as P
    ) as Z
    inner join
            select
            from
                    SELECT
                         a.ItemCode AS PRODUCTO,
                         a.Dscription AS DESCRIPCION,
                         ''Monto_Mes'' + cast( MONTH(b.DocDate) as varchar) + ''_año_'' + cast( YEAR(b.DocDate) as varchar) AS MES,
                         a.LineTotal AS TOTAL
                    FROM INV1 AS a
                        INNER JOIN OINV AS b
                        ON a.DocEntry=b.DocEntry
                        INNER JOIN OCRD AS c ON b.CardCode = c.CardCode
                    WHERE b.DocType = ''I'' AND b.DocDate BETWEEN ''' + CAST( @FECHAINI AS VARCHAR) + ''' AND ''' + CAST( @FECHAFIN AS VARCHAR) + '''
                UNION ALL
                    SELECT
                         d.ItemCode AS PRODUCTO,
                         d.Dscription AS DESCRIPCION,
                         ''Monto_Mes'' + cast( MONTH(e.DocDate) as varchar) + ''_año_'' + cast( YEAR(e.DocDate) as varchar) AS MES,
                         (d.LineTotal * -1) AS TOTAL
                    FROM RIN1 AS d
                        INNER JOIN ORIN AS e
                        ON d.DocEntry = e.DocEntry
                        INNER JOIN OCRD AS f ON e.CardCode = f.CardCode
                    WHERE e.DocType = ''I'' AND e.DocDate BETWEEN ''' + CAST( @FECHAINI AS VARCHAR) + ''' AND ''' + CAST( @FECHAFIN AS VARCHAR) + '''
            ) as TABLADATOS
                pivot
            SUM(TABLADATOS.TOTAL) for TABLADATOS.MES IN (' + @columns_2 + N')
            ) as P
    ) as Y
    on Z.PRODUCTO = Y.PRODUCTO and Z.DESCRIPCION = Y.DESCRIPCION
    order by
    PRODUCTO,
    DESCRIPCION;';
    EXEC sp_executesql @sql;
    SALUDOS ...

  • Where Can I settle an enhancement to delete a sales order item according to the data in BDOC from CRM?

    Hi expert,
    I have an urgent requirement from the client.
    Delete the sales order item totally in ECC.
    I planned to implement this enhancement in ECC. Check the data in BDOC from CRM middleware, according to the user status in the order item,decide whether the item can be deleted.
    My question is,where can I settle this enhancement? The BADI name,user exit?
    Thanks in advance.
    Jerry.

    Hi Jerry,
    It may be delayed. you may found the solution.
    Use BADI CRM_DATAEXCHG_BADI and try the code in MBDOC_FILL or BAPI_FILL method.
    Regards,
    Bala

  • Can not delete a Production Order is the Sales order item is rejected?

    Hello everyone,
    I can not delete the production order as the Sales order line item is rejected.
    Does anybody know if any configuration change is required or any work around?
    Thank you,
    BG

    Hi,
    Could you pl. explain how the production order is created?
    Also did you try by choosing Function in the menu (CO02 transaction) & try to set deletion flag or Technically complete?
    If so did you get any error message ?
    Regards,
    Senthilkumar

  • Function/Procedure help - just want to build simple query and show results

    I'd like a simple "histogram" function - perhaps there is one built-in I'm not aware of. I just want to count discrete values of a column. So I'm constantly writing queries of the form:
    select column_name, count(*)
    from table_name
    group by column_name
    order by column_name;
    and I'm trying to write a function that will allow me to just type:
    execute whatever(column_name, table_name)
    or select whatever(column_name, table_name) from ?
    and get the equivalent results from the query above.
    How do you, or can you, write a procedure to take column/table names as inputs, substitue them into a query, execute the query and just display the results of that query? As I'm trying to figure out how to do this via google search, I keep going down rabbit holes of creating temporary tables/data types/records/refcursors etc. and I can't get any of it to compile. I'm not a DBA or SQL expert, so I'm hoping there's a simple way to accomplish this (without having to store and then process the "results" one row at a time)

    If I understand the requirement correctly, a simple pipelined function will do it:
    Dynamic
    GROUP_VALUE                    NUM_RECS
    10                                    1
    20                                    2
    30                                    6
    40                                    1
    50                                   45
    60                                    5
    70                                    1
    80                                   34
    90                                    3
    100                                   6
    110                                   2
                                          1
    12 rows selected.
      1  SELECT *
      2* FROM TABLE (Gen_Counts.Group_Count ('EMPLOYEES', 'DEPARTMENT_ID'))
    Static
    DEPARTMENT_ID   COUNT(*)
               10          1
               20          2
               30          6
               40          1
               50         45
               60          5
               70          1
               80         34
               90          3
              100          6
              110          2
                           1
    12 rows selected.
      1  SELECT department_id, Count(*)
      2    FROM employees
      3   GROUP BY department_id
      4*  ORDER BY 1The types and package code is:
    CREATE OR REPLACE TYPE group_count_type IS OBJECT
        (group_value VARCHAR2(4000), num_recs NUMBER);
    CREATE OR REPLACE TYPE group_count_list_type IS TABLE OF group_count_type;
    CREATE OR REPLACE PACKAGE Gen_Counts IS
    FUNCTION Group_Count (p_tab_name VARCHAR2, p_col_name VARCHAR2) RETURN group_count_list_type PIPELINED;
    END Gen_Counts;
    CREATE OR REPLACE PACKAGE BODY Gen_Counts IS
    FUNCTION Group_Count (p_tab_name VARCHAR2, p_col_name VARCHAR2) RETURN group_count_list_type PIPELINED IS
      l_cur             SYS_REFCURSOR;
      l_rec_list    group_count_list_type;
      l_cur_str     VARCHAR2(1000) := 'SELECT group_count_type (' || p_col_name || ', Count(*)) FROM ' || p_tab_name ||
        ' GROUP BY ' || p_col_name || ' ORDER BY ' || p_col_name;
    BEGIN
      OPEN l_cur FOR l_cur_str;
      DBMS_Output.Put_Line (l_cur_str);
      LOOP
        FETCH l_cur BULK COLLECT
         INTO l_rec_list LIMIT 1000;
        EXIT WHEN l_rec_list.COUNT = 0;
        FOR i IN 1..l_rec_list.COUNT LOOP
          PIPE ROW (group_count_type (l_rec_list(i).group_value, l_rec_list(i).num_recs));
        END LOOP;
      END LOOP;
    END Group_Count;
    END Gen_Counts;
    /Edited by: BrendanP on 06-Sep-2012 07:18
    Just to be clear - I'm not saying it's a great idea to do that, just that's a way of doing it technically. I'd just use the static way myself.

  • Can't obtain a query result/show more data on LiveCycle Designer ES4 (Windows 7)

    Hi all,
    I'm having some problems with LiveCycle Designer ES4 and a database connection.
    I have successfully connected my fields to a DataConnection but I only can see the first info of the database.
    I want to go through the rest of the data, I've tryied several tutorials (for example commands like xfa.sourceSet.{my Data Connection name}.next), I've tryied several DB types (SQL Server and Access (.mdb and .accdb)), I've tryed in all types of events (click, exit, initialize, and so on) and the result is the same.
    I've tryied something so simple like, create a OLEDB connection in Access, bind the fields (4 textfields), create a button with the code "xfa.sourceSet.{my Data Connection name}.next" (like the tutorial at http://www.youtube.com/watch?v=C56_Cz-aE0c) and nothing.
    Differences between the tutorial and me: The version of Designer (Tutorial ES2, mine ES4).
    Someone know what it could be? Is there some sample where can I see the code used?
    Thanks in advance.

    Thank you Denis,
    the database is intalled on the same server (Solaris-Unix) that boe and the databse is running.
    I have to install the driver when the database is in the same server?
    thanks in advance
    Mauricio

  • Showing Monthly Sales Analysis for Sales Employees (including credit notes)

    Hi Experts,
    I want to show a report for my director so we can accurately decide upon sales targets for each sales employee for 2012.
    The Monthly Report > Invoices by posting date in the Sales Analysis module is not ideal because it does not appear to include credit notes so the totals are incorrect.
    How could I create a query which gave me a total for each month of 2011 for every sales employee which includes invoice minus credit notes.
    Unfortunately my SQL is not great but I started something which might help - this is only for first 2 months of the year.   I presume I would need a select statement for each month if I wanted to have the sales employee name followed by a total for each month.    Maybe this is too intensive a query to run anyway.  
    SELECT T1.[SlpName],
    (select(sum(t2.doctotal)-(t3.doctotal)) where (Month(t2.docdate)=1 and t3.docdate=1) FROM OCRD T0  INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode INNER JOIN OINV T2 ON T0.CardCode = T2.CardCode INNER JOIN ORIN T3 ON T0.CardCode = T3.CardCode)
    (select(sum(t2.doctotal)-(t3.doctotal)) where (Month(t2.docdate)=2 and t3.docdate=1) FROM OCRD T0  INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode INNER JOIN OINV T2 ON T0.CardCode = T2.CardCode INNER JOIN ORIN T3 ON T0.CardCode = T3.CardCode)

    Hi,
    I have moved your posting here because it belongs here.
    You may check this first: Re: Top Customers report
    Thanks,
    Gordon

  • Help With Monthly Sales Query

    Hello All -
    We use the below Query to find monthly sales for each of our stock units.  However, it only provides the current year -- so for 2010, all our 2009 data is gone and the query just shows Jan 2010.
    Is there any way to adjust this Query so that we can select the year we want to see?
    Thanks!
    Mike
    SELECT T0.ITEMCODE,
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 1 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JAN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 2 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'FEB Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 3 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'MAR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 4 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'APR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 5 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'MAY Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 6 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JUN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 7 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JUL Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 8 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'AUG Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 9 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'SEP Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 10 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'OCT Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 11 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'NOV Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 12 AND T1.ITEMCODE
    = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'DEC Amt'
    FROM dbo.OITM T0
    LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode
    WHERE T0.SellItem = 'Y'
    GROUP BY T0.ItemCode,YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) = YEAR(GETDATE())
    ORDER BY T0. ITEMCODE

    /*Hello there!!
    you should try this code*/
    SELECT T0.ITEMCODE, (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 1
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'JAN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 2
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'FEB Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 3
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'MAR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 4
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'APR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 5
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'MAY Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 6
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'JUN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 7
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'JUL Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 8
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'AUG Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 9
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'SEP Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 10
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'OCT Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 11
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'NOV Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 12
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1)) AS 'DEC Amt'
    FROM dbo.OITM T0 LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode WHERE T0.SellItem = 'Y'
    GROUP BY T0.ItemCode,YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) = (YEAR(GETDATE())-1) ORDER BY T0. ITEMCODE
    thou i suggest that its more practical for you to use a variable to enter the year, for example like this.
    declare @year as char(4)
    set @year = '2009'
    SELECT T0.ITEMCODE, (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 1
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'JAN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 2
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'FEB Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 3
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'MAR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 4
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'APR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 5
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'MAY Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 6
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'JUN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 7
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'JUL Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 8
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'AUG Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 9
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'SEP Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 10
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'OCT Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 11
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'NOV Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with (NOLOCK) WHERE MONTH(T1.DOCDATE) = 12
    AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = @year) AS 'DEC Amt'
    FROM dbo.OITM T0 LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode WHERE T0.SellItem = 'Y'
    GROUP BY T0.ItemCode,YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) = @year ORDER BY T0. ITEMCODE

  • Employee business partner ID showing up in "Service Team" column of query

    Hey everyone,
    We have a strange problem appearing in our Solution Manager. In workcenter, when we build a query that shows the "Service Team" column we find that while the "Support Team" shows up for most of the results (which is correct) a few of the results displays employee business partner IDs instead (despite the message having Support Teams assigned to them).
    Through investigation we've found out that all of these business partners are assigned to roles in the message (reported by, message processor, functional analyst etc etc.) Interesting to note that the business partner ID showing up in the "Service Team" column is always the LAST business partner record on the "Business Partner" tab of the message.
    So if the business partner tab looks like this:
    Partner Function       Partners
    Reported by              A1
    Support Team           B1
    Message Processor C1
    Functional Analyst    D1
    D1 would show up in the Service Team column despite there being a Support Team assigned. If a new partner is assigned and a new record appears below the Functional Analyst D1 record, that new partner's ID appears in the "Service Team" column instead.
    Does anyone have an idea of why this could be happening to these few recordcs and how to ensure the "Support Team" is the value showing up in the "Service Team" column?
    Thanks,
    Laurence

    Hi,
    You can go to the infoobject setting RSD1 and check the help f4 attributes and select only those which you want. this afect for infoobject 0COSTCENTER not for any specific query.
    regards
    Gopal

  • Creating Query to show items from open sales orders with a/p invoice

    Hi experts,
    I am trying to create a query that will show what items/quantities are still in open sales orders that can now be filled by an incoming shipment of goods, processed through the a/p invoice.
    This needs to be done using subqueries, which I have no experience with.  I am trying to do this using the ORDR and RDR1 tables to show the open items from the sales orders and the OPOR and POR1 tables to show items just received in to inventory.  I would like the query to show exactly the open item's, their quantities, the posting date from the sales order and the customer name that can now be filled from the new shipment through the a/p invoice.
    I appreciate the assistance,
    Hayden (on behalf of Todd)

    Hello,
    try this
    SELECT T0.[DocDate], T1.[ItemCode], T1.[Dscription],( T1.[Quantity] - T1.[DelivrdQty]) As "Open Qty" FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDueDate]  <= [%0]And ( T1.[Quantity] - T1.[DelivrdQty]) != 0
    Try this query in query manager.
    Thanks
    Manvendra Singh Niranjan
    Edited by: Manvendra Singh Niranjan on Jul 13, 2011 6:27 AM

  • SQVI or SQ01 - Building a Query

    I am looking to build a query in SQ01 or SQVI to list the following:
    1. List of all the customer numbers
    2. List of all agreement numbers
    3. List of customer with associated agreement
    4. List of all addresses.
    WHile the Query 1 is for Business partner... which is the table i can use.
    Is it BUT000 or i need to join more than one table.
    Query 2 - refers to Total commitment in SAP. I don't know the table details.
    Query 3 - Refers to the combination of SAP Business Partner data and Total commitment data.
    Query 4 -  Seems to be the address in Business partner. Which is the appropriate table.
    help me in tbuilding this query.

    Hi,
    Is requirement part of the FSCD module, if you let me know I can help you on that.  Please more specific with your requirement.
    I am currently working on FSCD module as an ABAP consultant.
    Thanks,
    Mahesh.

  • How can i show sales order details for specific partner in view

    Hi All,
              My Requirement is that I want to display the sales order id,sataus,amount in sales order assignment block  in Customer FACTSHEET. I created a new componnet and new view for Sales Order View  using BTQRSlsOrd BOL Entity in ONEORDER I want to diplay sales order id ,status ,amount for specifc business partner which i selected from Account Tab in WEB UI.How can i bind my ( view or context node or context ) so that it shows details of sales order for specific business partner.
    Thanks in Advance.......
    Vishwas Sahu

    Hi Vishwas
    I hope the following link helps you in setting up the sales order in account fact sheet:
    Add Sales Order to Account Factsheet
    If you are on CRM 2007 SP03 then you might need the following note:
    Note 1165224 - Search result is not showing up in IC account factsheet.
    Regards
    Rupesh

  • How to build a query to get the item properties is tick or not?

    hello everybody. i'm 1 of the sap b1 user. i face a problem in build a query to check one of the item properties is tick or not? pls help...

    Hi Grace,
    your query could look like this:
    Select itemcode from oitm where qrygroup1= "Y"
    qrygroup1 is item property 1, qrygroup2 is item property 2 etc.
    Regards
    Ad

  • A query to get all sales processed in 2007 ?

    Hi All,
    I got a requirement from user saying
    " We have situations where "new" sales get processed against already existing or "old" sales orders. I need a query which shows all sales processed in year 2007 by sales order or whatever other identifier that is used"
    This is not making any sense to me. Can anyone help me with this ? Is there something to do with ship date or anything? Please let me know!!
    Thanks in advance
    Prathibha

    Hi Prathibha,
    The only idea that came to my mind is the following: your customer sends order in a regular interval (weekly, monthly…) under a number that represents an agreement between you and your customer.
    Under this scenario, you have one order created in the previous period from customer A that was partially shipped. In the current period, customer A sends a new order to you, but the quantity sent by your customer includes the balance. So, if new_quantity greater than old order balance, you will need to add an order with the balance.
    Still under this scenario, the report could all orders in OM posted/shipped in 2007 under this agreement.
    Just an idea, hope it helps,
    Ketter Ohnes

Maybe you are looking for