Cost Price for Returns order adopting cost from preceding billing doc

Hi Forum Experts,
Our Returns Order (SO) currently obtains cost price (VPRS) based on material moving average price.
However, what we really need is to copy the cost price from the preceding Billing Document.
I've explored using VOFM and created a routine under (Formulas --> Condition Value) as per below.
I found that while the debugger steps through this code, the value of the cost gets copied from the preceding document.
However, immediately after the code finishes execution, the value gets resetted back to the material moving average price again.
What can I do do let the system keep the copied cost price from the preceding document instead?
FORM FRM_KONDI_WERT_998.
DATA: lv_kbetr TYPE kbetr,
      ls_vbfa  TYPE vbfa,
      lv_knumv TYPE knumv.
IF SY-TCODE = 'VA01' OR SY-TCODE = 'VA02' OR
       SY-TCODE = 'VA21' OR SY-TCODE = 'VA22'.
IF xkomv-kschl EQ 'VPRS'.
Get billing doc and position
SELECT SINGLE vbelv posnv
INTO corresponding fields of ls_vbfa
FROM vbfa
WHERE vbeln EQ komp-aubel "returns order number
AND posnn EQ komp-aupos "returns order item
AND vbtyp_n EQ 'H' "returns order
AND vbtyp_v EQ 'M'. "invoice
IF sy-subrc EQ 0.
Get billing doc conditions key
SELECT SINGLE knumv
INTO lv_knumv
FROM vbrk
WHERE vbeln EQ ls_vbfa-vbelv.
IF sy-subrc EQ 0.
Get moving average price from billing doc conditions
SELECT SINGLE kbetr
INTO lv_kbetr
FROM konv
WHERE knumv EQ lv_knumv
AND kposn EQ ls_vbfa-posnv
AND kschl EQ 'VPRS'.
IF sy-subrc EQ 0.
Recalculate condition values
xkomv-kbetr = lv_kbetr.
xkomv-kwert = lv_kbetr.
xkwert = xkomv-kwert.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
Regards,
Edric

Hi,
If you bring the Freight condition after PBXX and include in the net value, your problem will be solved.  so it will be 120 in MIGO, MIRO, Dellivery and VPRS in billing.
We have the same situation and its working fine for us. 
Thanks
Krishna.

