SQL turnover from sales and quantity for designated articles minus credit

Hi,
I need a query wich can show me the complete (turnover from the sales, quantity and Ø Price) minus credits. Unfortunately my query work correctly
Who can help?
SELECT T0.[ItemCode],
(Select Sum(T0.[Quantity]) FROM INV1 T0 where T0.[ItemCode] = [%ItemCode] and
T0.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') -
(Select Sum(T1.[Quantity]) FROM  RIN1 T1 where T1.[ItemCode] = [%ItemCode] and
T1.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') as Menge,
(Select Sum(T0.[Price]) FROM INV1 T0 where T0.[ItemCode] = [%ItemCode] and
T0.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') -
(Select Sum(T1.[Price]) FROM  RIN1 T1 where T1.[ItemCode] = [%ItemCode] and
T1.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') as Preis,
((Select Sum(T0.[Price]) FROM INV1 T0 where T0.[ItemCode] = [%ItemCode] and
T0.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') -
(Select Sum(T1.[Price]) FROM  RIN1 T1 where T1.[ItemCode] = [%ItemCode] and
T1.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]')) /
((Select Sum(T0.[Quantity]) FROM INV1 T0 where T0.[ItemCode] = [%ItemCode] and
T0.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]') -
(Select Sum(T1.[Quantity]) FROM  RIN1 T1 where T1.[ItemCode] = [%ItemCode] and
T1.ShipDate BETWEEN '[%FromDate]' AND '[%ToDate]')) as 'Ø Preis'
FROM INV1 T0
Where T0.[ItemCode]=[%ItemCode]
GROUP BY T0.[ItemCode]

Try This
/* select Docdate from Oinv t1 */
declare @d1 as Datetime
declare @d2 as Datetime
set @d1 =/* t1.docdate */'[%0]'
set @d2 =/* t1.docdate */'[%1]'
select t.CardCode,t.CardName,t.CardType,t.State,t.SlpName,sum(t.SDocTotal) as Sales , sum(t.SVatSum) as Vat,
sum(t.RDocTotal)as Creditnote, sum(t.rvatsum) CreditVat,SUM(t.SDocTotal-t.SVatSum -t.RDocTotal + (t.rvatsum) ) as Net
from (
SELECT T1.[DocDate],T0.[CardCode], T0.[CardName], T0.[CardType], T4.[State],
T3.[SlpName], T1.[DocNum]as [SDocNum], T1.[VatSum]as [SVatSum] , T1.[DocTotal]as  [SDocTotal]
,0 as [RDocNum],0 as [RVatSum], 0 as [RDocTotal]
FROM OCRD T0 INNER JOIN [dbo].OINV T1 ON T0.[CardCode] = T1.[CardCode]
INNER JOIN OSLP T3 ON T0.[SlpCode] = T3.[SlpCode]
  INNER JOIN CRD1 T4 ON T0.[CardCode] = T4.[CardCode]
WHERE   T0.[CardType] = 'C'
union all
SELECT T2.[DocDate], T0.[CardCode], T0.[CardName], T0.[CardType], T4.[State],
T3.[SlpName],
0 as [SDocNum],0 as [SVatSum], 0 as [SDocTotal],
T2.[DocNum] as [RDocNum], T2.[VatSum]  as [RVatSum], T2.[DocTotal]  as [RDocTotal]
FROM OCRD T0 INNER JOIN [dbo].orin T2 ON T0.[CardCode] = T2.[CardCode]
INNER JOIN OSLP T3 ON T0.[SlpCode] = T3.[SlpCode]
  INNER JOIN CRD1 T4 ON T0.[CardCode] = T4.[CardCode]
   WHERE    T0.[CardType] = 'C'
  ) as T
    where DocDate between @d1  and @d2
  group by t.CardCode,t.CardName,t.CardType,t.State,t.SlpName
Rgds
Kennedy

Similar Messages

  • From which table can I display PGI (material and quantity)for a spesific cu

    Dear gurus,
    From which table can I display PGI (material and quantity)for a spesific customer order?
    Thanks in advance

    HI
    PGI and material quantity can be available in MSEG table
    for this enter the sales order number in KDAUF or* MAT_KDAUF* fields in MSEG table
    Also try with LIPS delivery item table and LIKP table
    regards
    SAP SD
    Edited by: sapkpit_sd on Jul 22, 2010 8:14 AM

  • Problem Posting Receipt From Production and Issue for Production

    Hi Everyone,
    I am posting Receipt from Production and Issue for Production through DIAPI in SAP Business One 2007A SP00 PL03.
    I am using following lines of code
    oDocument.Lines.SetCurrentLine(0);
    oDocument.Lines.BaseEntry = int.Parse(BaseEntry);
    oDocument.Lines.Quantity = double.Parse(Quantity);
    lRetCode = oDocument.Add();
    The Document adds perfectly but when I open the document in SAP Business One i am not able to see the Order Number at Line level on which this document was Based.
    I identified the problem being Order Number Column being binded to BaseRef field hence form is not able to Show the Order Number and we cannot set BaseRef via DIAPI since the property to set that field is not exposed.
    I donot want to update the table through a Recordset Update Query. I would appreciate if the property to set that field is exposed by SAP or any other workaround can be put forward by anyone who has faced the same problem.
    Thanks
    Kapil

    Do you need to set
    oDocument.Lines.BaseType = 17 (if this is sales order)
    and then baseentry = baseentry....etc
    If you bind the base entry correctly it should alwasy shows the base document on both database as well as front end. I have never had any problem with this
    Sincerely

  • [svn:fx-trunk] 8786: Minor updates from Sujata and Min for fxgutils.

    Revision: 8786
    Author:   [email protected]
    Date:     2009-07-23 21:10:35 -0700 (Thu, 23 Jul 2009)
    Log Message:
    Minor updates from Sujata and Min for fxgutils. Addresses an issue where FXG files with a matrix display differently after running through FXG to FXG. Also includes a fix to stop processing of unknown fxg tags in skipped sections.
    QE: No
    Doc: No
    Checkintests: Pass
    Reviewer: Min and Sujata
    Modified Paths:
        flex/sdk/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/filters/AbstractFilte rNode.java
        flex/sdk/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/transforms/MatrixNode .java
        flex/sdk/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXParser.java
        flex/sdk/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java

    This is a duplicate post.  This should be locked to avoid further confusion.
    My CSS wont change
    Nancy O.

  • Purchase requisition from sales document' not possible due to a credit bloc

    hi experts,
    i have to confirm delivery date and quantity for some purchase order items but i'm not able because i receive following message:
    Subsequent function 'Purchase requisition from sales document' not possible due to a credit block'
    Purchase requisition belongs to a sales order which has customer 10000.
    The customer 10000 was block from FD32 but now i have unblock the customer from FD32, i have assigned customer to a category risk which is only a warning. (in OVA8 risk category 002 static check, reaction C, status/block uncheck )
    There is any possiblilities to confirm quantity ?? I mean ... i understand that sales order was created when the customer was block due to credit limit exceded ... but now the customer is not blocked.
    What should i do?
    Thank you.

    Hi Dan
    If you want to  confirm the delivery date then change the static check reaction to B . in OVA8 . But if you change the static check reaction to A , you can do Delivery and billing also
    Regards
    Srinath

  • Please I'm from Ecuador and I can't put my credit card en App Store. Please I need help  

    Please I'm from Ecuador and I can't put my credit card en App Store. Please I need help  

    Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • Fixed Date and Quantity for Sales order

    We have Requested Delivery Date in our order entry page in CRM ISA. This date is transferred fine to R/3 with the sales order.
    We want to flag the "Fixed Date and Quantity" field in schedule lines of the order in R/3 when the order is replicated to R/3.
    We also want to restrict the order specific to particular organization for which the fixed date and quantity is flagged when the
    order is replicated
    Any ideas on how to achieve this?

    thanks Rajesh..But I would like to do in a sales order without doing going to any other transaction. Can I assume that this is a gap and we need to code in user exit to trigger 413 movement type.
    points are rewarded.
    regards,

  • Difference between batch quantity and quantity for sale

    Hi all,
    I have created a batch in system with weight 340 KG. However, when I make a sales order for that batch, the system picks only 188 KG of it. There is no reserved/blocked etc quantity for the batch. Can you please help me identify where I might be going wrong?

    Base Quantity - Quantity of the material to be produced to which the standard values of the operation refer.
    Operation Quantity - Quantity planned for this operation.
    Base quantity and operation quantity may not always be the same, if we have partial lots delivered during the sequence of operations, the operation quantity will be equal to the lot delivered during the operation.
    Base quantity is dependent on the BOM, where it signifies the total quantity of output after using the components of certain quantity.
    Hope this may help you.

  • Automatic creation of PR from sales order (SO) for the materials compement

    Hi
    I would like to create un PR from a sales order , but only for the material component (defined on Tcod CS01)
    I already know how to create un automatic PR from SO By using the TAS post type
    But the problem is that this method create only a PR for the material in SO him self and not for his component "what I really want"
    I search every where in VOV6  and VOV7 but I didn't find what Iu2019m looking for
    Thanks in advance For your advices and help
    S.Ghafai

    hello
    did you have any idea about this problem?
    I want to create automatically an PR for the Component of the Production BOM on saving my sales order
    exp :
    Material component = 1010 Qte 2  and 1011 Qte 25
    Sales material = 10XX Qte 1
    In my PR created the materials must be 1010 Qte 2 & 1011 Qte 25
    I hope my question is more clear now
    thanks in advanve

  • Set up Tolerance Limits with Date and quantity for GR

    Hi Experts,
    We would like to set the GR Tolerance Limits with Date and qty.
    how to set the Tolerance Limits for Date and quantity..??
    if we created PO 100qty and date 01-05-009.
    if we receive the goods on 20-04-2009 and 50qty...
    For GR .. Migo should be give error message..
    where can i set this Tolerance Limit Configuration.... can u please explin me..
    Thanks in Advance,
    Anthyodaya .

    hi,
    You can do one thing...
    Activate the SLED check...
    BY this when the date goes earlier or late from the expected date, then system show you the messages like:
    1. Earliest delivery date is DD.MM.YY..
    2. Expected delivery date was DD.MM.YY...
    In std sap system, the second message is already error message...so when get late delivery then it'll not be possible to maintain the GR...
    For the qty varinace, activate the quantity variance either via over/under delievery tolerances..or
    Via SPRO settings...
    SPRO >> MM >> LIV >> Invoice block >> check for qty tolerances and make the settings as per your requirement...
    Regards
    Priyanka.P

  • How to Set "delete from hub and server" for each account

    How can I set "delete from hub and server" differently for each account?
    I have 3 emails (2 shared, 1 personal).
    the personal is a 'hotmail' account which has device set to 'sync email', 'push', and 'Use SSL'.
    it will only sync one way (from desktop to device).
    I cannot set the global setting on the device to "delete from Hub and server" without affecting all accounts.
    I do not want to have to confirm delete on every item.
    previous to the 10.3 update this was not an issue.
    am i missing something? or is this another step backwards?

    The only other way would be to set it to prompt every time you get an email. Yeah, I know that defeats the purpose.. I guess in this aspect it is a step back

  • Sales and Support for Foreign Countries?

    Although I'm not familiar with the exportability of MATRIXx, I assume foreign sales are permitted (and encouraged). If I work with a foreign customer, to whom in NI should I direct their questions about pricing, planned development, and support?
    Thanks.

    Michael -
    National Instruments has over 35 international offices. You can find the contact information for the branch nearest your foreign customer at Contact NI. The staff there will be able to address all of your concerns surrounding foreign sales and the exportability of all NI products in that area, including MATRIXx.
    Regards,
    Greg Wempe
    Product Manager for MATRIXx
    National Instruments

  • Thunderbird3-x86-64 from AUR and Provider for Google plugin not workin

    Hi
    I compiled Thunderbird 3 from AUR which has the Lightning plugin in it v1.0b2pre and want Provider for Google (sync google calender to lightning) and I'm not getting it working.  I have tried serveral versions including the nightly build and does not install.  Has anyone got this plugin working?
    M

    Hi
    Thanks I've tried that but Provider for Google's preferences is not available for me to select - its greyed out. 
    I compiled Thunderbird from AUR which had Lightning pre-installed.  I disabled it and installed your recommended version - lightning is now 1.0b1 and Provider is 0.6b1.  Did you install Thunderbird from extra and not AUR?
    M
    Okay uninstalled my compiled thunderbird and installed from extra - its called shredder from what I see.  Installed lightning and provider as you have indicated and still Provider's preference button is grayed out.  is this due to remnents of previous installation? what can I do to fix?
    Last edited by majikins (2010-02-27 16:09:11)

  • Can you help? Converting from PC to Mac for Design Standard CS6

    Hello,
    I have recently purchased a macbook pro and downloaded the files for Design Standard CS6, I install the application and then enter my product key which works however it says
    "this product is valid but we could not find a qualifying product on this computer"
    It then tells me that if I want to use the code I must have one of the following products and the serial code, then it gives me a list of products none of which I want such as Design Standard 5, Web Premium etc
    I didn't need any of these on my PC I just downloaded the application and used my code
    Can anyone offer any advice here?
    Thanks
    S

    Order product | Platform, language swap
    For anything else you need to contact support by web chat.
    Mylenium

  • I noticed this morning that someone had accessed my calendar and put a letter in there, it was an obvious scam as it was from outside and asking for money, how will they have accessed it and is there a way of stopping it? I only use my macbook at home

    As above it seems that someone has accessed my calendar
    Not sure how this may have happened, have looked in my security settings and do note that the only program to share my calendar is google Chrome.
    Any ideas how this may have been hacked?
    I never take my macbook away from home and am rural so no driveby issues.
    Its a bit concerning if this can happen

    SORTED IT!!!!
    In calendar preferences it says share with and my share with was also set to gmail
    the scammer send a message with a heading date and time and it popped up in my calendar - turned it off now so not hacked after all just clever on the part of the scammer!!

Maybe you are looking for

  • How to configure Enterprise Manager Database Control (EMDC) to make it work on 2 servers working (primary and standby) under DG rules

    Hello everybody i use Oracle Database EE 11.2.0.4 with DG. In those cases i need to get Enterprise Manager Database Control running against DB with no RAC and no DG i perform the following steps: I Logon SQLPLUS as user SYS or SYSTEM, and drop the sy

  • Delimited text file

    Hi friends,   My requirement is i need to download a tab delimited text file. i am using the below coding but i am able to download a file but it is not coming with delimited. CALL FUNCTION 'GUI_DOWNLOAD'            EXPORTING                 filename

  • Time constraints and Dialog module

    1.What is the difference between the time constraints A(IT exists just once from 01 Jan 1800 to 12 Dec 9999) and B(IT exists for maximum of once from 01 Jan 1800 to 12 Dec 9999)? 2.What is the necessity of dialog module for a Infotype?

  • Subscription renew date Time Zone ?

    Hi All, I need to know what is the Time Zone is the subscription date. i had used all the credits and the subscription was auto renewed on 3rd Feb and the subscription date is 6th Feb, but i still dont have any credits to call. What will the credits

  • MSI 975X PUE + MSI StarHub 7-port USB 2.0 + Windows XP SP3 = Fail

    Hi, today I bought a MSI StarHub and connected it to my computer with MSI 975X PUE and Win XP SP3. But XP does not recognize the hub. On the same computer I have Win 7 installed. There the hub works very well. Any hints to get the hub working on XP?