Getting Turnover Year to Date amount in Sales Order

Hi Experts
I would like to be able to have a UDF on Sales Order which shows Sales the Turnover Year to Date for the BP.
I have created a UDF which is formatted as an amount field and a formatted search with the following syntax.  it is essentially a calculation of the total of all invoices minus credit notes:
(select (select sum(t1.doctotal) - sum(t1.vatsum) from oinv t1 where (t1.cardcode = t0.cardcode) AND ((T1.[docdate]>='01.01.09') AND (T1.[docdate]<=GETDATE())))
- (select sum(t2.doctotal) - sum(t2.vatsum) from orin t2 where (t2.cardcode = t0.cardcode)  AND ((T2.[docdate]>='01.01.09') AND (T2.[docdate]<=GETDATE()))))
from OCRD T0  INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
WHERE T0.[CardCode] = $[$4.1.0]
it is working for me unfortunately and I hope one of the experts can tell me where I am going wrong?
Thanks
Jon

Hi
Try this,
DECLARE @a Numeric(19,6)
DECLARE @b Numeric(19,6)
Set @a = Select (SUM(T1.DocTotal) - SUM(T1.VATSUM))
FROM  OCRD T0
INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
WHERE T0.CardCode = $[$4.0.0]
AND
T1.DocDate '01/01/2009' AND T1.DocDate<= 'GETDATE()'
Set @B = Select SUM(T2.DocTotal) - SUM(T2.VATSUM)
FROM OCRD T0
INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
WHERE T0.CardCode = $[$4.0.0]
AND
T2.DocDate>= '01/01/2009' AND T2.DocDate<= 'GETDATE()'
SELECT (@a-@b)
Regards,
Madhan.