Similar Messages

  • Conditions record for returns order with order type "RE" Modification

    Hi,
    How can I gay out the EDI1 conditons row ( Customer expected price ) for returns order, so that the customer price is not considered.
    Current Scenerion: when we create a returns order "RE" with reference to standard order "OR" it pulls out the price details from the standard order, but then in the conditions tab the EDI1 ( customer expected price ) is still active which allows the user to enter the new price. When the user enters the new price, the price for that line item is getting updated with this new customer expected price.
    Can any one help me out on how to gray put that row, so that the user is not allowed to enter a new price during rreturns.
    Thanks in Advance!!

    Hi
    This will be updated automatically when generate planned orders thru MRP. (MD02)
    regards
    Srinivas

  • BAPI KPF6 POST PLAN COST FOR INTERNAL ORDER AND COST ELEMENT

    Hi all gurus,
    I would like to use in a custom report a BAPI/Function Module that help me to simulate KPF6 in order to post planning costs for internal order and cost element (layout 1-401).
    So the input should be:
    1) Version
    2) period from
    3) periodo to
    4) year
    5) internal order n.
    6) cost element n.
    7) value
    I found a lot of BAPI but don't know the correct one and how to use it (example how to fill the input value).
    Can anyone help me on that?
    Kind Regards

    In additio  to the previous I found the BAPI_COSTACTPLN_POSTPRIMCOST but don't know if it's the correct one and how to use it (some example fitting the my case will be very appreciated).
    If the quoted BAPI is correct.
    I tested it filling all fields as following:
    HEADERINFO:
    CO_AREA=FFCA
    FISC_YEAR=2008
    PERIOD_FROM=001
    PERIOD_TO=012
    DOC_HDR_TX='blank'
    INDEXSTRUCTURE:
    OBJECT_INDEX=000001
    VALUE_INDEX=000004 (hope this point at Interna Order)
    ATTRIB_INDEX=000000
    COOBJECT:
    OBJECT_INDEX=000001
    ORDERID=ZO53-08IMZ
    TOTVALUE:
    VALUE_INDEX=000004
    COST_ELEM=3224048
    FIX_VALUE= 200,0000
    DIST_KEY_FIX_VAL=2
    The Return table is set to 0. Nothing happens.....I suspect something related to indexstructure or index is wrong..
    Could anyone help me on that?
    Kind Regards

  • Cost estimate for sales order

    Dear Friends,
    In a make to stock scenario a finished good is sold from the depot and thereafter it is returned. After creating the credit memo for return, when the same is being released to accounting in VF02, the system throws an error message which reads 'Error reading the material cost estimate for sales order "12000373". and the document cannot be passed on to accounting. Although, we are able to release the sales invoice to accounting without any error. In the item condition tab for sales order the standard cost VPRS is updated as we enter the plant.
    Strategy group for the material is 40-planning with final assembly. The concern over here is that why the system is asking for cost estimate at the level of sales return.
    Please suggest why this error is coming and how the same can be released to accounting.
    Regards

    Hello Friend,
    The problem is that Material you are using for that Cost Estimate is not done. So go to T.Code CK11 give the Costing Variant, Material & Plant and go on entar and entar. If everything is green in end then save it.
    Then Go to T.code CK24 give the Company Code, material & Plant and then execute.
    Click Back and click on Release Button and then execute.
    Then try the Transaction you have got the error again.
    Hope this helps.

  • Error reading material cost estimate for sales order (KE292)

    Dear All,
    I have an issue with billing. we are posting july month transactions, the material cost is maintained through MR21. When releasing billing document for accounting we are getting error message like"Error reading the material cost estimate for sales order "11"
    Message no. KE292
    Diagnosis
    In Profitability Analysis (CO-PA), the system tried to valuate item 000010 of sales order 11 by reading the corresponding product cost estimate.
    However, no product cost estimate could be found for this sales order item.
    The system accessed product costing for product AMLFP011011XX00P using costing key YB3 as defined in the
    CO-PA Customizing settings.
    System Response
    The system cannot process the document any further.
    Procedure
    Check your Customizing settings."
    We cross checked with other client as a current date and we ran cost estimate through CK40N with same material. and we posted entries. Here it is working fine. but in above process it is not working. Can you pls guide me where i missed.
    Regards,
    Nagaraju,

    Hi,
    When the Costing Key is assigned to the material types in the COPA customizing, then system expects Cost estimation when billing is released to Accounts.
    If you dont run cost estimation but update the material master through MR21, system will not accept as in the Costing key configuration you must have selected the Current Standard price field for the valuation.
    Hence, try to run cost estimation and then do releasing.
    Thanks & Regards
    Ravi Kumar

  • Periodic cost settlement for production order

    Hello All,
    Please explain me can we do Periodic cost settlement for production order in discrete manufacturing. If yes, how?
    Thanks & Regards,
    Alok Tiwari

    WIP entry gets passed to accounts if the order is not in DLV or TECO status.
    or else variance gets calculated.
    Two GLs which gets hit are
    Change in stock a/c Dr.
    To Inventory Price Difference a/c Cr.                or vice versa......
    Regards,
    Divraj

  • No delivery costs exist for purchase order

    Dear Friends,
    While doing MIRO, i am getting an error message as mentioned below----
    "No delivery costs exist for purchase order xxxxxxxxx"
    Message no. M8014.
    Kindly guide me in resolving the error.
    Thanks & Regards,

    hi
    >"No delivery costs exist for purchase order xxxxxxxxx"
    itself says that there is no delivery cost,
    firstly check ur PO ,Did u entere the delivery cost conditions like for freight or octoi in the PO
    or if u have entered the condition then check if it is not already invoiced
    if u dont have delivery cost in po and wanna do IV for material then in miro
    change the option of delivery cost to goods/service
    (at right side of the po no field)
    regards
    kunal

  • Information costing data for maintenance orders

    Hi everbody,
    Can somebody throw some light on Costing Data for maintenance order for the following functions
    1) Costing sheet
    2) Costing Variants
    3) valuation Varaints.
    I would like to know how this setting will be used in the business form the PM point of view.
    Thanks in Advance
    DP

    [SAP Help|http://help.sap.com/saphelp_erp60_sp/helpdata/EN/a9/ab7654414111d182b10000e829fbfe/frameset.htm]

  • Product cost collector for sales order related production

    Hi Friends,
    This is Azam and here i am new to this discussion forum.
    we are in situation that use diffrent variant for configurable material in sales order related production,
    I would like to have some information about use product cost collector for this kind of sales order related production,
    also I want to know difference between prelimanary cost estimate or cost estimate for sales order?
    Please co-operate me.
    I would be highly appriciated if you can respond at the earliest.
    Thanks
    Azam

    Hi,
    Here, for each sales order item, you will have sales order cost estimate. This enables the system to compute the variances once the actual costs are booked against the production.
    In the case of preliminery cost, we get the preliminery cost for production order as a plan cost and is not being used for the computation of variance but only for comparision purpose which is very marginally used.
    Trust this helps much and do encourage our efforts!
    Cheers!

  • How to mark up the price for sales order entry?

    Hi Gurus,
    How to Mark up the price for sales order entry?
    Example: Item Price: $10, Adding 20% Margin
    Selliing price of the item is $12
    we are giving many typs discounts like festival Discount, customerwise, Order value wise etc..
    After giving above discounts, if discount falls below $10 system should not allow to book the order, Trigger should go to respective person or sales person saying that item price falling below cost, system should not allow to book the sales order.
    How to configure this scenarios in Order management Module, appreciate your inputs, advise.
    Regards
    AK

    Thanks for your response,
    can you please guide me step to achieve this requirement.
    Regards
    AK

  • Pricing for return orders

    Hi,
    Can anyone help me on an user exit for return orders pricing.i have to do the pricing based on some logic .but im unable to find the table in which material/customer exists (except KNMT table) such that i can find entry for shipment and go head and find the avg price.
    can suggestion also is welcome

    Hi,
    following is the code that can be helpful.
    use the following code in the MV45AFZZ include program and trigger the following code in a include program USEREXIT_PRICING_PREPARE_TKOMP.
    hope it helps.
    CHECK vbak-auart EQ 'ZRE'.
    *CHECK vbak-vkorg EQ '1300'.
         T Y P E  D E C L A R A T I O N S                               *
    TYPES : BEGIN OF ty_s_retorders,
              kunag TYPE vbrk-kunag,    " Customer Number
              vbeln TYPE vbrp-vbeln,    " Billing Doucuement
              matnr TYPE vbrp-matnr,    " Material Number
              vgpos TYPE vbrp-vgpos,    " Item Number
              fkimg TYPE vbrp-fkimg,    " Item Quantity
              netwr TYPE vbrp-netwr,    " Net price of the Item
              erdat TYPE vbrk-erdat,    " Date of cretaion of the record
              value TYPE vbrp-netwr,    " Net value of the Item
            END OF ty_s_retorders,
           ty_t_retorders TYPE STANDARD TABLE OF ty_s_retorders.
                V A R I A B L E S                                       *
    DATA : lv_quant TYPE vbrp-fkimg,    " Total quantity
           lv_value TYPE vbrp-netwr,    " Total value of the materials
           lv_avgpr TYPE vbrp-netwr,    " Averge Price of the material
           lv_dat   TYPE i,             " variable to hold the year value
           lv_date  TYPE vbrk-erdat.    " Creation date of the docuement
         I N T E R N A L  T A B L E S                                   *
    DATA : gt_retorders TYPE ty_t_retorders.
    G L O B A L    D A T A   D E C L A R A T I O N S                    *
    DATA   : gs_output    TYPE ty_s_retorders.
    CONSTANTS : lc_zpr0(4) TYPE c VALUE 'ZPR0' .
    Get date value which is 12 months ago.
    lv_dat     = sy-datum+0(4) - 1.
    lv_date    = sy-datum.
    lv_date(4) = lv_dat.
    Select data
    SELECT   vbrk~kunag          " Customer Number
             vbrp~vbeln          " Billing Doucuement
             vbrp~matnr          " Material Number
             vbrp~vgpos          " Item Number
             vbrp~fkimg          " Item Quantity
             vbrp~netwr          " Net price of the Item
             vbrk~erdat          " Date of cretaion of the record
             INTO   TABLE gt_retorders
             FROM  vbrp  JOIN   vbrk
             ON   vbrkvbeln = vbrpvbeln
             WHERE   vbrk~erdat BETWEEN lv_date AND sy-datum
               AND   kunag EQ vbak-kunnr
               AND   matnr EQ vbap-matnr.
    CLEAR: lv_quant,
           lv_value.
    loop the internal table and get the total of quantity and value
    LOOP AT gt_retorders INTO gs_output.
      gs_output-value = gs_output-fkimg * gs_output-netwr.
      lv_quant        = lv_quant +  gs_output-fkimg.
      lv_value        = lv_value +  gs_output-value.
    ENDLOOP.
    calculate the average pricing value
    CLEAR lv_avgpr .
    lv_avgpr = lv_value / lv_quant.
    CLEAR xkomv.
    READ TABLE xkomv INTO xkomv WITH KEY kposn = vbap-posnr
                                         kschl = lc_zpr0 .
    IF sy-subrc EQ 0.
      xkomv-kbetr = lv_avgpr .
      MODIFY TABLE xkomv[] FROM xkomv TRANSPORTING kbetr .
    ENDIF.

  • Recalculation of quantity in free goods for return order wrf to invoice

    Hello everyone,
    I want to recalculate quantity of free goods category in a return order created with reference to an invoice, if the quantity in the High Level Item Category has changed.
    For example, a customer bought 100 boxes of product "A " and received 10 of these for free. Then he wants to return 60 boxes. When I create a return order with reference to the invoice and change these quantity from 100 to 60, free goods item category still shows 10 boxes instead of 6.
    Recalculation must be take place acording to the pricing date determination in order to apply free goods in a valid date.
    Customized features reviewing:
    1. There's not Item Category Proposal for Target Sales Doc type of the Return order, but item category of source bill type has one an is set to Pricing Type "D".
    2. High Level Item category of free goods category is relevant for billing and is set to M "Delivery - related invoices-no zero qtys (in main bath items)"
    3. Free goods category assigment has NORM as item Category Group, FREE ussage, High Level Item category is determinated for return order document type and Item category by default is the free goods category.
    I will appreciate your support to solve this issue.
    Best Regards,
    Andrea Figueroa

    Hello,
    Thank you for your response.
    My Discount Type of Free Goods determination is set to:
    Calculation Rule: "2 - Unit reference"
    Free Goods Category: "1 - Inclusive rebate (with item generation)"
    Free Goods delivery control: "C - Delivery of main item is part. delivered, only with main item"
    However, whatever the calculation rule is, if I change the quantity in the main item, subitem does not work. 
    I read about SAP Note 573598 that describes perfectly my problem, but is valid in 4.6 to 4.7 version and I have ERP version.
    Thank for your help,
    Andrea Figueroa

  • BADI for return order creation in CRM

    Hi group,
    I have an requirement. In CRM ,Return order should be created from UBB service contract when change process takes place(Contract termination), ie throgh actions in the UBB service contract. these steps are configured through Actions.
    The requirement is, I need to enhance the  BADI implemention(COPY_DOCUMENT) by creating a function module. this function module should provide the necessary data for Return Order creation. Is there any function module to create a Return order in CRM or how to proceed? Appreciate if any suggestions
    Regards,
    Sankar

    Hi,
           You can use BAPI_SALESORDER_CREATEFROMDAT2 .
    In import TESTRUN = X
    Description
    This parameter is a test switch.
    If you activate the switch, the system does not save the document.
    Value range
    Space = Document should be saved
      X   = Document should not be saved
    Default
    Space

  • Import License Check for Return Orders

    Hello,
    We are currently testing compliance for return orders in sales.
    We would like to check the import license for these orders.
    For this we have defined a separate legal regulation and assigned the combination country of plant (= legal unit) and country of departure to it.
    When we process the return order the GTS system can not retrieve the correct country of departure.
    to check available import licenses.
    Does this has something to do with the incorrect determination of the partner function for returns.
    I suppose that we need a function for inbound movements : goods supplier, vendor ?
    Thanks for your support
    Regrds
    Frank

    Hi,
    What Iam going to tell is not advisable but if  you want you can do this.
    1)Go to T.code:OVAH
    2) Select the message :229
    3) Select Application : V4
    After selecting the above message and application----towards on the Right hand side "Change the Message category from Waring to Error".
    After doing the above setting--when ever the user tries to give more quantity in Return order when referenced from Invoice---""System will give error message" and does not allow to give more Quantity when referenced from the Invoiced quantity.
    Regards
    SK

  • Query to get extended price for a order in R12

    Hi All,
    How do i get extended price for a order in R12(version 12.1.3)
    Thanks

    Hi,
    you can get ext.price using following SQL.
    SELECT (ORDERED_QUANTITY * UNIT_SELLING_PRICE) EXTENDED_PRICE
    from oe_order_lines_all WHERE line_id = :P_LINE_ID
    HTH
    Sanjay

