Sales Analysis with AR Downpayment Invoice

Hi all
Please help if you know how to rectify this customised stored procedure for Sales Analysis Crystal Report.
It does not reflect the Sales amount for AR Invoice that is linked to a fully paid Downpayment Invoice.
[SBODemoSG]
ANSI_NULLS ON
QUOTED_IDENTIFIER ON
PROC [dbo].[GPbySP]
datetime, @DateTo datetime, @SlpFrom nvarchar(20), @SlpTo nvarchar(20)
'IN' as DocType, T0.DocNum, T0.DocDate, T1.CardName, T0.DocCur, T0.DocRate,
WHEN T0.DocCur=(SELECT TOP 1 T10.MainCurncy FROM OADM T10) THEN T0.DocTotal ELSE T0.DocTotalFC END as 'DocAmt',
.DocTotal-T0.VatSum as 'DocTotalBefTax', T0.VatSum, T0.DocTotal,
.ItemCode, T3.ItemName, T2.Quantity, T2.LineTotal, T2.GrossBuyPr as 'ItemCost', T2.GrssProfit, T5.SlpName, T5.SlpCode,
.GrosProfit
OINV T0
JOIN OCRD T1 ON T0.CardCode=T1.CardCode
JOIN INV1 T2 ON T0.DocEntry=T2.DocEntry
JOIN OITM T3 ON T2.ItemCode=T3.ItemCode
JOIN OITB T4 ON T3.ItmsGrpCod=T4.ItmsGrpCod
JOIN OSLP T5 ON T0.SlpCode=T5.SlpCode
T0.DocDate BETWEEN @DateFrom AND @DateTo AND T5.SlpName BETWEEN @SlpFrom AND @SlpTo
ALL
'CN' as DocType, T0.DocNum, T0.DocDate, T1.CardName, T0.DocCur, T0.DocRate,
WHEN T0.DocCur=(SELECT TOP 1 T10.MainCurncy FROM OADM T10) THEN T0.DocTotal*-1 ELSE T0.DocTotalFC*-1 END as 'DocAmt',
T0.DocTotal-T0.VatSum)*-1 as 'DocTotalBefTax', T0.VatSum*-1, T0.DocTotal*-1,
.ItemCode, T3.ItemName, T2.Quantity*-1, T2.LineTotal*-1, T2.GrossBuyPr*-1 as 'ItemCost', T2.GrssProfit*-1, T5.SlpName, T5.SlpCode,
.GrosProfit*-1
ORIN T0
JOIN OCRD T1 ON T0.CardCode=T1.CardCode
JOIN RIN1 T2 ON T0.DocEntry=T2.DocEntry
JOIN OITM T3 ON T2.ItemCode=T3.ItemCode
JOIN OITB T4 ON T3.ItmsGrpCod=T4.ItmsGrpCod
JOIN OSLP T5 ON T0.SlpCode=T5.SlpCode
T0.DocDate BETWEEN @DateFrom AND @DateTo AND T5.SlpName BETWEEN @SlpFrom AND @SlpTo

Hi,
Try to add below portion in above query with union:
'DP' as DocType, T0.DocNum, T0.DocDate, T1.CardName, T0.DocCur, T0.DocRate,
WHEN T0.DocCur=(SELECT TOP 1 T10.MainCurncy FROM OADM T10) THEN T0.DocTotal*-1 ELSE T0.DocTotalFC*-1 END as 'DocAmt',
T0.DocTotal-T0.VatSum)*-1 as 'DocTotalBefTax', T0.VatSum*-1, T0.DocTotal*-1,
.ItemCode, T3.ItemName, T2.Quantity*-1, T2.LineTotal*-1, T2.GrossBuyPr*-1 as 'ItemCost', T2.GrssProfit*-1, T5.SlpName, T5.SlpCode,
.GrosProfit*-1
ODPI T0
JOIN OCRD T1 ON T0.CardCode=T1.CardCode
JOIN RIN1 T2 ON T0.DocEntry=T2.DocEntry
JOIN OITM T3 ON T2.ItemCode=T3.ItemCode
JOIN OITB T4 ON T3.ItmsGrpCod=T4.ItmsGrpCod
JOIN OSLP T5 ON T0.SlpCode=T5.SlpCode
T0.DocDate BETWEEN @DateFrom AND @DateTo AND T5.SlpName BETWEEN @SlpFrom AND @SlpTo
Thanks & Regards,
Nagarajan