Similar Messages

  • Scehdule Line Date getting change to future date once the Sales Order is saved

    Hello Experts,
    Good Morning to you all,
    This is with respect to the Issue we are facing for the Orders having Product Allocation on multiple materials. Please find enclosed the detials below.
    Issue : Scehdule Line Date getting change to future date once the Sales Order is saved. These Order's are having Product Allocation on multiple materials.
    Description:
    We have implemented Product Allocation few months back.
    We have Product Allocation on multiple materials which are in demand and has been reserved for the Customers of different PA behaviors.
    When we are trying to create the Sales Orders for the normal customer who is not on Product Allocation. The Order Schedule Line is getting changed to future date once the Sales Order is saved after initial creation.
    These Order's are having materials of Product Allocation.
    I have enclosed the sample screen shot of the error we are getting which saving the Sales Order and also the Order Schedule Line screen shot showing future date.
    Error Message : There may be Product Over Allocation in Delivery Group 001.
    Message No : VV023
    This is a random behavior we are coming across and out of 10 Order 2 or 3 Orders is getting this Issue.
    Please share your inputs how to rack this Issue.
    Your suggestions will be highly appreciated.
    I am unable to upload the attacments dont know what the reason.
    Thanks,
    Farhan.

    Check whether you need to carry out the coding corrections as recommended in the following note:-
    Note 52067 - Message VV023/VV024, but no prod.alloc.processing    
    But I wonder this is for older versions and not sure whether this would help you to overcome from the issue.
    G. Lakshmipathi

  • Unable to change requested delivery date in the sales order at item level.

    The issue is when I create order with one material (linked to network and project is created automatically in the background), I am able to change (in change mode) req delivery date for an item, but when I create order with 2 materials (linked to network and project is created automatically in the background), I can not change (in change mode) the req delivery date of any item. Req delivery date is then copied from the header req delivery date.
    Is this a standard SAP functionality or a defect?

    Req del date is the date requested by customer and  can be changed at item level. Probably the confirmed date in the schedule line is derived from the network scheduling after ATP check. (ATP check is not activated in this case)
    I am able to change the req del date at item level if there is only one item (Linked to network) and not when there are two line items (Both are linked to 2 diff networks belonging to same project)
    I tried to change the date in the network, scheduled and saved but that didnt change the date in the sales order. On the contrary, if I run ATP check, netowrk dates get back to original dates derived from sales order.

  • How To Get The Total Delivered Quantity of a Sales Order

    Hello All,
    I have a requirement of getting the total delivery quantity of the sales order .I have checked it in LIps table but I am getting partially delivered quantity for a schedule line item.Can any one tell me how to get the total delivered quantity.
    Regards,
    Pavani.

    Hi
    Check the Table:
    VBEP  - Sales Document: Schedule Line Data.
    Inside the table check the Quantity Fields.
    Regards,
    Sreeram

  • Is it posible to find out the billing date of any sales order..?

    Hi all,
    Is it posible to find out the billing date of any sales order..?
    If it is posible tell  me how to do.
    Thanks

    Hi ,
    Can you explain more on this.
    I think you want to know billing date for the sales order. Here the billing is already done.
    If so , go to vbfa table and then give the sales order number in VBELV field. You will get many records. But VBTYP_N give as M ( Invoice ) and find out the document number and then pass it in billing table VBRK and get the date of creation.
    If it is like proposed date while creating the sales order ,
    then i am not sure about it.
    Regards,
    Venkatesh

  • Third Party process - billing date change in Sales order / Customer Invoice

    Dear Friends,
    In Third Party Sales Process , as we are aware  billing is order related billing and it will become due only after vendor invoice is received.
                   My situation is in the original sales order billing date is eg: 01.02.2009 . The subsequent vendor invoice ( Invoice receipt done based on PR --> and PO)  has a later date eg: 05.02.2009 .
    This means that the customer biling can be done only after this date.  
    How the system behaves in this case wrt to the billing date ( 01/02/2009) of the original sales order.
    Regards
    Mahesh
    Edited by: Mahesh sap on Feb 4, 2009 8:55 AM

    Hi all ,
             Thanx all for your responses . But my case is a bit peculiar . Here the vendor invoice is coming by IDoc through EDI . When EDI flow is confirmed, the billing date is pushed ahead. As per billing calendar  in CMR the customer can be invoiced only on the last date of the month. 
    As a result if the original billing date in the sales order is Feb end, when vendor invoice received through EDI , the billing date is shifting to march end .
    Is it because the date of vendor invoice is causing this?  Obviously the customer billing date falls only after vendor invoice date.
    Regards
    Mahesh

  • I want to pick up Schedule line Delivery date based on Sales Order of Mater

    Hi Experts,
    I have one scenario like,
    I want to pick up Schedule line Delivery date based on Sales Order of Material.
    For example :
    Go to va03
    Give the order no
    Press the enter
    Double click on material.
    Go to Schedule line Tab
    Then we can find out the Delivery date .
    I want to pick up the that Delivery date. Could you please help on that.
    Thanks,
    Amjad.

    Hi,
    schedule line dates are available in VBEP.
    VBEP-VBELN = sales order number.
    VBEP-EDATU = schedule line date.
    REgards,
    Raghavendra

  • Material Availabilty Date Determination in Sales Order

    Hi Gurus,
    When creating the sales order, if stock is not available then how the material availability date is determined.
    What are the inputs the system consider for calculating the material availability date.
    Even though I am giving the total replenishment leadtime, Inhouse processing time(Lot size independent), GR processing time and even the planned delivery time, the system proposing the current date as material availability date irrespective of the sales order quantity.
    All responses will be rewarded suitably.
    Thanks and Regards,
    Jejesh.
    Edited by: jejesh yal on Sep 12, 2008 6:33 PM

    Available checking rule in SD.
    It depends on the Availability group you have maintained in material master.
    The checking rule specifies the scope of the availability check for the respective transactions in sales and distribution by specifying precisely which stocks, receipt and issue elements should be taken into account during the availability check.
    Every checking rule is allocated to a checking group: together these two elements determine the final inspection requirements. In addition, the checking rule includes a specification whether or not an availability check should take into account the replenishment lead time ( i.e. Total time for the in-house production or for the external procurement of a product. In in-house production the replenishment lead time is determined to cover all BOM levels.)
    Items for which the delivery date falls within the replenishment lead time, but for which there is no inventory, are confirmed for delivery after the replenishment lead time. In the case of items for which the delivery date falls after the end of the replenishment lead time, the system assumes that everything can be confirmed.
    If you want the system to check the replenishment lead time, you should make sure that you have entered a value in at least one of the following three fields in the material master:
    GR (goods receipt) processing time (Purchasing view)
    Planned delivery time (MRP I view)
    GR processing time (MRP II view)
    Otherwise, the system confirms every requirement.
    Ava checking group what you have maintained in material master and the checking rule  for SD (in std system is A)
    --combination of above will decide how the ava check to be carried out and decide the delivery date. This sitting is available in SPRO in OVZ9.
    If you carry out the availability check using the replenishment lead time, you should plan ahead in regular intervals (on a daily basis for individual and daily requirements, on a weekly basis for weekly requirements) to prevent a shortage and therefore a possible delivery block. This shortage could occur if the delivery date of a sales order, which was confirmed the previous day for the replenishment lead time, is already within the replenishment period on the current day and therefore results in a shortage.
    Hence,
    1. Check the configurations for the checking groups which are contained in the standard SAP R/3 System.
    2. Make sure that the checking group is maintained in the material master records. Depending on the plant, you can specify a checking group for each material type
    3. Select the individual stock elements as well as the receipts and issues which should be taken into account during the availability check.
    4. Select the field for replenishment lead time if you do NOT want to take the replenishment lead time into account.
    Depending on above setting delivery date will e determined or delivery block in case no qty available can be designed.

  • How can we get purchase req. no in third party sales order

    Hi,
    I am creating third party order scenario, where i can get purchase req. no in third party sales order.
    Regards,
    M B Raju

    HI
    Once you save the Sale order then go to VA02
    Double click on the Line item , click on the schedule line tab
    under Schedule line tab  you can see the Purchase Req. number
    Regards,
    Prasanna

  • FM for Updating Installation date in Contracts + sales orders Item level

    Hi
    Plesae give any FM for Updating Installation date in Contracts + sales orders Item level for contracts tab.
    Thanks and Regards,
    Vishnuvardhan....

    Have used the billing transaction to set a Default Billing date at time of blling.

  • User Exit/Badi to change the billing plan date when create sale order

    Experts,
    Please advise which user exit/badi can be used to change the billing plan date wen create sale order.
    My requriement is based on some rules to dynamically change the line item billing plan start date and end date when create sales order.
    I tried some user eixt in MV45AFZZ, but the date got revert to the orginal date from billing plan.

    Hi,
      check the include MV45AFZB.
    Thanks & Regards,
    Sateesh.

  • Require a dummy date in a sale order

    Hi gurus,
    I require a dummy date in a sales order for entering a date on which letter of indent has come to end user. This date should also appear in tcode va05.
    U can also specify a date which is not used for regular purpose in a std order.
    Note:
    USER EXIT should't be used.
    regards,
    vimal

    hi,
    check these fields in vbap STDAT, STADAT. in vbkd FBUDA, VALDT, BSTDK. i think its not mandatory for u to use a date kind of data type certain kinds of fields can be used as date even though they are not date data types- consult ur ABAP consul for this. morevover its really for you to find out which fields are avalible to you as u are the best judge of teh business process.
    saurabh

  • Additional Data A in Sales order Item....

    Hi,
    Where to Configure fields(Material Group1,Material Group 2) in Additional data A in Sales Order Item level??? so that user can select it from Dropdown list.
    Any impact on Busines Process???
    Regards,
    Amol

    Hi Amol,
    The path for configuring these material groups is:
    SPRO>Logistics-General>Materail master>Settings for key fields>Data relevant to sales and distribution-->Define material groups.
    Here you can define the material groups and for each group you can define the values also. by double clicking on the groups.
    No,It willnot have any impact on the business process at all.
    Regards,
    Krishna.

  • Delivery date on the sales order

    Hi frnds
    I am facing an issue here. When the sales order comes of credit hold the system proposes a new delivery date in the sales order. How can i change the settings to avoid the system from assigning weekends(Saturday & Sunday) as the delivery date????
    I have checked that the factory calendar is set for weekdays only and also the propose del date is check marked in VOV8, OVX5 & OX10 have factory calendar asssigned but i am not able to figure out how to restrict the delivery date to weekdays to be proposed by the system.!!!
    Am i missing something???
    Will appreciate your suggestions.
    null

    Hi,
    The fields needs to be activated in the filed group in accounting.
    The path is SPRO -> Financial accouting -> Accounts Receivables and Accounts Payables -> Customer accounts -> Master data -> Preparations for creating Customer master data -> Define account groups with screen layout.
    Shiva

  • Where do we have Fixed date field  in sales order

    Hi All,
    Where do we have the field "fixed date" in the sales order,
    What is the relevance of the field.
    Thanks in Advance,
    Regards
    Jai

    Hi,
    The fixed date field is available at sales order -> line item -> scheudle line tab. (VBAP-FIXMG).
    If you click on F1 button on this field you can see the user of it.
    From F1 help;
    Delivery date and quantity fixed
    Indicates whether you want to fix the delivery dates and quantities that are confirmed after an availability check for the item.
    Use
    You use this field if you cannot confirm the delivery date or quantity that the customer initially requests.
    Procedure
    If the customer accepts the delivery and quantity confirmed by the system, mark the field. The system then passes on MRP requirements so that the confirmed date and quantity can be met.
    Note
    If you leave the field blank, the delivery date and confirmed quantity are not fixed. If you are able to expedite either the manufacture or purchase of goods, you may be able to deliver the goods closer to the customer's original request (and sooner than the date the system confirmed).
    Regards,
    PS: Can you please close your previous postings, if you feel answered.

Maybe you are looking for