Modifying Detailed Sales Report Query

Hello All --
Can we adjust the Query below so that the current Company, Address, City, State and Zip have the letters BT in front (for Bill To)?
Then, can we add new columns of the Company, Address, City, State and Zip for the Ship To with ST in the front of the names?
Thanks!!
Mike

Mike,
It seems BT and the State are in two seperate lines on the Query.  Please check the following
SELECT 'Invoice' "Invoice/AR CM", T0.CardCode
"BP Code", T0.CardName 'Company', T0.Address 'BT Address', T2.City 'BT City', T2.State1 'BT State', T2.ZipCode 'BT Zip', T0.Address2 'ST Address', T3.Name, T0.DocDate,T0.DocNum, T0.DocTotal 'Gross Amt', T0.TotalExpns 'Freight/Svc Charge',
(T0.DocTotal - T0.VatSum-T0.TotalExpns) 'Net Order', T1.SlpName 'Sales Rep', T1.Commission '% Commision',
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(T1.Commission/100)) 'Commission Amount', T4.GroupName 'Group'
FROM dbo.OINV T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND
(T0.DocDate BETWEEN '[%2]' AND '[%3]')
UNION ALL
SELECT 'Credit Memo' "Credit", T0.CardCode, T0.CardName,
T0.Address, T2.City, T2.State1, T2.ZipCode, T0.Address2,
T3.Name, T0.DocDate,T0.DocNum,
-T0.DocTotal, -T0.TotalExpns,
-(T0.DocTotal - T0.VatSum-T0.TotalExpns),
T1.SlpName,
T1.Commission,
((T0.DocTotal - T0.VatSum-T0.TotalExpns)*(-T1.Commission/100)),
T4.GroupName 'Group'
FROM dbo.ORIN T0 LEFT JOIN dbo.OSLP T1 ON T0.SlpCode = T1.SlpCode
LEFT JOIN dbo.OCRD T2 ON T0.CardCode = T2.CardCode
LEFT JOIN dbo.OCPR T3 ON T0.CntctCode = T3.CntctCode
LEFT JOIN dbo.OCRG T4 ON T4.GroupCode = T2.GroupCode
WHERE (T1.SlpName BETWEEN '[%0]' and '[%1]') AND
(T0.DocDate BETWEEN '[%2]' AND '[%3]')