Similar Messages

  • Return sales order( with ref. to Invoice) need to have less quantity

    Hi Friends,
    Here one issue is coming while creating a return sales order with ref. to  invoice.
    Example is:
    In original invoice an article X is of price 10 having 10 quantity and hence total price 100.
    but now customer wish to return only 5 articles and creating this Retun sales order with refernce to this invice
    now in return sales order quantity is coming correct i.e 5 but the amount is still the same i.e 100.
    But this should be 50( 5*10).
    Please can someone help to find the reason why the price is not changing while quantity is changing.
    I have already check the copy control but there also setting seems to be correct.
    Also when i try to update the pricing via condition tab the price got changed. but that is manually.
    Thanks
    Punit.

    Thanks Jignesh,
    But can you please tell which pricing input should be the best.
    As "price redetermine" option can't be selected as price keep changing.
    also i did that for "same price and redetermine tax" but doesn't seems to be working.
    Please if you can suggest any option where the price of the article will be same (the old one when article was sold) as proportionate to quantity without redetermining the price.
    like article x has qty 10 and price 10 hence amount 100
    but later price of article change to 11
    then if i chose redetermine price then for five article this will be 55 which is again wrong( it should be 50 as at the time of sale the price was 10)
    Hope I made the issue clear enough. Which setting in pricing one can recommend.
    Regards
    Punit
    Thanks

  • CREATE SALES ORDER WITH REFERENCE TO INVOICE USING RECORDING

    Hi,
    I wanted to know if it was possible to create a sales order with reference to an invoice using recording(SHDB transaction).If there is some other method please explain the method in detail(Its very urgent)

    Hi,
    You should be able to use BAPI_SALESORDER_CREATEFROMDAT2 instead of doing a BDC and you can populate the reference document in the relevant header field.
    Gareth.

  • SALES ORDER WITH REFERENCE TO INVOICE

    I need to create a sales order with reference to an invoice which is called a credit memo request.Which method is better?Can we do recording using SHDB for VA01 transaction by clicking on the create with reference tab in VA01 and performing the recording or do we need to use BAPI.Please explain both the  methods if possible

    Use the BAPI: BAPI_CUSTOMERRETURN_CREATE.
    Regards
    Kannaiah

  • Sales Analysis with Customer Group Name

    Hi,
    Just want to know whether anyone knows how to add the Customer Group Name in SAP Standard Sales Analysis Report?
    I have tried to add in Sales Analysis layout designer, but the value reflected is not correct. E.g. when my customer group criteria is Retail group, but the report layout printed out is Corporate group.
    In layout designer, my source type = database, table = card groups, column = group name. Thanks.
    Regards,
    MH

    I have checked that Sales Analysis Report by Customer - Monthly and by Invoices - by Individual Display should be ok to bring the right group name based on your selection if you put the new field in the right place. (source type = database, table = card groups, column = group name)
    Where do you create this field? What is your B1 version and PL?
    Thanks,
    Gordon

  • Bapi: create sales order with reference to Invoice.

    HI ,
    i am trying to create sales order(credit memo request) with respect to invoice.
    What  BAPI to use. also, please provide with sample code.
    I have passed invoice to BAPI_SALESDOCU_CREATEFROMDATA1 at header level(ref_doc).
    and i am  passing other details correctly. the pricing procedure attched to original invoice is not getting triggered for th newly creating sales order.
    Please help me with this.

    use   BAPI_SALESORDER_CREATEFROMDAT2
    search the forum for sample program

  • Create sales order with refrence to invoice number

    Hi,
    I am creating salesorder using FM SD_SALESDOCUMENT_CREATE in my custom report.
    My requirement is to create a sales order with refrence to a invoice number. Kindly let me know which parameters are need to be passed to this FM to create sales order with refrence to a invoice.
    Regards,
    Rajneesh

    Hi,
    Please I have something similar requirement ot create the sales order from the billing document via Idoc.
    Please let me know if any ideas thanks
    Cheers
    Jasmeet

  • Creating Query to show items from open sales orders with a/p invoice

    Hi experts,
    I am trying to create a query that will show what items/quantities are still in open sales orders that can now be filled by an incoming shipment of goods, processed through the a/p invoice.
    This needs to be done using subqueries, which I have no experience with.  I am trying to do this using the ORDR and RDR1 tables to show the open items from the sales orders and the OPOR and POR1 tables to show items just received in to inventory.  I would like the query to show exactly the open item's, their quantities, the posting date from the sales order and the customer name that can now be filled from the new shipment through the a/p invoice.
    I appreciate the assistance,
    Hayden (on behalf of Todd)

    Hello,
    try this
    SELECT T0.[DocDate], T1.[ItemCode], T1.[Dscription],( T1.[Quantity] - T1.[DelivrdQty]) As "Open Qty" FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDueDate]  <= [%0]And ( T1.[Quantity] - T1.[DelivrdQty]) != 0
    Try this query in query manager.
    Thanks
    Manvendra Singh Niranjan
    Edited by: Manvendra Singh Niranjan on Jul 13, 2011 6:27 AM

  • Vendor aging analysis with name and invoice.....URGENT!!!!!!!!!!!

    Frnds,
    There is a requirement from the client, wherein they need vendor aging analysis along with the invoice number, amount due against each of the invoices that can be seen in the appropriate age period(say a particular invoice amount falls between 30-60 days, and 2 other invoices fall between 60-90days of the same vendor).
    In their legacy system they could get a report with the vendor number, name, due date, invoice #, amount due against each invoice apart from the net amount.
    S_ALR_87012085 , we get the total amount (net), not the breakup with the invoice#.
    in S_ALR_87012082, we dont get to input the no of days
    Is there any way we I can achieve the requirement, plz suggest
    regards
    sandhya

    Hi Venkatesh,
    Thnx a lot for the reply. This has almost solved my problem, however there's one thing left. when I'm trying to take a print out after exporting the info into an excel sheet, the information really looks scattered, i.e.,  is there a way where we can go ahead and get the info in a rather unscattered manner.
    I've tried to take a print directly without actually transferring the info into an excel sheet, then each of the vendor is printed in a separate page, which again they feel is a problem.
    So, if you have an idea pls suggest.
    Thnx again for the information.
    regards
    sandhya

  • Sales Orders And Downpayment Invoices

    Hi,
    I am trying to get a link between the Sales Order and the Downpayment Invoices.
    As I open a Sales Order I cannot directly figure out weather it has a down payment
    invoice or not. (DP Invoices will not show on Target Document Button on the tool bar)
    Is there a way to Find it out??
    When I am going through the ORDR Table I have noticed DpmDrawn, DpmPrcnt, DpmAmnt, DpmAmntFC, DpmAmntSC, Columns.
    DpmDrawn Shows Values 'Y' or 'N' but rest of the fields are just showing default values (null or 0.00)  for every Sales order.
    Is there any setting I have to set up to fill those fields?
    or is there a better way to check that Sales Order has a Downpayment Invoice??
    Thank you very much for your help.

    Hi Suda,
    Thanks for the quick answer. True, that is the way I use to find the DP invoices.
    Problem is no one check it before they generate a new DP invoice for the Sales Order.
    We end up creating few DP invoices for the same Sales order.
    I just want to stop that. Thats why i am trying find out a link between sales order and the
    DP invoice and show it with the Sales order or give a rule.
    Thank you very much for the help.
    Kind Regards
    Sanjaya

  • Quantity appears in Sales Analysis Report when the Drop Ship Warehouse is used

    Dear Experts,
    We would like your help in the following case. We are using SAP Business One 9.0 (PL10)
    When a Sales Invoice document is added to the system using the Drop Ship warehouse, then in the report 'Stock Posting List' it does not display the document, which is correct since a Drop Ship warehouse is used.
    However, the report 'Sales Analysis Report' displays the Invoice, but it also shows the quantity that is used in the document, which is not correct.
    Why is this happening? Is there any setting that excludes the display of the quantity of the document from the 'Sales Analysis Report', when the Drop Ship Warehouse is used?
    Thank you in advance
    Kind Regards,
    Vassilis Korolis

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

  • Sale analysis

    Hi everybody!
    i have any problem about report sale. I sale for customer 5 boxes, each box store 100 Items.
    I want to report in sale analysis with quality is 500 Items. General, Just system show me quality is 5 boxes.
    Can you help me treat this problem!
    Edited by: Rui Pereira on Aug 8, 2008 1:44 PM

    Hello Tien,
    Will Sales type BOM apply to your business need? If you define your BOM as sales type, both parent and child will be shown on sales analysis report once you select those relevant items.
    Production BOM only shows parent quantity in sales analysis.
    Regards,
    Wilma Wang
    SAP Business One Forums Team

  • Error while posting A/R Downpayment Invoice with Excisable Tax Code.

    While posting A/R Dowpayment Invoice with Excisable Tax Code error of "Unbalanced Transaction" appears. This error does not occur while posting A/R Downpayment Invoices with Non-Excisable Tax Codes.
    Kindly provide a solution for the same.

    SAP Note Number: 1179405
    Error -5002 when trying to copy a document with Sales BOM
    In order to create the delivery via the DI, you need to set the oDoc.Lines.BaseLine value to the LineNum value from the RDR1 table (in the above example you should enter the value 2).
    we set oDoc.Lines.BaseLine=0 before starting the lines loop. This has resolved the issue.
    This note was really helpful and it was found in another query.
    You can also refer to this. https://forums.sdn.sap.com/click.jspa?searchID=19070513&messageID=6178079
    Thanks.
    Edited by: Sadanand Manda on Nov 24, 2008 12:16 PM

  • Manually closed DN appear with value 0 on sales analysis - items

    Hello everyone,
    When i manually close a Delivery Note (DN) using Data->Close that DN still appears on my sales analysis -> customer. (using the filter -> Delivery Notes)
    However when i use sales analysis -> items i only get the list of items contained on that DN. All the columns (quantity, sales amount, gross profit, etc) are with zero values.
    Is there any way of showing those values on the sales report? Or any other report? Is this standard system behavior? Shouldn't the items disappear completely then? What is the purpose of showing them without any further information?
    Looking forward to be hearing from you.
    Regards,
    Sérgio Romã

    Hello Gordon,
    Thanks for the quick reply.
    The business process requires me to close the DN manually:
    The customer has something like 4000 employees that are created as customers. Each of those employees has a pre-defined creditline amount. DNotes can be created for each employee until that amount. On the second week of every month i need to close all these DNotes (i am doing this using an addon that runs based on schedule defined in a user table and that closes all DN that meet certain conditions) so that i can add more DNotes to each employee. At the end of every month i have another addon that totals all DN added that month (closed and open) and creates a single service invoice for a customer (defined in each employee).
    So i need to close them manually because i cannot copy them to a consolidation partner (release of employee creditline and invoicing occur at the different moments during the month).
    My disagreament with the system behavior is the following:
    - I get the correct the results if i create a sales analysis -> customer. If they don't result in a sales transaction they shoudn't appear on this report either. (according to the logic you presented)
    - Sales analysis -> Item. The item lines appear with zero. Once again, if it is not a sales transaction they shoudn't appear at all (according to the same logic). The system is doing the same thing as if the DN has been copied to an invoice which is a wrong behavior. This is a different situation and the item detail should be visible on the sales analysis report.
    What do you think?
    Regards,
    Sérgio Romã

  • Sales Analysis Report per Sales Employee with BP Reference No

    Hi All,
    I need your assistance in creating a query that balances back to Sales Analysis Report but I require the BP Reference No to show per row.  I have created 2 queries through Query Generator.  The 1st contains the OINV and OSLP tables with Fields:  DocNum, NumAtCard, SlpName, DocDate, CardCode, CardName, DocTotal
    The 2nd contains the ORIN and OSLP tables withe the same Fields.
    I need to combine these 2 queries and I need assistance with the DocTotal.  I need the amount before tax.
    This report needs to balance back to the SAP B1 Sales Analysis Report.
    Your assistance would be appreciated.
    Regards,
    Desiré Janse van Rensburg

    Thank you for your assistance!  After googling a few pages I came across this query.  I adjusted it to comply to my needs.
    Herewith query if you guys are interested:
    SELECT
    T0.DocNum AS 'Invoice Nr',
    T0.NumAtCard AS 'Customer Ref Nr',
    T1.SlpName AS 'Salesperson',
    --T0.SlpCode AS 'SP Code',
    T0.DocDate AS 'Posting Date',
    T0.CardCode AS 'Customer Code',
    T0.CardName AS 'CustomerName',
    'Credit Memos' AS 'Doc Type',
    ((T0.DocTotal) * -1) AS 'Total Docs',
    (((T0.DocTotal - T0.VatSum) - T0.TotalExpns) * -1) AS 'Product Sales',
    ((T0.GrosProfit) * -1) AS 'Gross Profit',
    CASE
    WHEN (((T0.DocTotal - T0.VatSum) - T0.TotalExpns) * -1) = 0.00 THEN 0.00
    ELSE (((T0.GrosProfit) * -1)/(((T0.DocTotal - T0.VatSum) - T0.TotalExpns) * -1)) * 100
    END AS 'Gross Profit %',
    ((T0.PaidToDate) * -1) AS 'Paid To Date',
    ((T0.DocTotal - T0.PaidToDate) *-1) AS 'Open on Docs'
    FROM ORIN T0
    INNER JOIN OSLP T1
    ON T0.SlpCode = T1.SlpCode
    WHERE
    (T1.SlpName LIKE '%%[%0]%%' OR '[%0]' = ' ')
    AND T0.TaxDate >= '[%1]'
    AND T0.TaxDate <= '[%2]'
    UNION
    SELECT
    T0.DocNum AS 'Invoice Nr',
    T0.NumAtCard AS 'Customer Ref Nr',
    T1.SlpName AS 'Salesperson',
    --T0.SlpCode AS 'SP Code',
    T0.DocDate AS 'Posting Date',
    T0.CardCode AS 'Customer Code',
    T0.CardName AS 'CustomerName',
    'Invoices' AS 'Doc Type',
    (T0.DocTotal) AS 'Total Docs',
    ((T0.DocTotal - T0.VatSum) - T0.TotalExpns) AS 'Product Sales',
    (T0.GrosProfit) AS 'Gross Profit',
    CASE
    WHEN (((T0.DocTotal - T0.VatSum) - T0.TotalExpns)) = 0.00 THEN 0.00
    ELSE ((T0.GrosProfit)/((T0.DocTotal - T0.VatSum) - T0.TotalExpns)) * 100
    END AS 'Gross Profit %',
    (T0.PaidToDate) AS 'Paid To Date',
    (T0.DocTotal - T0.PaidToDate) AS 'Open on Docs'
    FROM OINV T0
    INNER JOIN OSLP T1
    ON T0.SlpCode = T1.SlpCode
    WHERE
    (T1.SlpName LIKE '%%[%0]%%' OR '[%0]' = ' ')
    AND T0.TaxDate >= '[%1]'
    AND T0.TaxDate <= '[%2]'
    Thanks again for the replies!

