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

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

  • Crystal report - need some help

    Hi
    I'll try to explain my problem simply. Basically we have a support line in our company and i am putting report on a screen that will show missed calls ( that part is done) and was the call returned(here is the problem).
    We have 3 inbond phone queues and 1 outbound. I am connecting to orderlystats database which is supplying me with the missed calls and the queue id. It is supplying as well, was the missed call called back or not, but marking that only if missed caller call back again, if we call back him the orderlystats is not marking that missed call as called back.
    Now what i want to do is check in the outbound queue, was there a call with the same callerid that have been missed and if there was a call like that, mark the missed call as returned.
    Here is some info about the database:
    acdqueueid (Number)      (1 = outbound queue, 7 = inbound queue, 8 = inbound queue, 10 = inbound queue)
    callerid (String)
    calledback (Number) (0 = no, 1 = yes)
    At the moment the report is not displaying the outbound queue at all as we want just the inbound missed calls. The question is how i can compare the callerid from 3 inbound queues and check was there the same callerid in the outbound queue and mark that in called back variable?
    Current SQL Query:
    SELECT `orderlystats_call1`.`calledback`, `orderlystats_call1`.`entry`, `orderlystats_call1`.`agentid`, `orderlystats_call1`.`acdqueueid`, `orderlystats_call1`.`holdtime`, `orderlystats_call1`.`callerid`
    FROM   `orderlystats`.`orderlystats_call` `orderlystats_call1`
    WHERE  (`orderlystats_call1`.`acdqueueid`=7 OR `orderlystats_call1`.`acdqueueid`=8 OR `orderlystats_call1`.`acdqueueid`=10)
    I hope all this make sense.
    Thanks in advance for any suggestions.
    Karol

    I honestly got lost in translation, but, I would think you could leave the main report as is.
    Add a sub report, add a link to the sub-report,  link by the call id.
    In the subreport, make your db connection the Callback database.
    you could then pull info from the Callback DB, based on the value of the Call ID from the main report.
    Hope that makes sense.

  • 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]')

  • Report Query..help

    Hi,
    I have supplier, qutation and invoice table.
    Supplier:
    supp_id = supp_name
    1 = ABC
    2 = XYZ
    Qutation:
    quta_id = quta_date = supp_id
    1 = 12-Dec-2008 = 1
    3 = 15-Dec-2008 = 1
    5 = 18-Dec-2008 = 1
    Invoice:
    inv_id = inv_date = supp_id
    150 = 01-Dec-2008 = 1
    250 = 11-Dec-2008 = 1
    100 = 15-Nov-2008 = 2
    Qutation and Invoice are non dependent.
    I have a report which needs to display following information:
    Supplier with total qutation and invoices
    Supplier Name = Qutation ID = Qutation Date = Invoice Id = Invoice Date
    ABC = 1 = 12-Dec-2008 = 150 = 01-Dec-2008
    ABC = 3 = 15-Dec-2008 = 250 = 11-Dec-2008
    ABC = 5 = 18-Dec-2008 = * = *
    XYZ = * = * = 100 = 15-Nov-2008
    You can see there is no record for Invoice in 3rd row and qutation data for 4th row thats why it is showing '*'.
    Could you please tell me how to manage such output using Single query
    Thanks in advance,
    RSD
    Edited by: RSD on Dec 30, 2008 6:03 PM

    Check this out. You need FULL JOIN
    SQL> with supplier
      2  as
      3  (
      4     select 1 supp_id, 'ABC' supp_name from dual
      5     union all
      6     select 2, 'XYZ' from dual
      7  )
      8  , Qutation
      9  as
    10  (
    11     select 1 quta_id,  to_date('12-Dec-2008','dd-mon-yyyy') quta_date, 1 supp_id from dual
    12     union all
    13     select 3, to_date('15-Dec-2008','dd-mon-yyyy'), 1 from dual
    14     union all
    15     select 5, to_date('18-Dec-2008','dd-mon-yyyy'), 1 from dual
    16  )
    17  , Invoice
    18  as
    19  (
    20     select 150 inv_id, to_date('01-Dec-2008','dd-mon-yyyy') inv_date, 1 supp_id from dual
    21     union all
    22     select 250, to_date('11-Dec-2008','dd-mon-yyyy'), 1 from dual
    23     union all
    24     select 100, to_date('15-Nov-2008','dd-mon-yyyy'), 2 from dual
    25  )
    26  --
    27  -- sample date ends here
    28  --
    29  select supp_name, t.*
    30    from (select decode(q.supp_id, null, i.supp_id, q.supp_id) supp_id, q.quta_id, q.quta_date, i.inv_id, i.inv_date
    31       from (select row_number() over(partition by supp_id order by quta_id) rno, q.*
    32               from qutation q) q
    33       full join
    34            (select row_number() over(partition by supp_id order by inv_id) rno, i.*
    35               from invoice i) i
    36         on q.supp_id = i.supp_id
    37        and q.rno = i.rno) t
    38    join supplier s
    39      on t.supp_id = s.supp_id
    40  /
    SUP    SUPP_ID    QUTA_ID QUTA_DATE     INV_ID INV_DATE
    ABC          1          1 12-DEC-08        150 01-DEC-08
    ABC          1          3 15-DEC-08        250 11-DEC-08
    ABC          1          5 18-DEC-08
    XYZ          2                             100 15-NOV-08

  • Newbie report. need some help.

    I bit the bullet and installed ArchLinux on a 'clean' laptop. Prior to Arch, I had a dual-boot system running Ubuntu 7.04 and XP. I was planning to install ArchLinux, and run WindowsFLP (I still got apps that only work in Windows) under VirtualBox.
    I got around to installing ArchLinux using FTP install - not my original plan.   I'm glad to have backed up my data to an external drive because after I repartitioned the whole disk, I got stupid and somehow ruined my installer disc during the process. . I'm glad to have an old puppylinux disc at hand, so I managed to download the software I need to install 64-bit Arch via USB stick.
    Right now, I'm not very sure whether to be happy about it or not. I've been on Ubuntu for several years now and it was the only distro that made me stick with Linux 98% of the time. What I liked about Ubuntu is that in most cases, I don't have to bother with most things. They just work. (Or at least, the things I wanted did.)
    Now I have Arch installed with XFCE. Unfortunately, I'm beginning to get tired of having to install everything I wanted one package at a time. Though I like the control and the latest program versions I get; but I'm not really an expert so I miss the 'friendliness' of Ubuntu. For example, after I got my DE running (thanks to the great wiki and forum) I have to get a browser (epiphany), and then an office suite (openoffice), next is drawing program (inkscape). I still have lots of packages to work on (Bluetooth, Gramps, VirtualBox, etc, etc.)
    I'm kinda irritated that not everything is working smoothly. Flash is not working. I can't get Firefox to run. Some of Epiphany's icons are missing (I only got an image with a red 'X' in its place). check this image:
    I haven't decided on whether it's for keeps - it's like a day-old only and still the only OS running on my computer. I'll give Arch a go and compare it with Ubuntu 8.04 when it comes out three weeks from now.
    I hope for some feedback. Thanks.
    EDIT
    - icon problem resolved by changing to Tango icon pack
    - still working on Flash
    Last edited by GOwin (2008-04-09 00:30:55)

    sudo pacman -Sy flashplugin
    Tried it but it's not working. Got this "error: 'flashplugin': not found in sync db"
    As for my Icon problem. Changing the Icon set didn't work out.
    As you can see, there are other icons missing. Here's a screen shot of the toolbar editor with highlights on missing icons.
    Last edited by GOwin (2008-04-08 13:26:39)

  • 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.

  • Need help troubleshooting Report Query/BI Publisher

    Hi All --
    I need some help with an odd issue I'm having with a report query and BI Publisher. The users run this report by inputting a date range, usually by week. Oddly enough, if we input a date range of 06/01/2008 through 06/07/2008, the report runs and BI Publisher renders the document correctly, but if we input a date range of 06/08/2008 through 06/14/2008, the report shows correctly on the screen, but BI Publisher returns an empty document. I thought perhaps it was an issue with the data, but inputting the date range of 06/01/2008 through 06/14/2008 works correctly and the document is rendered with all the data as shown in the report.
    I'm really at a loss and don't know how to proceed in troubleshooting the issue. Does anyone know of any log files or anything else to look at to try and figure out why the report isn't being rendered correctly for that one week?
    Thanks!
    Leigh Johnson

    Thanks Marc --
    The OC4J logs don't show any errors at the time I tried running the report. I did change the output format to XML and saved it for the date range that doesn't work as well as a date range that does work. As foar as I can tell, the only differences is the data within the tags, but I'm no XML expert so I may have missed something. I opened my report template and loaded the xml data first from the date range that produces a rendered report properly and used preview...as expected it worked. When I did the same thing for the "bad" date range, I get the following set of errors, should I move my issue to the BI Publisher forum do you think?
    ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: D:\BiPublisher\on_time_delivery.rtf
    RTFProcessor setLocale: en-us
    FOProcessor setData: D:\BiPublisher\ontimedelivery.xml
    FOProcessor setLocale: en-us
    Output type: MHTML
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(XSLT10gR1.java:721)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:504)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:253)
         at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:181)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1151)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:275)
         at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1809)
         at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:1027)
         at RTF2PDF.runRTFto(RTF2PDF.java:708)
         at RTF2PDF.runXDO(RTF2PDF.java:548)
         at RTF2PDF.main(RTF2PDF.java:305)
    Caused by: oracle.xdo.parser.v2.XPathException: An internal error condition occurred.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
         ... 15 more

  • Sales opportunities (source) -- sales report (sales analysis) link, help!

    Hello,
    Should be a simple quetion but I just can't work it out, please help!
    On our sales opportunities we record the source. Ie where we advertised to get that opp through the door.
    On Sales Reports>Sales Analysis I can see the totals for the month and the gross profit.
    What I'm trying to do is map the totals for the month and gross profit against the source. Ie to see which sources make us the money that keeps us going as a company
    But I can't seem to find the links anywhere to do a custom query.
    Can anyone help?
    many thanks

    Hi.......
    You can get this link very easily......
    Its there in standard report.
    When you punch the Sales Opportunity and conclude the same by attaching the document reference like Sales Quotation or Sales Order or any sales Doc. After that if your refer any Opportunity report (Sales Opportunity--> Sales Opportunity Reports) then you have to select the document tick. It will give you the document wise opportunity status.
    Hope this will help you.....
    Regards,
    Rahul

  • Need Some help in Developing an ALV report ..Plz help me

    Hi Experts I am basic learner to ABAP Here I need some help in developing a Delivery *** Invoice Report....Please help me by spending a little time..
    Tables are VBAK VBAP LIPS LIKP   and Document floe table is VBFA
      SELECT VBELN VKORG VTWEG SPART
        FROM VBAK
        INTO TABLE I_VBAK
        WHERE VBELN IN S_VBELN.
      IF I_VBAK IS NOT INITIAL .
        SELECT VBELN POSNR MATKL POSAR WERKS
          FROM VBAP
          INTO TABLE I_VBAP
          FOR ALL ENTRIES IN I_VBAK
          WHERE VBELN = I_VBAK-VBELN.
      ENDIF.
      IF I_VBAP IS NOT INITIAL.
        SELECT * FROM LIPS
          INTO CORRESPONDING FIELDS OF TABLE I_LIPS
          WHERE VGBEL = VBAP-VBELN
          AND VGPOS = VBAP-POSNR.
      ENDIF.
      IF I_LIPS IS NOT INITIAL.
        SELECT VBELN VSTEL VKORG KUNNR
        FROM LIKP
        INTO TABLE I_LIKP.
      ENDIF.
    Moderator message : Outsourcing is not allowed, don't expect others to correct your source code. Thread locked.
    Edited by: Vinod Kumar on Aug 1, 2011 5:43 PM

    hi ,
      Look in this link
      <a href="http://help.sap.com/saphelp_nw04/helpdata/en/b3/0ef3e8396111d5b2e80050da4c74dc/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/b3/0ef3e8396111d5b2e80050da4c74dc/frameset.htm</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/21/894eeee0b911d4b2d90050da4c74dc/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/21/894eeee0b911d4b2d90050da4c74dc/content.htm</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/80/1a62bfe07211d2acb80000e829fbfe/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/80/1a62bfe07211d2acb80000e829fbfe/content.htm</a>
    Regards
    Renjith Kumar

  • Monthly wise Sales report - Help me

    Dear SDN mates
    Is there any standard reports for Monthly wise sales report ...the SAP1 , SAP2 reports were not helpful....Does this can be solved by standard reports or it needs to be customized????
    kindly help me?

    hi,
    check VC05 transaction.

  • Need some help with the Select query.

    Need some help with the Select query.
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    select single vkorg abgru from ZADS into it_rej.
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
            VKORG TYPE VBAK-VKORG,
            ABGRU TYPE VBAP-ABGRU,
           END OF IT_REJ.
    This is causing performance issue. They are asking me to include the where condition for this select query.
    What should be my select query here?
    Please suggest....
    Any suggestion will be apprecaiated!
    Regards,
    Developer

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • 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

  • Need some help with a bottom up recursive query

    I need to query some hierarchical data. I've written a recursive query that allows me to examine a parent and all it's related children using an adjacency data model. The scenario is to allow users to track how columns are populated in an ETL process. I've
    set up the sample data so that there are two paths:
    1. col1 -> col2 -> col3 -> col6
    2. col4 - > col5
    You can input a column name and get everything from that point downstream. The problem is, you need to be able to start at the bottom and work your way up. Basically, you should be able to put in col6 and see how the data got from col1 to col6. I'm not sure
    if it's a matter of rewriting the query or changing the schema to invert the relationships. Any input is welcome. Sample code below.
    DECLARE @table_loads TABLE (column_id INT, parent_id INT, table_name VARCHAR(25), column_name VARCHAR(25))
    DECLARE @column_name VARCHAR(10)
    INSERT INTO @table_loads(column_id, parent_id, table_name, column_name)
    SELECT 1,NULL,'table1','col1'
    UNION ALL
    SELECT 2,1,'table2','col2'
    UNION ALL
    SELECT 3,2,'table3','col3'
    UNION ALL
    SELECT 4,NULL,'table4','col4'
    UNION ALL
    SELECT 5,4,'table5','col5'
    UNION ALL
    SELECT 6,3,'table6','col6'
    SELECT * FROM @table_loads
    SET @column_name = 'col1'
    WITH load_order(column_id, parent_id,table_name, column_name)
    AS(
    SELECT column_id, parent_id,table_name, column_name
    FROM @table_loads
    WHERE column_name = @column_name
    UNION ALL
    SELECT tl.column_id, tl.parent_id, tl.table_name, tl.column_name
    FROM load_order lo
    JOIN @table_loads tl
    ON lo.column_id = tl.parent_id
    SELECT * FROM load_order

    Got it. It required a VERY subtle change in the join code:
    WITH load_order(column_id, parent_id,table_name, column_name)
    AS(
    SELECT column_id, parent_id,table_name, column_name
    FROM @table_loads
    WHERE column_name = @column_name
    UNION ALL
    SELECT tl.column_id, tl.parent_id, tl.table_name, tl.column_name
    FROM @table_loads tl
    JOIN load_order lo
    ON lo.parent_id = tl.column_id
    SELECT * FROM load_order

  • Sales report for the month.

    Hi all,
    I am looking for some help with a query that I am trying to write for a customer. They have asked me for a report that shows them a date range of sales not including: Discount, Tax, and Shipping/Freight. They are wanting to be able to populate this using a date range and by business partner. The last thing they are wanting is to have this only include items that are in 2 specific item groups. If anyone has any suggestions it would be greatly appreciated. Thanks!
    Kind Regards,
    Jeff Haldeman
    Support One

    Hi Jeff ,
    lets make this simpler
    1. How do you identify as sales -- Is it Ar invoice or Sales order
    2. How is your user entering data for discount at row level or footer (header) level
    3. Since they need Item * sales Cost  ,looks like you have to calculate your own total so you cannot  use  system total unless you reverse (doctotal -tax -discount )
    4.  Date range means (you have to use parameter )
    5. Business partner range (parameter )
    6. Item with two group ( put a condition )
    Did you take a look at Sales Analysis report by Item with secondary selection customer and use filter function to take out some unnecessry field .May be that satisfied their need .
    Please update us more .then we can help you more
    Thank you
    Bishal

Maybe you are looking for