Similar Messages

  • Sales Report query by Sales Employee

    Hi All
    I need your help I have a problem with a custom report I created based on a query.
    Here is the query.
    SELECT T4.[SlpName], T3.[ItmsGrpNam], sum(T0.[LineTotal]) AS 'Line Total' FROM [dbo].[INV1]  T0 INNER JOIN [dbo].[OINV]  T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod INNER JOIN OSLP T4 ON T0.SlpCode = T4.SlpCode WHERE T1.[DocDate] >=[%0] AND  T1.[DocDate] <=[%1] GROUP BY T4.[SlpName], T3.[ItmsGrpNam] ORDER BY T4.[SlpName], T3.[ItmsGrpNam]
    This report is must show the same info. as the sales analysis report based on sales employee and gropued by item group.
    Hope this is clear thanks
    Bongani

    create crystal report using query
    SELECT  T1.DocDate, T4.SlpName, T3.ItmsGrpNam, sum(T0.LineTotal) AS 'Line Total' FROM dbo.INV1 T0 INNER JOIN dbo.OINV T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod INNER JOIN OSLP T4 ON T0.SlpCode = T4.SlpCode  GROUP BY T4.SlpName, T3.ItmsGrpNam ORDER BY T4.SlpName, T3.ItmsGrpNam
    and pass doc date as parameter in crystal report.
    you cant pass parameters directly in query to use in crystal report.
    you you want to pass parameter s in query create the stored procedue in sql.
    other wise pass the parameters in crystal report.
    hope this will help you
    regards,
    neetu

  • Sales report query - some help?

    Hi,
    I'm trying to create a report that goes all trough the sales documents by line showing the status.
    The problem is that the JOIN is multiplying the rows of the documents.
    Maybe someone did something similar in the past?
    SELECT distinct T0.[U_ProjectCoTi] , T0.[U_ProjectName], T0.[CardCode], T0.[CardName],
    T0.[DocNum] as 'SO Num.', (T0.DocTotal - T0.VatSum) as 'SO Net Amount',
    T0.[DocDate] as 'SO Date',
    Case when (T1.[LineStatus] = 'O') then 'Open'
         when (T1.[LineStatus]= 'C' and T1.[Trgetentry] = ' ') then 'Cancelled'
         when (T1.[LineStatus] = 'C' and T1.[Trgetentry] != ' ') then 'Closed'
    End as 'SO Line Status',
    T3.[DocNum] as 'Del. Num.', T2.Linetotal as 'Del. Row Amount',
    T3.[DocDate] as 'Del Date',
    Case when (T2.[LineStatus] = 'O') then 'Open'
         when (T2.[LineStatus]= 'C' and T2.[Trgetentry] = ' ') then 'Cancelled'
         when (T2.[LineStatus] = 'C' and T2.[Trgetentry] != ' ') then 'Closed'
    End as 'Del. Line Status',
    T5.[docnum] as 'Inv. Num.', 
    T4.Linetotal as 'Inv. Row Amount', T5.[DocDate] as 'Inv Date',
    Case when (T4.[LineStatus] = 'O' and T5.DocStatus = 'O') then 'Open'
         when (T4.[LineStatus]= 'O' and T5.DocStatus = 'C') then 'Closed'
         when (T4.[LineStatus] = 'C' and T5.DocStatus = 'C') then 'Closed'
    End as 'AR Inv. Line Status'
    FROM ORDR T0 Left join rdr1 t1 on t0.docentry = t1.docentry
         Left JOIN DLN1 T2 on t1.trgetentry = t2.docentry
         Left join odln t3 on t2.docentry = t3.docentry
         left join inv1 t4 on t2.trgetentry = t4.docentry
         left join oinv t5 on t5.docentry = t4.docentry

    Hi Cynthia,
    I am not 100% sure that I get what you are trying to do, but could it not be an idea to use Union in the query and create separate queries for each document instead of joining Orders, Deliveries and Invoices.
    Something like:
    Select 'Sales Order', docnum, docstatus from ordr
    union
    Select 'Delivery', docnum, docstatus from odln
    union
    Select 'AR Invoice', docnum docstatus from oinv
    Obviously this is just a suggestion on the structure, then in each query you need to do the join with the lines etc etc.
    Hope it helps,
    Jesper

  • SALES REPORT (Credit memos Subtracted)

    Hi all,
    I would like to come up with a detailed Sales Reports that shows the Quantity and Value of items sold per day (AR Invoices) excluding the credit memos. I later want to use the same query in crystal reports. I came up with the below query; the select statements are executing individually but using 'UNION ALL' I am getting a 'Conversion' error.
    SELECT T0.[CardCode]Code, T4.[SuppCatNum]cat, T4.[FrgnName]frn, T1.[Quantity]InvQ, T0.[DocTotal]InvT,0 MemoQ,0 MemoT FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry full outer JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode full outer JOIN OUSR T3 ON T0.UserSign = T3.USERID full outer JOIN OITM T4 ON T1.ItemCode = T4.ItemCode WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01')  AND T0.DocDate=[%0]
    union all 
    SELECT  0 Code, 0 cat, 0 frn, 0 InvQ,0 InvT, T1.[Quantity] MemoQ, T0.[DocTotal] MemoT FROM ORIN T0  INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry full outer JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode full outer JOIN OUSR T3 ON T0.UserSign = T3.USERID full outer JOIN OITM T4 ON T1.ItemCode = T4.ItemCode WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0]
    kindly assist refine this query or come up with a better one altogether. Thank you.

    Hi,
    Try:
    SELECT T0.CardCode Code, T4.SuppCatNum cat, T4.FrgnName frn, T1.Quantity InvQ, T1.LineTotal InvT,0 MemoQ,0 MemoT
    FROM OINV T0
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN OITM T4 ON T1.ItemCode = T4.ItemCode
    WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0\]
    union all 
    SELECT  '', '', '', 0,0, T1.Quantity, T1.lineTotal
    FROM ORIN T0
    INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
    LEFT JOIN OITM T4 ON T1.ItemCode = T4.ItemCode
    WHERE (T1.WhsCode='MLO01' or T1.WhsCode='ARG01') AND T0.DocDate=[%0\]
    Thanks,
    Gordon

  • Sales Report for US Sales and Use tax

    Hi,
    I'm looking for t-code to extract detailed sales report having Gross sales, Exempt sales , Ship to state, Ship to County\ City,  Sales Tax collected. If I'm getting this report i can verify what my sales tax software is updating.
    When i extract  tcode - ZINVLIS i don't get much detail.
    Please help me in extracting complete sales detail which can be used for sales and use tax verification process and audit purpose.
    Thanks,
    Karthik

    Hi Karthik,
    There is no standard report available as per my knowledge.You may develop Z report to achive your requirment. Check some LIS report can give data (MC01 is transaction where you can check all type of key figure reports)
    Regards
    Mani Kumar

  • Sales report issue while saving the query

    Hi,
    I am working on Sales reports and that i came across a senario and facing a problem, can anyone help me over this
    Senario:
    I created a structure in Rows and added few keyfigures to the New structure which is in Rows.
    After that i added 2 charcteristics.
    Now the problem is that when i save the query i am getting the Keyfigure structure first and then characteristics
    But, i need the 2 charcteristics first and then i need the Keyfigures
    I changed the query as i want it like i placed 2 charcteristics first and then the keyfigure (structure) and the query saved sucessfully.
    The problem is that when i open the query again i found that the Keyfigure (structure) first and then the 2 charcteristics
    I did it all my possible ways still the problem perstists
    Edited by: MAHESH MUMAR on Oct 6, 2008 2:22 PM
    Edited by: MAHESH MUMAR on Oct 6, 2008 2:32 PM

    mahesh,,,
    can u xplain more what xactly is ur need.
    "After that i added 2 charcteristics."
    so do u want chars & keyfig in Rows only.
    this way i dont think u will have report output ..
    Take simple e.g. below:
    $----
    Quantity
    Material
    Channel112--
    1
    Channel223--
    34
    Is this how u want ur report to display?
    that means u will need material and channel in rows and keyfigures ($ & quantity ) in Columns.
    if this is not what u seek what else is your rek.
    sometimes such display helps to understand.
    Yes u can add chars in Rows and then add structure of keyfigure.
    Yes you can change the sequence of display in Rows among different structure.
    But do u still have something in columns.
    It is intersection of Rows & Columns that displays result data set...
    let us know in more detailed e.g.

  • Master Detail Report using Report Query

    I am using APEX Report Query component to try and create a mater/detail report with BI plug-in. The Report Queries doesn't give you mush flexibility as each query is independent of the other. I'm trying to see if I need to create 2 queries or 1 AND what option would let me create a master detail report like so in BI Desktop:
    Employee: Bob ID:100 Dept: HR
    Jobs
    Job 1
    Job 2
    Job 3
    Employee: Tom ID:200 Dept: ACCt
    Jobs
    Job 1
    Job 2
    Job 3
    Option1.
    I could combine the Employee Job info with the Employee info, but that would report the Employee info for every Employee Job. I didn't think that was good.
    <Rowset1_Row>
    <EMPID>
    <NAME>
    <DEPT>
    <JOB>
    </Rowset1_Row>
    Option 2.
    I could create 2 queries. The 1st getting all of the Empoyee info. The 2nd getting all of the Employee jobs.
    <Rowset1_Row>
    <EMPID>
    <NAME>
    <DEPT>
    <JOB>
    </Rowset1_Row>
    <Rowset2_Row>
    <EMPID>
    <JOB>
    </Rowset2_Row>
    <Rowset2_Row>
    <EMPID>
    <JOB>
    </Rowset2_Row>
    Any advice?
    Edited by: bobmagan on Jun 1, 2009 5:29 AM

    Can you check for the settings please.
    Thanks and Regards
    Riyas

  • Query for Weekly Sales Report

    Dear Experts,
    I have developed the query for weekly sales report for the alert management to send out the report on every Monday as follow :
    SELECT T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T1.[LineTotal] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.[DocDate] between GetDate()-8 and GetDate()-1
    The weekly report received on every Monday through email is without column total for the "Line Total".
    Can the Sum of column "Line Total" to be included in the query ?
    Thus, the auto send report on every Monday by alert management will display the total.
    Thanks in advance for all your kind assistance.
    Regards,
    Clara

    Ok you want it at the bottom.......
    then you must must try this if you are running query generator....
    Else a good option is Crystal Report.
    You need to only add Group Sum.......
    SELECT T0.CardCode, T0.CardName, T0.DocDate, T1.ItemCode, T1.Dscription, T1.Quantity, T1.LineTotal FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
    Union All
    Select '','',Null, '','Total',Null, Sum(T1.LineTotal) FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode WHERE T0.DocDate between GetDate()-8 and GetDate()-1
    Regards,
    Rahul

  • Territory Wise Sales Report

    I want to generate territory wise sales report using sql server reporting services from sap b1.  How can I define the hierarchy where my state will be the top group, the territories will be the sub groups and the executive name and sales value will be the details.  How can I transform the parent, child relation into a group, sub group option in a report.  Kindly provide sample sql query for the same.
    Thanks in advance.

    Dear Gordon,
    As advised by you i have created territory hierarchy in the territory setup, where zone is the first level, state is the second level and territory (district) is the third level and in the BP master territory field this third level is picked. I am finding it difficult to develop hierarchy wise report where the report when run should show the zone wise net sales summary (net in the sense, minus all the sales returns and credit notes, etc) and when drilled should show the state wise total and in the last level the territory wise sales and if possible one more drill where the BP under that territory with sales amount will be shown.  Request you to kindly help me with a base query wherein i can modify the same to develop many variation of the same report.  Thanks in advance.

  • How set authorizations for sales reports and other reports in SAPB1

    Hi, I'm currently working in SAP Business One Version 8.82
    The issue I'm facing is that I want to set it up so that certain users cannot see other users' sales information.  I know that I can turn on or off the Sales Analysis Report for various users for instance, but what I really want specifically is this.  Suppose we have 3 different teams: Team A consists of (Angie, Angela, and Anita the manager), Team B consists of (Bob, Barbara, and Ben the manager), Team C consists of (Cat, Charlie, and Courtney the manager).  I would like to make it so that everyone can view the individual sales order documents of everyone else (in case a customer calls and needs information, but the salesperson who created that document isn't there); however, Angie should only see her own orders when she does a Sales Analysis while Anita, the manager of Team A, should see the the orders of Angie, Angela, and herself of course.
    To summarize, I'd like to see the following
    1.  Each salesperson can lookup and view any sales order.
    2.  Each salesperson can run an sales report to view all his/her own open sales orders.
    3.  Each manager can run a sales report on his/her subordinates, but not on the other managers or their subordinates.
    4.  The boss or other people working in corporate are able to run a report on all open sales orders.
    What's the best way to approach this?  Is it best if I create my own report?  I haven't created any reports from scratch yet, so I'm not sure exactly how that works.  I'd like to be able to group the salespeople up by location if possible.  The sales analysis report doesn't really do that, but it is useful.  I just don't want everyone to be able to see the numbers on their peers.
    Thank you I appreciate any help or advice.

    Hi,
    1.  Each salesperson can lookup and view any sales order.
    Answer:
    Create own report by using query and save under query manager and the assign for all group. So that all sales person can run this query  and can get sales order detail.
    2.  Each salesperson can run an sales report to view all his/her own open sales orders.
    Answer:
    Create individual query ( add condition in where clause slpname = 'XXX') for each sales person and save it under query manager and assign to particular user group
    3.  Each manager can run a sales report on his/her subordinates, but not on the other managers or their subordinates.
    Answer:
    Create query for only particular team (  condition is slpname = XXX OR YYY OR ZZZ) and save under query manager. Make schedule report on this and send it to only particular manger
    Same way create for another manager and schedule report.
    4.  The boss or other people working in corporate are able to run a report on all open sales orders
    Answer.
    Create query for all sales person and schedule report to big boss.
    Hope you can get an idea.
    Let me know if you need sales report ( advice required field)
    Thanks & Regards,
    Nagarajan

  • Local currency showing higher value in BW compared to ERP - Sales report

    Hi,
    My sales report is showing higher value in BW report compared to ERP e.g
    the report is showing 567,01 and in ERP it is showing 566,94.
    is there a way I can resolve this in the query.
    thanks

    Hi  Bhat,
    there may be lot many factors like
    1)comparision between the Two i.e ERP and BIW.Are the Factors same.
    2)Have u  Deltas captured properly.
    3)have u missed any deltas any day.
    4)Any order that has been modified .
    5)hope u have considered ONE days Lag between BIW and ERP.
    6)To what is ur 0Recordmode mapped to.
    7)Is it because of Rounding OFF Values.
    Rgds
    SVU

  • Urgent: sales report

    Hi All,
    I want to devlop a sales report,
    please can any one explain me how to write select and go ahead
    the requiremnet is like this
    Based on selection criteria
    Sales organisation (VBRK-VKORG),
    Distribution channel (VBRK-VTWEG),
    Division (VBRK_SPART),
    Billing date(VBRK-ERDAT),
    Customer (VBRK-KUNAG),
    plant (VBRP-WERKS), and
    Material Group1(VBRP-MVGR1).
    Check if VBRK-FKSTO # X, VBRK-RFBSK = C, VBRK-FKART #S1 and S2, take all VBRK-VBELNs (Print in Invoice number ).
    VBRK-ERDAT(Print in Invoice Date).
    Pass VBRK-VBELN to VBRP-VBELN and check for every VBRP-MVGR1 pass VBRP-POSNR to KONV-KPOSN and
    For KONV-KSCHL =’ZPTS” sum all KONV-KWERT and display(PTS value).
    For KONV-KSCHL =”YNRV” sum all KONV-KWERT and display(NRV Value).
    thanks in advacne
    points will be rewarded if it is use full
    jay

    Hi,
    Refer this code.
    REPORT  z_daily_sales
            NO STANDARD PAGE HEADING
            MESSAGE-ID sabapdocu.
                          TABLES                                         *
    TABLES : vbak,                              "Sales Document: Header Data
             tfacs,                             "Factory calendar (display)
             vbrk,                              "Billing: Header Data
             vbrp,                              "Billing: Item Data
             vbpa,                              "Sales Document: Partner
             lips,                              "SD doc: Delivery: Item data
             mkpf,                              "Header: Material Document
             mseg,                              "Document Segment: Material
             konv.                              "Conditions (Trans Data)
                          CONSTANTS                                      *
    CONSTANTS : c_top_of_page(15) TYPE c VALUE 'SUB_TOP_OF_PAGE'.
                          TYPE-POOL                                      *
    TYPE-POOLS : slis. "Global types for generic cunning building blocks
                          VARIABLES                                      *
    DATA : v_repid    TYPE sy-repid,             "Report ID
           v_month(2) TYPE c,                    "Variable for Month
           v_year(4)  TYPE c,                    "Variable for year
           v_days(31) TYPE c,                    "Variable for days
           v_ship(10) TYPE c VALUE 0,            "Variable for total days
           v_jan(31)  TYPE c,                    "Variable for month
           v_count(2) TYPE c VALUE 0,            "Variable for count
           v_wdays(2) TYPE c VALUE 0,            "Variable for working days
           v_ndays(2) TYPE c VALUE 0,            "Variable for non work days
           v_tdays(2) TYPE c VALUE 0,            "Variable for total days
           v_oltot    TYPE i VALUE 0,            "Variable for order total
           v_sotot    TYPE i VALUE 0,            "Variable for special order
           v_corebus  TYPE kzwi2 VALUE 0,        "Variable for core bus
           v_onbulk   TYPE kzwi2 VALUE 0,        "Variable for bulk orders
           v_premier  TYPE kzwi2 VALUE 0,        "Variable for premier prog
           v_shipit   TYPE kzwi2 VALUE 0,        "Variable for ship it prog
           v_onpromo  TYPE kzwi2 VALUE 0,        "Variable for on promo
           v_netrev   TYPE kzwi2 VALUE 0,        "Variable for net rev
           v_storev   TYPE kzwi2 VALUE 0,        "Variable for store rev
           v_connet   TYPE kzwi2 VALUE 0,        "Variable for consignment
           v_sporder  TYPE kzwi2 VALUE 0,        "Variable for special order
           v_stdvd    TYPE kzwi2 VALUE 0,        "Variable for dvd
           v_totrev   TYPE kzwi2 VALUE 0,        "Variable for total rev
           v_totbud   TYPE kzwi2 VALUE 0,        "Variable for total budget
           v_ordsize  TYPE kzwi2 VALUE 0.        "Variable for order size
                          TYPES                                          *
    *--Structure for VBRP Table
    TYPES : BEGIN OF t_vbrp,
            vbeln  TYPE vbeln,                  "Billing document
            fkdat  TYPE fkdat,                  "Billing date
            fktyp  TYPE fktyp,                  "Billing category
            fkart  TYPE fkart,                  "Billing type
            vtweg  TYPE vtweg,                  "Distribution channel
            knumv  TYPE knumv,                  "Number of doc condition
            posnr  TYPE posnr,                  "Billing item
            matnr  TYPE matnr,                  "Material Number
            werks  TYPE werks_d,                "Plant
            vgbel  TYPE xblnr,                  "Referance
            vgbel1 TYPE vgbel,                  "Doc no reference document
            kzwi2  TYPE kzwi2,                  "Subtotal 2
            wavwr  TYPE wavwr,                  "Cost in document currency
            kunnr  TYPE kunnr,                  "Customer
            END OF t_vbrp,
    *--Structure for MKPF Table
            BEGIN OF t_mkpf,
            fkdat TYPE fkdat,                   "Billing date
            mblnr TYPE mblnr,                   "Number of material document
            mjahr TYPE mjahr,                   "Material doc. year
            xblnr TYPE xblnr,                   "Referance
            kunnr  TYPE kunnr,                  "Customer
            END OF t_mkpf,
    *--Structure for MSEG Table
            BEGIN OF t_mseg,
            fkdat TYPE fkdat,                   "Billing date
            mblnr TYPE mblnr,                   "Number of material document
            mjahr TYPE mjahr,                   "Material doc. year
            bwart TYPE bwart,                   "Movement type
            sobkz TYPE sobkz,                   "Special Stock indicator
            dmbtr TYPE dmbtr,                   "Amount in local currency
            kunnr TYPE kunnr,                   "Customer
            matnr TYPE matnr,                   "Material Number
            werks TYPE werks_d,                 "Plant
            END OF t_mseg,
    *--Structure for LIPS Table
            BEGIN OF t_lips,
            vbeln TYPE vbeln_vl,                "Delivery
            fkdat TYPE fkdat,                   "Billing date
            knumv TYPE knumv,                   "Number of doc condition
            matnr TYPE matnr,                   "Material Number
            werks TYPE werks_d,                 "Plant
            bwart TYPE bwart,                   "Movement type
            kzwi2 TYPE kzwi2,                   "Subtotal 2
            lfimg TYPE lfimg,                   "Quantity
            END OF t_lips,
    *--Structure for VBAK Table
            BEGIN OF t_vbak,
            erdat TYPE erdat,                   "Created On
            vbeln TYPE vbeln_va,                "Delivery
            auart TYPE auart,                   "Sales document type
            vtweg TYPE vtweg,                   "Distribution channel
            knumv TYPE knumv,                   "Number of doc condition
            END OF t_vbak,
    *--Structure for KONV Table
            BEGIN OF t_konv,
            knumv TYPE knumv,                   "Number of doc condition
            kschl TYPE kscha,                   "Condition type
            kbetr TYPE kbetr,                   "Rate
            END OF t_konv,
    *--Structure for DUMMY Table
            BEGIN OF t_dummy,
            fkdat TYPE fkdat,                   "Billing date
            matnr TYPE matnr,                   "Material Number
            bwart TYPE bwart,                   "Movement type
            kbetr TYPE kzwi2,                   "Net value of billing item
            END OF t_dummy,
    *--Structure for NDAY table
            BEGIN OF t_nday,
            erdat   TYPE erdat,                 "Created On
            flag(1) TYPE c,                     "Flag
            END OF t_nday,
    *--Structure for TFACS Table
            BEGIN OF t_tfacs,
            ident TYPE wfcid,                   "Factory calendar ID
            jahr  TYPE kjahr,                   "Fiscal Year
            mon01 TYPE mon00,                   "Calendar: Days in a month
            mon02 TYPE mon00,                   "Calendar: Days in a month
            mon03 TYPE mon00,                   "Calendar: Days in a month
            mon04 TYPE mon00,                   "Calendar: Days in a month
            mon05 TYPE mon00,                   "Calendar: Days in a month
            mon06 TYPE mon00,                   "Calendar: Days in a month
            mon07 TYPE mon00,                   "Calendar: Days in a month
            mon08 TYPE mon00,                   "Calendar: Days in a month
            mon09 TYPE mon00,                   "Calendar: Days in a month
            mon10 TYPE mon00,                   "Calendar: Days in a month
            mon11 TYPE mon00,                   "Calendar: Days in a month
            mon12 TYPE mon00,                   "Calendar: Days in a month
            END OF t_tfacs,
    *--Structure for shipping days table.
            BEGIN OF t_ship,
            title(35) TYPE c,                   "Title
            days(10)  TYPE c,                   "Days
            END OF t_ship,
    *--Structure for Final Table
            BEGIN OF t_final,
            erdat   TYPE erdat,                 "Date
            oltot   TYPE i,                     "Online Order total
            sotot   TYPE i,                     "Special Order Total
            corebus TYPE kzwi2,                 "ECS Online Promo Rev
            onbulk  TYPE kzwi2,                 "ECS online Bulk Orders
            premier TYPE kzwi2,                 "MSFT Premier Program
            shipit  TYPE kzwi2,                 "MSFT online shipit program
            onpromo TYPE kzwi2,                 "MSFT online promo rev
            netrev  TYPE kzwi2,                 "MSFT/Xbox Consignment
            storev  TYPE kzwi2,                 "MSFT Retail Store promo rev
            connet  TYPE kzwi2,                 "MSFT Retail Consign net rev
            sporder TYPE kzwi2,                 "Special order revenue
            stdvd   TYPE kzwi2,                 "Traveling Store/DVD
            totrev  TYPE kzwi2,                 "Total ECS Revenue
            totbud  TYPE kzwi2,                 "Total ECS Budget
            ordsize TYPE kzwi2,                 "Avg online order size
            END OF t_final,
    *--Structure for Total Table
            BEGIN OF t_total,
            title(10) TYPE c,                   "Date
            oltot     TYPE i,                   "Online Order total
            sotot     TYPE i,                   "Special Order Total
            corebus   TYPE kzwi2,               "ECS Online Promo Rev
            onbulk    TYPE kzwi2,               "ECS online Bulk Orders
            premier   TYPE kzwi2,               "MSFT Premier Program
            shipit    TYPE kzwi2,               "MSFT online shipit program
            onpromo   TYPE kzwi2,               "MSFT online promo rev
            netrev    TYPE kzwi2,               "MSFT/Xbox Consignment
            storev    TYPE kzwi2,               "MSFT Retail Store promo rev
            connet    TYPE kzwi2,               "MSFT Retail Consign net rev
            sporder   TYPE kzwi2,               "Special order revenue
            stdvd     TYPE kzwi2,               "Traveling Store/DVD
            totrev    TYPE kzwi2,               "Total ECS Revenue
            totbud    TYPE kzwi2,               "Total ECS Budget
            ordsize   TYPE kzwi2,               "Avg online order size
            END OF t_total,
    *--Structure for MKPF Table
            BEGIN OF t_jkmkpf,
            budat TYPE budat,                   "Posting date
            mblnr TYPE mblnr,                   "Number of material document
            mjahr TYPE mjahr,                   "Material doc. year
            END OF t_jkmkpf,
    *--Structure for MSEG Table
            BEGIN OF t_jkmseg,
            fkdat TYPE fkdat,                   "Billing date
            matnr TYPE matnr,                   "Material Number
            mblnr TYPE mblnr,                   "Number of material document
            mjahr TYPE mjahr,                   "Material doc. year
            bwart TYPE bwart,                   "Movement type
            menge TYPE menge_d,                 "Quantity
            kbetr TYPE kbetr_kond,              "Rate
            dmbtr TYPE dmbtr,                   "Amount in local currency
            END OF t_jkmseg,
    *--Structure for A006 Table
            BEGIN OF t_a006,
            fkdat TYPE fkdat,                   "Billing date
            matnr TYPE matnr,                   "Material Number
            kappl TYPE kappl,                   "Application
            kschl TYPE kschl,                   "Condition type
            vkorg TYPE vkorg,                   "Sales organization
            vtweg TYPE vtweg,                   "Distribution channel
            datbi TYPE kodatbi,                 "Validity end date
            datab TYPE kodatab,                 "Validity start date
            knumh TYPE knumh,                   "Condition record number
            END OF t_a006,
    *--Structure for KONP Table
            BEGIN OF t_konp,
            fkdat TYPE fkdat,                   "Billing date
            matnr TYPE matnr,                   "Material Number
            knumh TYPE knumh,                   "Condition record number
            kappl TYPE kappl,                   "Application
            kschl TYPE kschl,                   "Condition type
            kbetr TYPE kbetr_kond,              "Rate
            END OF t_konp.
                          WORK AREAS                                     *
    DATA : wa_vbrp   TYPE t_vbrp,          "Work area for VBRP Table
           wa_mkpf   TYPE t_mkpf,          "Work area for MKPF Table
           wa_mseg   TYPE t_mseg,          "Work area for MSEG Table
           wa_jkmkpf TYPE t_jkmkpf,        "Work area for MKPF Table
           wa_jkmseg TYPE t_jkmseg,        "Work area for MSEG Table
           wa_kjmseg TYPE t_jkmseg,        "Work area for MSEG Table
           wa_lips   TYPE t_lips,          "Work area for LIPS Table
           wa_vbak   TYPE t_vbak,          "Work area for VBAK Table
           wa_konv   TYPE t_konv,          "Work area for KONV Table
           wa_dummy  TYPE t_dummy,         "Work area for DUMMY Table
           wa_tfacs  TYPE t_tfacs,         "Work area for TFACS Table
           wa_final  TYPE t_final,         "Work area for Final Table
           wa_total  TYPE t_total,         "Work area for Total Table
           wa_ship   TYPE t_ship,          "Work area for Ship Table
           wa_a006   TYPE t_a006,
           wa_konp   TYPE t_konp,          "Work area for KONP Table
           wa_nday   TYPE t_nday,
           wa_fieldcat TYPE slis_fieldcat_alv,"Work area for fieldcatalog
           wa_layout1 TYPE slis_layout_alv,
           wa_layout2 TYPE slis_layout_alv,
           wa_layout3 TYPE slis_layout_alv.
                          INTERNAL TABLES                                *
    DATA : it_vbrp   TYPE STANDARD TABLE OF t_vbrp   INITIAL SIZE 0,
           it_mkpf   TYPE STANDARD TABLE OF t_mkpf   INITIAL SIZE 0,
           it_mseg   TYPE STANDARD TABLE OF t_mseg   INITIAL SIZE 0,
           it_jkmkpf TYPE STANDARD TABLE OF t_jkmkpf INITIAL SIZE 0,
           it_jkmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
           it_kjmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
           it_lips   TYPE STANDARD TABLE OF t_lips   INITIAL SIZE 0,
           it_vbak   TYPE STANDARD TABLE OF t_vbak   INITIAL SIZE 0,
           it_konv   TYPE STANDARD TABLE OF t_konv   INITIAL SIZE 0,
           it_dummy  TYPE STANDARD TABLE OF t_dummy  INITIAL SIZE 0,
           it_tfacs  TYPE STANDARD TABLE OF t_tfacs  INITIAL SIZE 0,
           it_final  TYPE STANDARD TABLE OF t_final  INITIAL SIZE 0,
           it_total  TYPE STANDARD TABLE OF t_total  INITIAL SIZE 0,
           it_ship   TYPE STANDARD TABLE OF t_ship   INITIAL SIZE 0,
           it_nday   TYPE STANDARD TABLE OF t_nday   INITIAL SIZE 0,
           it_a006   TYPE STANDARD TABLE OF t_a006   INITIAL SIZE 0,
           it_konp   TYPE STANDARD TABLE OF t_konp   INITIAL SIZE 0,
           it_fieldcat  TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           it_fieldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           it_events TYPE slis_t_event,
           it_event1 TYPE slis_t_event,
           it_event2 TYPE slis_t_event,
           it_header TYPE slis_t_listheader.
                      PARAMETERS &  SELECT-OPTIONS                       *
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_erdat FOR vbak-erdat NO-DISPLAY. "Created On
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(10) text-003.
    PARAMETERS : p_month(7) TYPE c OBLIGATORY.  "Month
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(40) text-030.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(10) text-004.
    PARAMETERS : p_bud(16) TYPE c OBLIGATORY.   "Budget
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK blk1.
                      AT SELECTION SCREEN                                *
    AT SELECTION-SCREEN ON p_month.
    *--Create the date range
      PERFORM sub_create_date.
                      START-OF-SELECTION                                 *
    START-OF-SELECTION.
    *--Select data from TFACS Table
      PERFORM sub_read_tfacs.
    *--Select Data from VBAK Table
      PERFORM sub_read_vbak.
    *--Select Data from VBRP Table
      PERFORM sub_read_vbrp.
    *--Select Data from MKPF Table
      PERFORM sub_read_mkpf.
    *--Select Data from MSEG Table
      PERFORM sub_read_mseg.
    *--Select Data from LIPS Table
      PERFORM sub_read_lips.
    *--Select Data from KONV Table
      PERFORM sub_read_konv.
    *--Collect all the data into final inetrnal table
      PERFORM sub_collect_data.
    *--Collect all the data into final inetrnal table
      PERFORM sub_collect_vbrp.
    *--Collect all the data into final inetrnal table
      PERFORM sub_collect_lips.
    *--Collect MSFT retail store promo rev & MSFT retail
    store consignment net rev
      PERFORM sub_jk_column.
    *--Collect consignment cost
      PERFORM sub_collect_consign.
    *--Calculate Plug Numbers
      PERFORM sub_claculate_plug.
    *--Collect data from vbrp
      PERFORM sub_collect_cost.
    *--Calculate the total & avarages
      PERFORM sub_calculate_total.
    *--Collect totals & avarages into final internal table
      PERFORM sub_collect_total.
                      END-OF-SELECTION                                   *
    END-OF-SELECTION.
    *--This perform creates the ALV events
      PERFORM sub_create_events.
    *--This perform prepare field catalog.
      PERFORM sub_field_catalogmerge.
    *--This perform displays an ALV report
      PERFORM sub_alv_display.
    *&      Form  sub_read_vbrp
          text
    FORM sub_read_vbrp .
    *--Local Variables
      DATA : lv_index LIKE sy-tabix.
    *--Select query to pick the Billing document Billing date Billing
    category Billing type Distribution channel Number of doc condition
    Billing item Material Number Plant Referance Subtotal 2 Cost in
    document currency and Partner function from table VBRK VBRP and VBPA
    using inner join
      SELECT a~vbeln                            "Billing document
             a~fkdat                            "Billing date
             a~fktyp                            "Billing category
             a~fkart                            "Billing type
             a~vtweg                            "Distribution channel
             a~knumv                            "Number of doc condition
             b~posnr                            "Billing item
             b~matnr                            "Material Number
             b~werks                            "Plant
             b~vgbel                            "Referance
             b~kzwi2                            "Subtotal 2
             b~wavwr                            "Cost in document currency
             c~kunnr                            "Partner function
             FROM vbrk AS a
             INNER JOIN vbrp AS b
             ON avbeln EQ bvbeln
             INNER JOIN vbpa AS c
             ON  bvbeln EQ cvbeln
             INTO CORRESPONDING FIELDS OF TABLE it_vbrp
             WHERE fkdat IN s_erdat
             AND   parvw EQ 'ZS'.
      IF sy-subrc EQ 0.
    *--Sort table by Referance
        SORT it_vbrp BY vgbel1.
      ENDIF.
      LOOP AT it_vbrp INTO wa_vbrp.
        lv_index = sy-tabix.
        wa_vbrp-vgbel1 = wa_vbrp-vgbel.
        MODIFY it_vbrp FROM wa_vbrp INDEX lv_index TRANSPORTING
                                          vgbel1.
    *--Clear
        CLEAR : wa_vbrp.
      ENDLOOP.
    ENDFORM.                    " sub_read_vbrp
    *&      Form  sub_read_mkpf
          text
    FORM sub_read_mkpf .
    *--Local Variables
      DATA : lv_index LIKE sy-tabix.
      IF NOT it_vbrp[] IS INITIAL.
    *--Select query to pick the Number of material document Material
    document year and Referance from table MKPF
        SELECT DISTINCT
               mblnr                            "Number of material document
               mjahr                            "Material doc. year
               xblnr                            "Referance
               FROM mkpf
               INTO CORRESPONDING FIELDS OF TABLE it_mkpf
               FOR ALL ENTRIES IN it_vbrp
               WHERE xblnr EQ it_vbrp-vgbel.
      ENDIF.
    *--Sort table by No of material document and fiscal year
      SORT it_mkpf BY mblnr mjahr.
      IF sy-subrc EQ 0.
        DELETE ADJACENT DUPLICATES FROM it_mkpf COMPARING mblnr mjahr.
      ENDIF.
    *--Sort table by referance document
      SORT it_vbrp BY vgbel.
      SORT it_mkpf BY xblnr.
      IF NOT it_mkpf[] IS INITIAL.
        LOOP AT it_mkpf INTO wa_mkpf.
          lv_index = sy-tabix.
    *--Clear
          CLEAR : wa_vbrp.
          READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel = wa_mkpf-xblnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_mkpf-fkdat = wa_vbrp-fkdat.
            wa_mkpf-kunnr = wa_vbrp-kunnr.
          ENDIF.
          MODIFY it_mkpf FROM wa_mkpf INDEX lv_index TRANSPORTING
                                            fkdat kunnr.
    *--Clear
          CLEAR : wa_mkpf.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " sub_read_mkpf
    *&      Form  sub_read_mseg
          text
    FORM sub_read_mseg .
    *--Local Variables
      DATA : lv_index LIKE sy-tabix.
      IF NOT it_mkpf[] IS INITIAL.
    *--Select query to pick the Number of material document Material
    document year Movement type Special Stock indicator and Amount in
    local currency from table MSEG
        SELECT mblnr                            "Number of material document
               mjahr                            "Material doc. year
               bwart                            "Movement type
               sobkz                            "Special Stock indicator
               dmbtr                            "Amount in local currency
               matnr                            "Material
               werks                            "Plant
               FROM mseg
               INTO CORRESPONDING FIELDS OF TABLE it_mseg
               FOR ALL ENTRIES IN it_mkpf
               WHERE mblnr EQ it_mkpf-mblnr
               AND   mjahr EQ it_mkpf-mjahr.
              AND   bwart EQ '601'.
              AND   sobkz EQ 'K'.
      ENDIF.
    *--Sort table by Number of material document
      SORT it_mkpf BY mblnr.
    *--Sort table by Number of material document
      SORT it_mseg BY mblnr.
      IF NOT it_mseg[] IS INITIAL.
        LOOP AT it_mseg INTO wa_mseg.
          lv_index = sy-tabix.
    *--Clear
          CLEAR : wa_mkpf.
          READ TABLE it_mkpf INTO wa_mkpf WITH KEY mblnr = wa_mseg-mblnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_mseg-fkdat = wa_mkpf-fkdat.
            wa_mseg-kunnr = wa_mkpf-kunnr.
          ENDIF.
          MODIFY it_mseg FROM wa_mseg INDEX lv_index TRANSPORTING
                                            fkdat kunnr.
    *--Clear
          CLEAR: wa_mseg.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " sub_read_mseg
    *&      Form  sub_read_lips
          text
    FORM sub_read_lips .
    *--Local Variables
      DATA : lv_index LIKE sy-tabix.
      IF NOT it_vbrp[] IS INITIAL.
    *--Select query to pick the Delivery Material Number Plant
    Movement type Subtotal 2 and Quantity from table LIPS
        SELECT vbeln                            "Delivery
               matnr                            "Material Number
               werks                            "Plant
               bwart                            "Movement type
               kzwi2                            "Subtotal 2
               lfimg                            "Quantity
               FROM lips
               INTO CORRESPONDING FIELDS OF TABLE it_lips
               FOR ALL ENTRIES IN it_vbrp
               WHERE vbeln EQ it_vbrp-vgbel1.
        IF sy-subrc EQ 0.
    *--Sort table by Delivery
          SORT it_lips BY vbeln.
        ENDIF.
      ENDIF.
    *--Sort table
      SORT it_vbrp BY vgbel1.
      LOOP AT it_lips INTO wa_lips.
        lv_index = sy-tabix.
    *--CLear
        CLEAR : wa_vbrp.
        READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel1 = wa_lips-vbeln
                                                 BINARY SEARCH.
        IF sy-subrc EQ 0.
          wa_lips-fkdat = wa_vbrp-fkdat.
          wa_lips-knumv = wa_vbrp-knumv.
        ENDIF.
        MODIFY it_lips FROM wa_lips INDEX lv_index TRANSPORTING
                                    fkdat knumv.
    *--Clear
        CLEAR : wa_lips.
      ENDLOOP.
    ENDFORM.                    " sub_read_lips
    *&      Form  sub_read_konv
          text
    FORM sub_read_konv .
      IF NOT it_vbrp[] IS INITIAL.
    *--Select query to pick the Number of doc condition Condition type
    and Rate from table KONV
        SELECT knumv                            "Number of doc condition
               kschl                            "Condition type
               kbetr                            "Rate
               FROM konv
               INTO TABLE it_konv
               FOR ALL ENTRIES IN it_vbrp
               WHERE knumv EQ it_vbrp-knumv
               AND   kschl EQ 'ZR00'.
      ENDIF.
    ENDFORM.                    " sub_read_konv
    *&      Form  sub_read_vbak
          text
    FORM sub_read_vbak .
    *--Select query to pick the Created On Delivery Sales document type
    Distribution channel and Number of doc condition from table VBAK
      SELECT erdat                              "Created On
             vbeln                              "Delivery
             auart                              "Sales document type
             vtweg                              "Distribution channel
             knumv                              "Number of doc condition
             FROM vbak
             INTO TABLE it_vbak
             WHERE erdat IN s_erdat.
      IF sy-subrc EQ 0.
    *--Sort table by created on
        SORT it_vbak BY erdat.
      ENDIF.
    ENDFORM.                    " sub_read_vbak
    Regards,
    prashant

  • Items Sales Report

    Hello.
    I need to make an items sales report, but i have diferences between OINV.DocTotal and (INV1.Quantity * INV1.Price). What is the correct way to make this kind of report?
    regards
    Oscar

    thanks for every one, I found the answer:
    SELECT T0.DocEntry, T1.DocNum,
           (SELECT (T2.DocTotal - T2.VatSum) FROM OINV T2 WHERE T0.DocEntry = T2.DocEntry) 'DocNeto',
          (ROUND(SUM(T0.LineTotal),4) - T1.DiscSum) 'DetTotal' FROM INV1 T0
       LEFT JOIN OINV T1 ON T0.DocEntry = T1.DocEntry
    WHERE YEAR(T0.DocDate) = 2008  AND T1.DocType = 'I' and T0.DocEntry = 8755
    GROUP BY T0.DocEntry,T1.DocTotal,T1.DocNum,T1.DiscSum
    I did this query to match the header and details invoices.
    Thanks, for your time.

  • Sales Report - Shipped, Open By Region then Country and so on

    Hi All,
    We are new to BusinessOne. We have just rolled it out and i have to develop a report in businessobjects using B1 data which resides on sql server 2012. What my requirement is that they need a MTD sales report by customer group, shipped and open.
    My question is which tables i need to query to get this information from?
    I need all sales that were shipped and are open by customer group for the current month to date.
    If i am not clear, please ask for detail and i will try my best again. Thank you.

    Hi,
    Please use below tables and link as shown below
    ORDR and  RDR1 for sales order
    ODLN and DLN1 for delivery order
    ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry left join DLN1 T2 on T2.[BaseEntry]  = T1.docentry and T2.[BaseLine]  =  T1.[LineNum] INNER JOIN ODLN T3 ON T2.DocEntry = T3.DocEntry
    Thanks & Regards,
    Nagarajan

  • Reg: Sales Report Problem

    Hi Experts,
    My client are already using the reports as Sales Report as follows
        Customer         Daily-Today     Monthly-Current        Yearly-Current
    Customer_001          5000.00          250000          350000
    Customer_002          25000.00            1250000          1250000
    For the above report, I used this Query
    SELECT DISTINCT T0.CardCode [Customer], T1.CARDNAME [NAME],
    (SELECT ISNULL(SUM(I.DocTotal),0) FROM INV1 I1 INNER JOIN
    OINV I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Day(I.DocDate) = Day(GetDate()) AND
    Month(I1.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Daily - Today],
    (SELECT ISNULL(SUM(I.DocTotal),0)
    FROM INV1 I1 INNER JOIN OINV I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Month(I.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Monthly - Current Month],
    (SELECT ISNULL(SUM(I.DocTotal),0) FROM INV1 I1 INNER JOIN
    OINV I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode
    AND Year(I.DocDate) = Year(GetDate())) [Yearly - Current Year]
    FROM [dbo].[OINV] T0 LEFT OUTER JOIN OCRD T1 ON
    T1.CARDCODE=T0.CARDCODE GROUP By T0.CardCode, T1.CARDNAME
    But my problem is the above query resulting without reference to A/R Credit Memo
    i.e I need to deduct the A/R Credit Memo amount, also another one problem
    is the above query is related to Calender Year, but My client need the report
    according to financial year.
    Regards,
    Balakumar

    Try this one I added a Union to include the credits, you can modify the dates to do a range of dates.
    SELECT DISTINCT T0.CardCode [Customer], T1.CARDNAME [NAME],
    (SELECT ISNULL(SUM(I.DocTotal),0) FROM INV1 I1 INNER JOIN
    OINV I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Day(I.DocDate) = Day(GetDate()) AND
    Month(I1.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Daily - Today],
    (SELECT ISNULL(SUM(I.DocTotal),0)
    FROM INV1 I1 INNER JOIN OINV I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Month(I.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Monthly - Current Month],
    (SELECT ISNULL(SUM(I.DocTotal),0) FROM INV1 I1 INNER JOIN
    OINV I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode
    AND Year(I.DocDate) = Year(GetDate())) [Yearly - Current Year]
    FROM [dbo].[OINV] T0 LEFT OUTER JOIN OCRD T1 ON
    T1.CARDCODE=T0.CARDCODE GROUP By T0.CardCode, T1.CARDNAME
    union
    SELECT DISTINCT T0.CardCode [Customer], T1.CARDNAME [NAME],
    (SELECT ISNULL(SUM(I.DocTotal),0) FROM rin1 I1 INNER JOIN
    orin I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Day(I.DocDate) = Day(GetDate()) AND
    Month(I1.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Daily - Today],
    (SELECT ISNULL(SUM(I.DocTotal *-1),0)
    FROM rin1 I1 INNER JOIN OrIN I ON I1.DocEntry = I.DocEntry
    WHERE I.CardCode = T0.CardCode AND
    Month(I.DocDate) = Month(GetDate()) AND
    Year(I1.DocDate) = Year(GetDate())) [Monthly - Current Month],
    (SELECT ISNULL(SUM(I.DocTotal * -1),0) FROM rin1 I1 INNER JOIN
    orin I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode
    AND Year(I.DocDate) = Year(GetDate())) [Yearly - Current Year]
    FROM [dbo].[Orin] T0 LEFT OUTER JOIN OCRD T1 ON
    T1.CARDCODE=T0.CARDCODE GROUP By T0.CardCode, T1.CARDNAME
    Edited by: M. Jenkins on Apr 9, 2009 2:53 PM

Maybe you are looking for

  • Concept question

    Hello All and Happy Friday, I have a quick question from a newbie. I am running my 11.1.0.7 db on a Redhat5 host in ARCHIVE LOG MODE. I have my archived redos going into two different locations. u02/oradata/CUST/ and s/22/san/flash_recovery_area/CUST

  • Problem using JDBC Connector

    Hi, I have problem connecting to MS SQL Server using the JDBC Connector. I have 2 main questions, one is on the DQE and the other is on user mapping. I have a created a JDBC System Landscape using the portal component com.sap.portal.systems.jdbc. Fol

  • Add audio files and automatically convert

    How to set up automatic conversion in MP3 128kb/s audio when I add music to itunes. The problem is that I have to constantly convert all I add. This creates a duplicate and I have to look for them and delete them. This is not very convenient

  • Jobs running different than scheduled time

    Hi All' I have 10g(10.2.0.2) database in linux,It is in Austin. Recently the jobs scheduled are running on different than scheduled time. And time in EM and the date command in linux also showing different. $ date Wed Oct 31 03:59:01 CDT 2007 and the

  • Applets and certificates in jdk1.4

    Hello all... I have an applet which imports the java.awt.Robot class. I can not use the methods from a html page due to security restrictions... I've searched high and wide for documentation on how to overcome this (as i am only going to be running t