SQL Report combining Sales Invoices & Sales Credit Notes

Hi Experts
As a novice at the SQL game, I was looking to produce a single report of all sales invoice/credit note lines where the product code began with "tel" in a given date range for the selected account manager
I've managed to complete this for Invoicing but despite best efforts, I cannot combine Credit Notes into the report. Can you help please?
My SQL is as follows
SELECT DISTINCT T0.[DocNum], T0.[DocType], T0.[DocDate],T0.[CardCode], T0.[CardName],  T1.[ItemCode], T1.[Dscription], T1.[LineTotal]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode INNER JOIN ORIN T3 ON T2.SlpCode = T3.SlpCode INNER JOIN RIN1 T4 ON T3.DocEntry = T4.DocEntry
WHERE T1.[ItemCode] Like 'TEL%%' and T0.[DocDate] >= '[%1]' AND T0.[DocDate] <= '[%2]' AND T2.[SlpName] = [%']
Thanks
Derek

Hi,
Check the following :
SELECT  DISTINCT T0.[DocNum], 'AR INVOICE', T0.[DocType], T0.[DocDate],T0.[CardCode], T0.[CardName],  T1.[ItemCode], T1.[Dscription], T1.[LineTotal]
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
WHERE T1.[ItemCode] Like 'TEL%' and T0.[DocDate] >= '[%1]' AND T0.[DocDate] <= '[%2]' AND T2.[SlpName] = '[%3]'
UNION ALL
SELECT  DISTINCT T0.[DocNum], 'AR CREDIT MEMO', T0.[DocType], T0.[DocDate],T0.[CardCode], T0.[CardName],  T1.[ItemCode], T1.[Dscription], T1.[LineTotal]
FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
WHERE T1.[ItemCode] Like 'TEL%' and T0.[DocDate] >= '[%3]' AND T0.[DocDate] <= '[%4]' AND T2.[SlpName] = '[%3]'
Run the query in Query Generator.
Kind Regards,
Jitin
SAP Business One Forum Team

Similar Messages

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

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

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

  • Block return sales orders or credit notes?

    Hi,
    Could someone please explain how I block return sales orders or credit notes?
    Also is there a way of searching which sales order documet types have been used for credit notes?
    Thanks

    Hi Friend,
    The billing block is comming from the tx. VOV8 -> choose the Order type  -> billing
    block -> you could set billing block here.
    In Shipping column, there is also a field Delivery block where you could set delivery
    block for the order type.
    Or you could also set delivery block and billing block manually when you create the order.
    You could check order type which is used as return or credit memo request by following way:
    SE16 -> TVAK -> use selection criteria VBTYP = H and K
    H  Returns
    K  Credit memo request
    Then excecute, you could get the order type you want.
    Best regards,
    Alex

  • Billing block for invoices and credit notes on Sold-tou00B4s level

    Hi All
    can we have billing block for invoices and credit notes on Sold-to´s level.
    please advice.
    Thanks
    Tushar

    Hi
    The bellow way at document level.
    One more way to maintian the billing block in the functionality of sales document types in VOV8
    In VOV8 , Maintain proper value in billing block field.
    So that , when you create the order or credit memo request system automatically pick the billing block.
    Once remove the block of billling then only system allow to create the billing or credit memo.
    Thanks,
    KP
    Edited by: phanik2503 on Mar 2, 2010 6:46 AM

  • Invoice and Credit Notes

    Hi Guys,
    I am trying to do a query that shows all the Invoices and Credit Notes Posted from a specific Date. So far I have come up with this, however It is not returning the correct Information and I need to show the document type as either an Invoice or Credit Note, can anyone assist me with this ? It is Important for me to have the DocEntry in there as I will need to use that in a Crystal Report.
    SELECT  DISTINCT T0.DocNum as 'Invoice/Credit Number', T0.DocEntry,T0.DocDate as 'Doc Date',  T0.CardCode as 'Customer Code', T0.CardName as 'Customer Name',T0.VatSumSy as 'VAT', T0.DocTotal as 'Doc Total' FROM OINV T0 WHERE T0.DocDate >=[%0]
    UNION ALL
    SELECT DISTINCT T1.DocNum as 'Invoice/Credit Number', T1.DocEntry, T1.DocDate as ' Doc Date',  T1.CardCode as 'Customer Code', T1.CardName as 'Customer Name',  T1.VatSumSy as 'VAT', T1.DocTotal as 'Doc. Total' FROM ORIN T1 WHERE T1.DocDate >=[%0]
    Help always gratefully appreciated
    Kind regards
    Sean Martin

    Hi,
    You can also check this query :
    Select distinct CASE WHEN T1.transtype = '13' THEN T0.DocNum WHEN T1.transtype = '14' THEN T2.Docnum 
    END as 'Invoice/Credit Number',
    CASE WHEN T1.transtype = '13' THEN T0.DocEntry  WHEN T1.transtype = '14' THEN T2.DocEntry  END,
    CASE WHEN T1.transtype = '13' THEN T0.DocDate  WHEN T1.transtype = '14' THEN  T2.DocDate  END as 'Doc Date',
    CASE WHEN t1.TransType ='13' THEN T0.CardCode  WHEN T1.transtype = '14' THEN T2.Cardcode  END as 'Customer Code',
    CASE WHEN T1.transtype = '13' THEN T0.CardName  WHEN T1.transtype = '14' THEN T2.CardName  END as 'Customer Name',
    CASE WHEN T1.transtype = '13' THEN T0.VatSumSy  WHEN T1.transtype = '14' THEN  T2.Vatsumsy  END as 'VAT',
    CASE WHEN T1.transtype = '13' THEN T0.DocTotal  WHEN T1.transtype = '14' THEN  T2.doctotal  END as 'Doc Total',
    CASE WHEN T1.TransType = '13' THEN 'INVOICE'  WHEN T1.transtype = '14' THEN 'CREDIT MEMO'  END
    from JDT1 T1
    LEFT join OINV T0 on T1.transid = T0.transid and t0.DocDate >= '[%1]'
    LEFT join ORIN T2 on T2.transid = T1.transid and  t2.DocDate >= '[%2'
    where T1.TransType in ('13','14')
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Invoice and credit note processing

    Hello all,
    I have got a query with respect to transaction MRBR (Remove Block on invoice). The process that we follow is:
    1) When AP clerk enters invoice, he enters the invoice with a 'R' block. This blocks the invoice from getting paid.
    2) Every evening there is a background job scheduled with transaction MRBR. What this job does is removes the 'R' block from the invoice if it has got a corresponding GR.
    3) This invoice then appears in the payment run and is paid off.
    The problem with this process is when the credit notes are raised on account. We link the credit notes and invoices by copying the document number of invoice in the 'invoice reference' field while entering the credit note. The 'R' block also gets copied onto the credit note (if the invoice has the block). Transction MRBR runs overnight and removes the block from the invocie (if it has a corresponding GR) and the invoice becomes free for payment. However there is no parameter in the program to remove the block from the credit note as well. What eventually happens is that the invoice becomes free for payment, the credit note remains 'R' blocked and hence does not appear in the payment run to offset the invoice and the invoice gets paid off even though it had a credit note.
    Is anyone aware of how to remove the 'R' block from the credit note or if there is a better process to work with invoice and credit notes.
    Thanks for all your help
    Regards
    Keyur

    Hi,
    I also think that there is no need for putting a R block in the credit note at all. 
    The process should be like below:
    1. Invoice posted before GR - Invoice should be automatically blocked if the tolerance keys are set up properly (transaction code OMR6).  I am not sure why you have to put the R block manually.
    2. Post credit note - do not put any kind of block.  Make sure that you are referencing the credit note to the earlier posted invoice or the the relevant PO line item.
    3. MRBR matches and releases the invoice.
    4. When you run F110, it should automatically clear the invoice, credit note and make payment for the rest.

  • Remove invoice and credit note block

    Hello all,
    I have got a query with respect to transaction MRBR (Remove Block on invoice). The process that we follow is:
    1) When AP clerk enters invoice, he enters the invoice with a 'R' block. This blocks the invoice from getting paid.
    2) Every evening there is a background job scheduled with transaction MRBR. What this job does is removes the 'R' block from the invoice if it has got a corresponding GR.
    3) This invoice then appears in the payment run and is paid off.
    The problem with this process is when the credit notes are raised on account. We link the credit notes and invoices by copying the document number of invoice in the 'invoice reference' field while entering the credit note. The 'R' block also gets copied onto the credit note (if the invoice has the block). Transction MRBR runs overnight and removes the block from the invocie (if it has a corresponding GR) and the invoice becomes free for payment. However there is no parameter in the program to remove the block from the credit note as well. What eventually happens is that the invoice becomes free for payment, the credit note remains 'R' blocked and hence does not appear in the payment run to offset the invoice and the invoice gets paid off even though it had a credit note.
    Is anyone aware of how to remove the 'R' block from the credit note or if there is a better process to work with invoice and credit notes.
    Thanks for all your help
    Regards
    Keyur

    normally, credit memo should be able to remove the block manually as soon as they are put in the sap.
    they should not be mixed with other AP invoices.
    and if the credit memo need to be paid, then it should have something like approval doc to support the block removing.
    if it is just reversal doc against wrong doc, then also need remove the block by supervisor asap.
    Edited by: JiQing Zhao on Apr 19, 2011 10:17 AM

  • FSCM-COL: Worklist separated by invoices and credit notes

    Hi all,
    We are implementing FSCM-COL and in the u2018Process Receivablesu2019 screen, in the tab "Invoices", there is a split between invoices and credit notes,in two separate lists. The documents are not displayed together!
    As a basic requirement for a collection contact, a single list is required, in order to be possible to sort all open items and enable
    greater efficiency during the customer contact.
    Do you know how this separation is done (by posting key for instance...?) and if we can change this....
    Or this is standard functionality of the worklist ?
    Thanks for your inputs,
    Best Regards,
    Bruno Sousa

    This is standard.
    Credits are normally a different colour.
    The worklist should be used by the team to define what the customers owe's and what they should pay.
    Total overdue - disputed items not resolved = amount to be collected.

  • Printing messages in invoices and credit notes

    Hi Sap gurus,
    The printing messages in invoices and credit notes must be changed due to a new law.
    Does anybody know the transaction used for this, please?
    Regards,
    Roger

    Hi Roger
    You can change the forms by SE71 transaction. 
    thanks
    Ashok
    Assign points for useful answer

  • Invoice and Credit note posting not matching

    Hi All,
    An invoice was issued with two items so the credit note in reference to that invoice (to reverse the invoice) has been issued item wise. The problem is that the amount of credit note and the invoice is not matching so the posting does not clear.
    Any idea, what could be the reason. Its critical to business so urgent.
    People with similar problem too are requested to share their experience.
    Regd
    Vk

    Hi Vinay,
    go to copy control from the invoice type to credit memo type. In the 'item' level, Chevk out the 'pricing type' field. If u want the same old values from the invoice as it is, then use the pricing type as 'D'. This will copy all values unchanging them.
    This will solve ur problem.
    Regards,
    Prashant

  • Mismatch between invoice and credit note

    Hi Gurus,
    We have made an credit note,5xxxxxxxx12, to cancel an invoice 5xxxxxxxx10. However the values on the corresponding accounting documents are different (USD  8000,02- and 7992,46), so we cannot match the two documents.
    Please advice me how to match these two documents.

    Hi shivaji,
    What is the reason for the difference in the amount. you may have to manually clear the documents using transaction F-03 or F-32 and post the difference manually.
    Regards
    Mahendra
    Assign points if this helps

  • How to Removed VAT during DTW upload for Invoices and Credit Notes

    Hi Experts
    Please help.
    Every time I import AR Invoice and  Ar credit Notes there is an automatic posting to VAT  even if the template has the same price after VAT and zero discount.
    How to removed this?
    Regards,
    Sandra

    Hi Julie
    As requested. The SO is VAT code for nonvat or zero vat
    As requested
    Header
    RecordKey     DocEntry     CardCode     CardName     Comments     DiscountPercent     DocCurrency     DocDate     DocDueDate     DocNum     DocRate     DocTime      DocTotal      DocType     JournalMemo     NumAtCard     Reference1     Reference2     Series     TaxDate
    1     TRUE     MC002 A     ABENSON INC.                    20090930     20060428          1           13,950.0000      dDocument_Service       OB AR Invoices 09.30.09     SI#044792          SI#044792          20060227
    Lines/Details
    RecordKey     LineNum     AccountCode      LineTotal      VatGroup
    RecordKey     LineNum     AccountCode      LineTotal      VatGroup
    1          392000000     13,950.00      SO
    Regards,
    Amy

  • Relation between Proforma Invoice and Credit Note Number

    Hi,
    Could you please tell me how i can link the proforma invoice number with credit note number.
    I have proroma invoice number. I want to find its corresponding credit note number.
    Kindly help.
    Regards
    Sachin

    there wont be any entry in BKPF as this is proforma invoice...
    i tried to link by VBFA but no sucess...
    Kindly help..

  • Report to to get  suppliers credit notes listed by material, purchase order

    Hello,
    Is there a way to get a listing of all suppliers credit notes listed by material, purchase order.
    Thanks.

    Hi Veera,
    I have understood following things from your answer(Correct me if I m wrong)
    1.Purchase Order is not auto-updateable ie even if we make changes in Master Data in Data Manager, PO will not reflect those changes.
    2.Whenever I merge two records and create third one, I need to create identifier which will store reference of these two material nos and I wiil have to manually make changes in PO.
    However, what will happen when you delete the particular material in Data Manager and it is being referred in Purchase Order created in SAP R3?
    Also, what is going to happen when you just make changes in few fields of a material record and same material is referred iN PO in SAP R3?
    how to track these changes??
    Regards,
    Joe.

  • Printing different Invoices or Credit Notes series

    Hi,
    I have two types of series on Credit Notes. One is called for example "Credit Note" and the other is called "Debit Note". On PLD, how can I do to print "Debit Note" on the layout when it's a Debit Note series and to print "Credit Note" when it's a credit note series?

    Well, I've made it through some formulas on PLD and associations between fields, but thanks anyway.
    Regards,
    Pedro Santos

