Sales Analysis Report based on Supplier-wise

Hi Experts,
My client requirement is ,We are into trading so , we want a Sales analysis report based on Supplier-wise. like,
Selection critieria is
1)Supllier name
2)From and To date.
Heading are
Item name     Sales UoM    Jan(quantity)   Feb(quanitity)   mar(quantity)   April(quanitiy).........
here, i need only the sum of the quantity for the items for that particular month based on the date giving in selection criteria.
Regards,
Dwarak
Edited by: Dwarak@SMS on Aug 23, 2010 4:29 PM

Hi experts,
For my clients requirement,
I could able to alter my previous query(find below).
My object is
1)To get sales report based on Manufacturer.
2)To get the TOTAL SALES QUANTITY OF THE MONTHS in the report. I go that in the below query, and only thing is that is have to minus the total Credit note for items to get the ACTUAL TOTAL SALES OF THE MONTHS. so , can anyone help me to alter the query to get me the ACTUAL TOTAL SALES OF THE MONTHS.
the query is
SELECT T0.ITEMCODE,T0.ItemName,T0.OnHand,
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 1 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0) AS 'JAN ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 2 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'FEB ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 3 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'MAR ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 4 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'APR ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 5 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'MAY ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 6 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'JUN ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 7 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'JUL ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 8 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'AUG ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 9 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'SEP ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 10 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'OCT ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 11 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'NOV ',
(SELECT SUM(T1.QUANTITY) FROM INV1 T1 with
(NOLOCK) WHERE MONTH(T1.DOCDATE) = 12 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE) = YEAR(GETDATE())-0)  AS 'DEC '
FROM dbo.OITM T0
LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode WHERE T0.SellItem = 'Y' and T0.[FirmCode] =[%0]
GROUP BY T0.ItemCode,T0.Itemname,T0.OnHand,YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) =
YEAR(GETDATE())-0
ORDER BY T0. ITEMCODE