Maybe you are looking for

  • Client IMAP folder duplication after upgrade to 10.8.2 server. Anyone know how to fix this?

    Just upgraded my client's server from 10.6.8 to 10.8.2. It's a Mac mini 2.66Ghz. Now when I launch an email client on a computer on the network (Mail or Outlook specifically) I get multiple IMAP folders created i.e. Deleted Messages 1, Deleted Messag

  • Migration of Windows Small Business Server 2011 Standard Edition to new hardware

    Hi I have a Windows SBS 2011 Standard Edition installation, of which, the windows component is very buggy.  Everything on the server is working i.e. AD, Email.  I am unable to shutdown the server gracefully, i am unable to open the system manager.  B

  • Images as visualizer

    Is there a plugin anyone knows of, or a technique that will allow the iTunes visualizer to run a folder of images in a slideshow. Just sort of curious, I know there are numerous otherways I could get the same effect. tim

  • Simple Event Listener Problem

    Hi, I am new to EventListeners so this might seem very simple to some of you. Basically, I got a Frame (extending JFrame) into which I place several "Mini-JPanels". These panels are a separate class. In each of them there are a JCheckBox, a JLabel an

  • Error in CJ88 reversal

    Hi All, I've tried to reverse some WBS/assets settlements in CJ88, but I've received an error: "Sender: WBS HXG/09110-009-01-01 System error - deletion not possible" What this stands for? How can I reverse this settlements? Is there another way to do