Maybe you are looking for

  • Adding Custom Fields for Change Request in EHS

    Hi, I need to add custom fields in Change request screen, where I am not able to identify for BO and node to do same. Its Configuration name  /MOC/F_ISS_ROOT_OBJECT_INFO. I tried with /IAM/ISSUE and /IAM/ACTIVITY BO.. but it is not working. Not able

  • Call Ref cursors in DAAB

    Hi, I have one procedure in Oracle which is returning the REF Cursor I am accessing it by using the Data access application block DAAB like the following: OracleParameter param = new OracleParameter(); param.ParameterName = "Emp_Cursor"; param.Oracle

  • Pasted text is always plain

    Hi folks, Whenever I paste a section of text into a message from, say, a website that has been formatted a certain way, Mail always turns it into plain text. I checked the compose preferences and it says that it's on Rich Text Format. I can change th

  • How edit DVCPro HD and HDV footage in the same multi-clip project?

    Dear All I am to edit a music video material shot with two cameras. I received the footage as .mov files, but one file is a DVCPro HD 1080i50 codec and the other is a HDV 1080i50 codec. - It seems the music concert was recorded on two different camer

  • BI Professional Level Certification

    Locking this thread since this will start link farms ... Hello Experts, I am an associate level certified BI consultant. I aspire for professional level certification as well. I need guidance on how to go about it. Any streamlined preparation guideli