Similar Messages

  • Sales analysis report and P&L match in SAP b1

    Dear All,
    I am running Sales Analysis report customerwise and item wise where the total of Sales Amount is matching with Revenue amount in profit and loss report for the month April 2011 only.
    But after that these reports are not matchinhg. Please guide in this regard.
    There are some items having valuation method standard, FIFo and moving average.
    Regards
    Aarati Kollur

    Dear Jitin,
    Thanks for quick reply,
    i run the report for item for the April 2011 where total matchs with revenue even there are some service type of A/R Invoices.
    Does sales analysis report consider service type of document in both customer wise and item wise.
    Regards
    Aarati. Kollur

  • Sales analysis report- showing & totaling both Invoices & Credit memos on o

    I have written a Several sales analysis reports based on INV1 tables and RIN1 tables, (Invoice lines and Credit memo lines) for SAP B1 using crystal. I would like the data from both the invoices & the credit memo to list & total on the same report. But have had no luck doing this.
    Is it possible?
    How would I go about doing it?

    Solved my problem, I used the "Show SQL Query" window on my existing reports copied and pasted them to SQL Management Studio as a View, used keyword Union All to join the two queries (Invoices and Credit memos)  and used the view as the data link to create a new report in Crystal Report writer.
    This got me both of the data files into the report detail line and allow for summing.
    Problem solved.
    Thanks for the input.

  • Sales Analysis Report service warehouse wise

    Dear Experts,
    I've configured 4 service warehouses to an item  in SAP B1 8.8 PL:16.  And now I want to see sales analysis report of that particular item against each service warehouse. But from the Sales Analysis or purchase analysis report I can't able to see service warehouse wise sales quantity & amount.
    N.B.-Those items are created as Sales & Expense item only, no inventory.
    Plz help.
    Subrata

    Hi Subrata,
    in this case you need a customized report trough Query or through Crystal Report.
    regards,
    Fidel

  • Branch wise sales analysis report

    Hi
    Client wants to see sales analysis report branch wise. How to do so?
    Thanks

    Hi Molhatra,
    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',
    M.CardName as 'Vendor Name',
    M.NumAtCard as 'Bill No. & Date',
    ISNULL(L.ItemCode,'Service Item') as 'Item Code',
    L.Dscription,
    L.Quantity,
    L.WhsCode,
    L.TaxCode,
    (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]'
    AND
    L.WhsCode='[%2]'
    GROUP BY
    T0.DocNum,T0.DocDate,T2.DocNum,T2.DocDate, M.DocNum,M.DocDate,M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    L.WhsCode,L.TaxCode,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,
    L.WhsCode,L.TaxCode,M.DocEntry,M.[DiscSum],M.WTSum,M.DocTotal
    Regards,
    Madhan.

  • Hide Particular Item Group from Selection Criteria of Sales Analysis Report

    Hello Experts,
    Is this possible to Hide Particular Item Group from Selection Criteria of Sales Analysis Report?
    I have one Item Group as 'Special Items'.
    Now, when I open  Item wise sales analysis report, I want to hide above mentioned group from selection criteria.
    Thanks in advance.
    Best Regards,
    Pankit Sheth

    Hi,
    1. Not possible to put validation for selection criteria windows.
    2. In standard, I don't think it is possible to hide only one item group.
    3. Alternatively don't give authorization to user for running sales reports. If still need create customized query and ask user run every month.
    Thanks & Regards,
    Nagarajan

  • Query to mimic the items tab of the Sales Analysis report.

    Hi there,
    I'm currently looking to create a query that mimics the behaviour of the Sales Analysis report in B1. The items tab of the Sales Analysis report provides all the data I require - the only issue is that I would like to merge this data with some other data regarding current on hand stock quantities etc. and therefore I would like to be able to pull out the query behind the Sales Analysis report.
    I'm assuming this cannot be done and therefore I'm attempting to build a query to replicate the results. The query needs to show Item No, Item Description, Quantity Sold, Sales Amt (in system currency), Gross Profit and Gross Profit % for items within a given period.
    If this can be done relatively easily, can the query then be modified to show all items (including items that haven't sold in the date range) merely with '0' for Quantity Sold, Sales Amt etc. if the item hasn't been sold in the period, and the appropriate figures if each of these columns if the item has sold. I assume some kind of CASE statement can be used to generate this.
    So the query needs to show Item No, Item Description, Current quantity in stock, Quantity Sold, Sales Amt (in system currency), Gross Profit and Gross Profit % for all items within a given date range.
    I hope you can assist me with this problem.
    Thanks
    Grant.

    Hi,
    Thanks Gordon that was exactly what I needed.
    I've been trying to add some additional columns to the query but I'm experiencing some errors and I can't quite tell why.
    Basically, here's the code from another working query I have which I wish to merge into the query you've suggested above:
    SELECT T0.[ItemCode],
    T0.[ItemName],
    T3.[ItmsGrpNam],
    T4.[Name] AS [Sub-Category],
    T5.[Name] AS [Sub-Sub-Category],
    T0.[CardCode] AS [Pref Supplier],
    T6.[FirmName] AS [Brand],
    T0.[U_Range],
    T0.[OnHand],
    CASE WHEN T0.[StockValue] = 0 THEN 0 ELSE T0.[StockValue] END AS [StockValue],
    T1.[Price] AS [PBK GBP Price],
    CASE WHEN T0.[OnHand] = 0 THEN T0.[LastPurPrc] ELSE T0.[StockValue]/T0.[OnHand] END AS [Ave Cost],
    CASE WHEN T0.[OnHand] = 0 THEN T1.[Price]-T0.[LastPurPrc] ELSE CASE WHEN T0.[OnHand] > 0 THEN T1.[Price]-T0.[StockValue]/T0.[OnHand] END END AS [Margin],
    CASE WHEN T0.[OnHand] = 0 AND T0.[LastPurPrc] = 0 THEN 0 ELSE CASE WHEN T0.[OnHand] > 0 AND (T0.[StockValue]/T0.[OnHand]) = 0 THEN 0 ELSE CASE WHEN T0.[OnHand] = 0 THEN (T1.[Price]-T0.[LastPurPrc])/T1.[Price]*100 ELSE CASE WHEN T0.[OnHand] > 0 THEN (T1.[Price]-T0.[StockValue]/T0.[OnHand])/T1.[Price]*100 END END END END AS [Margin %],
    T0.[LastPurPrc]
    FROM [dbo].[OITM]  T0 INNER JOIN [dbo].[ITM1]  T1 ON T0.ItemCode = T1.ItemCode INNER JOIN [dbo].[OITB]  T3 ON T0.ItmsGrpCod = T3.ItmsGrpCod LEFT OUTER JOIN [dbo].[@U_SUBCATEGORY]  T4 ON T0.U_Subcategory = T4.Code LEFT OUTER JOIN [dbo].[@U_SUBSUBCATEGORY]  T5 ON T0.U_SubSubCategory = T5.Code INNER JOIN OMRC T6 ON T0.FirmCode = T6.FirmCode
    WHERE T0.[OnHand] >= 0 and T0.U_Range not in ('E','X')  
    ORDER BY T0.[ItemCode]
    Essentially I just wish to add the fields which are specified in the query above, but not in the query you've already suggested:
    SELECT T0.ItemCode,
    Max(T0.ItemName),
    Max(IsNull(T0.OnHand,0)) 'In Stock',
    SUM(IsNull(T1.Quantity,0)) 'Quantity',
    Sum(IsNull(T1.LineTotal,0)) 'Sales Amt',
    SUM(IsNull(T1.GrssProfit,0)) 'Gross Profit',
    Case WHEN Sum(Isnull(T1.LineTotal,0)) = 0 THEN 0 ELSE
    SUM(IsNUll(T1.GrssProfit,0))/Sum(Isnull(T1.LineTotal,0)) * 100 END 'Gross Profit %'
    FROM dbo.OITM T0
    LEFT JOIN dbo.INV1 T1 ON T1.ItemCode=T0.ItemCode
    LEFT JOIN dbo.OINV T2 ON T2.DocEntry=T1.DocEntry AND T2.DocDate Between [%0] AND [%1]
    GROUP BY T0.ItemCode
    I was hoping it would be fairly straight forward but so far I've had limited success.
    What am I missing here?
    Thanks in advance!

  • Sales Analysis Report for Batch Numbers

    I am currently having an issue with Batch numbers and sales analysis report item wise. If the goods are delivered it does not show the quantity in the report. is there a way to make the quantites show. Open delivery notes show the quantity in the report. Could the reason be that once the delivery note is closed the quantity does not show in the report.????

    Dear Mr Shah,
    If I understood correctly, you are saying that there is no issue in adding the document with the batch but it is not shown in the Sales Analysis report?
    The Sales Analysis report does not show information regarding the quantity because it focuses on the value of the document.
    In order to have an overview on the trasactions related to the batches please use the Batch Number Transaction Report under Inventory - Inventory report.
    Regards,
    Marcella Rivi
    SAP Business One Forums Team

  • Wrong Qty Showing in Sales Analysis Report

    Dear All
    When we run Sales Analysis Report Item Wise by selecting Delivery Note in the selection, then it shows '0' or '-1' in Quantity field. It should show totat quantity delivered of each item.
    Can anyone elaborate this why it happens?
    Thanks and Best Regards
    Nabeel

    Dear Rahul
    I haven't unblocked negative inventory check. But that will not create any affect in Sales Analysis Report.
    Regards
    Nabeel

  • Sales analysis report - in query form?

    Good afternoon. Looking for a bit if help/advice.
    I'm not a complete novice to SAP but what I need is confusing me slightly. I understand the sales analysis report uses many different table as part of its calculations. A company I've recently began working for, who has had SAP for a while, has used sales analysis reports alongside some bespoke reports that are reporting different data.
    Here is their report:
    SELECT T0.[DocNum] AS 'Invoice No.',  CONVERT(VARCHAR(10),T0.[DocDate], 103) AS 'Invoice Date', T0.[NumAtCard] AS 'Cust Order No.', T4.[ItemCode], T5.[U_MSKU] AS 'Manuf SKU', T4.[Dscription] AS 'Description', T6.[ItmsGrpNam] AS 'Item Group', T4.[Quantity], T4.[Price] AS 'Net Unit Price', T4.[LineTotal] AS 'Net/Line Total', T0.[U_ClientNam] AS 'Client Name', T2.[Name] AS 'Division', T1.[Name] AS 'Business Unit', T3.[StreetS] AS 'Ship-to Street', T3.[CityS] AS 'Ship-to City', T3.[ZipCodeS] AS 'Ship-to Postcode'
    FROM OINV T0
    LEFT JOIN [dbo].[@BUSINESSUNITS]  T1 ON T0.U_Bizunits = T1.Code
    LEFT JOIN [dbo].[@DIVISIONS]  T2 ON T0.U_Division = T2.Code
    INNER JOIN INV12 T3 ON T0.DocEntry = T3.DocEntry
    INNER JOIN INV1 T4 ON T0.DocEntry = T4.DocEntry
    INNER JOIN OITM T5 ON T4.ItemCode = T5.ItemCode
    INNER JOIN OITB T6 ON T5.ItmsGrpCod = T6.ItmsGrpCod
    WHERE T0.[DocDate] BETWEEN [%0] AND [%1]  AND T0.[CardCode] = [%2]
    It just doesn't give the same totals as the sales analysis report but I can't reproduce the sales analysis report. How would I go about getting the right figures? Because what we ideally need is to filter the sales analysis results by some of our custom fields:
    [U_ClientNam], [Name] etc.
    How would I go about this? Can I extract parts of the sales analysis report somehow and run it as a query I can manipulate?
    Thanks.

    Hi, not sure if you meant to link to a thread? Based on the query you have given on this thread no totals appear to match however it is much closer than the simple query.
    SELECT Div, BusUnit, isnull([1],0) as Jan, isnull([2],0) as Feb, [3] as Mar, isnull([4],0) as Apr, isnull([5],0) as May, isnull([6],0) as june, isnull([7],0) as July, isnull([8],0) as Aug, isnull([9],0) as Sept, isnull([10],0) as Oct, isnull([11],0) as Nov, isnull([12],0) as Dec
    from
    (SELECT T1.[LineTotal] as Total, month(T0.[DocDate])as month, T8.[Name] AS BusUnit, T9.[Name] AS Div FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN [dbo].[@BUSINESSUNITS]  T8 ON T0.U_Bizunits = T8.Code INNER JOIN [dbo].[@DIVISIONS]  T9 ON T0.U_Division = T9.Code
    WHERE year(T0.[DocDate]) = 2013 and T0.[CardCode] = 'NOR0001'
    union all
    (SELECT -T1.[LineTotal] as Total, month(T0.[DocDate])as month, T8.[Name] AS BusUnit, T9.[Name] AS Div FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN [dbo].[@BUSINESSUNITS]  T8 ON T0.U_Bizunits = T8.Code INNER JOIN [dbo].[@DIVISIONS]  T9 ON T0.U_Division = T9.Code
    WHERE year(T0.[DocDate]) = 2013 and T0.[CardCode] = 'NOR0001')) S
    Pivot
    (sum(S.Total) For Month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
    Is what I've just used. Still well off the mark though.

  • Sales Analysis Report Additional Field for viewing

    Good Day Experts!
    Is it possible for us to display an additional field  to be viewed in Sales Analysis Report?
    I'm talking about a vacant field from BP Master data, and somehow append it into form settings and put it into the report?
    Is there any store procedures that we can look for prior to this matter? Our client need something more on that particular issue.
    Thank you very much

    Hi Elmar,
    It is not possible to add field on SAP sales analysis report , but you can create report based on query with required fields.
    Check http://wiki.sdn.sap.com/wiki/display/B1/D-SLSalesARModuleSQLPostedto+Wiki link for some sales queries , it might help you.
    Thanks,
    Neetu

  • Sales Analysis Report - Items -- blank result

    Hi,
    I'm testing a setup and running the sales analysis report. It works for the Customer version but I get no results when running on Items.
    I'm on SBO 2007A SP01 PL07. There are open and closed invoices for inventory items; no credit memos have been posted. All Item type invoices.
    When I run by Customer, I get the correct data - open and closed invoices for that customer.
    When I run by Items, I get no results. The date range is the same for both reports.
    When I run the purchase analysis on Items, I get data for the same items I am trying to see in the sales analysis.
    Any ideas what could be causing this?
    Thank you,
    Heather

    HI Gordon,
    I left the default settings: 
    - Annual Report, Invoices, Individual Display, No Totals
    - Posting Date:  whole fiscal year
    - Main selection:  left blank/default (group = all, no properties)
    I have double/triple/quadruple-check even the Secondary SElection to make sure there's nothing there.
    I have also run it on Due Date instead of Posting Date, still no results (if run on Items).
    As I mentioned, the selection criteria is what I want but for some reason that one version, Items, does not work. The other 2 tabs work with the same selection.
    Heather

  • Adding Data Field to Sales Analysis Report

    Does anyone know how to add data fields to Sales Analysis Reports, either in PLD or CR?  On Sales Analysis by Customer, I need to add the total quantities for all items sold for the sales included in the report, excluding negative quantities.
    Thank you,
    Avraham

    Hi Avraham.......
    You can create your own Query Report for getting all the desired outputs and it will be easy to show in reports also.....
    Regards,
    Rahul

  • Data Ownership in Sales Analysis Report

    The company has sales employees around the world and the company is not interested that each of them
    can see the others sales, so when an employee runs a sales analysis report they should only see
    their own documents but it not happened despite the data ownership funtion was activated and all the
    options related with the sales analysis excluded forms was filtered by header only.
    According to SAP Support team their comments were:
    "We have reproduced the issue in our testing database. After verification, we noted that this is the current system definition as described in the attached Data_Ownership2004_A.pdf file. In page 11, it mentions that Data Ownership Authorizations apply to sales and purchasing documents, the Open Items List, Sales Opportunities and Sales Opportunities Reports. This is why the header filtration does n ot work in Sales Analysis Report.
    As the requirement is currently not available in the standard software version of SAP Business One, we would like to ask you post your requirement in our SAP Business One Product Development Collabora tion forum."
    Due to the current situation and the disconfort that this can produce, I will appreciate a lot your help.
    Thanks in adavance,
    Manuel Barrero

    Hi Vassilis,
    Sorry, but in my opinion it's correct.
    We also use Drop Ship and like you said in the Stock Posting List we don't have any document and it's perfect. In other way when we sell an item we want and it's true the quantity that B1 is showing.
    We want to see the for a itemcode we sold 100qty qith the value of 1000.
    There's no way to avoid this SAP B1 behaviour.
    Kind regards,
    Augusto

  • Query vs Sales Analysis Report

    I wrote a query that does virtually the same thing as a sales analysis report -- add up all invoice totals and calculate a gross sales number.
    In the sales analysis report ItemXXX has a total sales of $1456.94
    My query ItemXXX has a total sales of $1457.73
    A $.79 discrepancy which I assumed was a result of the fact that my query doesn't include A/R Credit Memos. Only some items have this discrepancy.
    The problem is that if I do an inventory posting list on the item there are no A/R Credit Memos listed. Only A/R Invoices, A/P Invoices, and A/P Goods Receipts.
    What other documents could be affecting this number? Any other things that could be causing this?
    Thanks,
    -Steve

    Hi Nagarajan,
    Im user of Sap Business One, i need the completly query for obtain the Sales Analysis Report
    i have this but in some items dont match
    SELECT  ItemCode,   
            Sum(TotFac) - SUM(TotNC) as  'FacturadoNeto',   
            Sum(GBrutaFac)-SUM(GbrutaNC) as  'GBruta',   
            Round((Sum(GBrutaFac)-SUM(GbrutaNC))/case when  (Sum(TotFac) - SUM(TotNC))= 0 then 1 else (Sum(TotFac) - SUM(TotNC)) end  *100,2) as '% Margen'   
    FROM (   
    SELECT    
    ItemCode = T1.ItemCode, 
    Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode), 
    TotFac = Sum(T1.Linetotal),    
    GBrutaFac = SUM(T1.GrssProfit),   
    TotNc= 0,   
    GbrutaNC = 0   
    FROM OINV T0 (NOLOCK) INNER JOIN INV1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry                                    
    WHERE (T0.[DocDate] >='20140101' AND  T0.[DocDate] <='20141231') 
      and T0.DocType  = 'I' -- solo facturas por articulos   
    Group by  T1.ItemCode  
    Union   
    SELECT    
    ItemCode = T1.ItemCode,   
    Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode), 
    TotFac = 0,   
    GBrutaFac = 0,   
    TotNc= Sum(T1.LineTotal),    
    GbrutaNC = SUM(T1.GrssProfit)   
    FROM ORIN T0 (NOLOCK) INNER JOIN RIN1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry                                    
    WHERE (T0.[DocDate] >='20140101' AND  T0.[DocDate] <='20141231')
      and T0.DocType  = 'I' -- solo NC por articulos   
    Group by T1.ItemCode 
    Union
    SELECT    
    ItemCode = T1.ItemCode,   
    Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode), 
    TotFac = 0,   
    GBrutaFac = 0,   
    TotNc= Sum(T1.LineTotal),    
    GbrutaNC = SUM(T1.GrssProfit)   
    FROM ODPI T0 (NOLOCK) INNER JOIN DPI1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry                                    
    WHERE (T0.[DocDate] >='20140101' AND  T0.[DocDate] <='20141231')     
      and T0.DocType  = 'I' -- solo Fact Anticipos por articulos   
    Group by T1.ItemCode
    ) T   
    Group by  ItemCode, Marca