Maybe you are looking for

  • After changing 'MS SQL server' service's user name SDAC doesn't work properly

    I've changed 'MS SQL Server' service user name from .\admin (have had such already) to network_services and now my oracle linked servers to Oracle instance stopped to work. Namely, 'Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for l

  • The labels and text fileld are not hiden by jXDatePicker

    Hello When i click on the drop-down jXDatePicker, labels and thet fields (taht are under jXDatePicker in the form ) show over the calendar- the ables and text filelds are displayed onto the calendar. Is there some ideas what could be the problem and

  • Lenovo Thinkpad Twist touchscreen issue

    Does anybody have any expirience with setting up the touchscreen on the thinkpad twist? I assume that I am having  a kernel moduel issue because it does not show up in xinput (it did however show up in ubuntu as atmel maxtouch digitizer, and works wi

  • Why are EPS files preferred when dropping a logo into a publication?

    I need to send a logo to several printers who will be dropping it into publications that they produce for my client.  Most of the printers have requested EPS files.  Can someone explain why EPS seems to be the preferred file format in this situation?

  • Reg: Arrow to navigate different contracts in adobe form

    Hi, When there are multiple contracts, multiple reports are generated and there is an arrow to navigate between the contracts  in top of PDF form how can we add a counter to show what that the user is viewing contract 1 of 6 How can we handle this. R