Maybe you are looking for

  • Split Mapping

    Hi experts, I am performing a split mapping via java mapping in a FILE to FILE scenario. In sender file adapter i am using file content conversion. I have 2 files i want to process via PI. The files sizes are 16kb and 75 kb. When i process 16kb file

  • Sample invoice with excise duty only

    Hello Experts, User is sending free samples to customers. Presently, normal sales invoice is raised and credit note is issued in SAP. We need a separate Sample Invoice with zero value but with Excise Duty Payment. How to achieve this requirement? sug

  • Document Distribution Context

    Hi all, Can anyone give their perspective on the context field used on document distribution recipient lists?  I understand it controls the basic items of Read Receipt, Dist Immediately, and Confirm Output, but I would like to know if anyone is using

  • 1.33 GHz 17" PowerBook battery indicator going up?

    Lately I've noticed that when I use my PowerBook on battery power, the "Time Remaining" indicator in the menubar counts up. I unplugged it just now and turned down the brightness and it went from 1:30 to 2:24, then to 2:09, now it's at 2:15. On my ot

  • How can I fix the language in which my iTunes displays texts and menus?

    When I installed iTunes on my PC, I configured it to be in Spanish. However, each time I click on the Music Store, it suddenly displays the text in French. How can I fix this? I've reconfigured the language several times (In Edit...Preferences...etc.