Order Quantity in BAPI_Salesorder_change becomes zero when changed.

Hi,
As a requirement , I have to delete line item on a sales order and create one line item with the same data except delivering plant. I am using BAPI_SALESORDER_CHANGE.
I need to change ship to party and line item data. Ship to party and other line item details updates fine but order quantity remains zero.
Please find below used code.
{ Code
wa_order_item_in-itm_number    = wa_vbap-posnr.
      wa_order_item_in-plant         = wa_vbap-werks.
      wa_order_item_in-material      = wa_vbap-matnr.
      wa_order_item_in-target_qty    = '1'.
       clear wa_order_item_in.
*--Adding second line item
      wa_order_item_in-plant         = pa_werks.
      wa_order_item_in-material      = wa_vbap-matnr.
      wa_order_item_in-target_qty    = '1'.
      wa_order_item_inx-itm_number = wa_vbap-posnr.
      wa_order_item_inx-updateflag = c_delete.
      clear wa_order_item_inx.
      wa_order_item_inx-itm_number = wa_vbap-posnr.
      wa_order_item_inx-updateflag = 'I'.
      wa_order_item_inx-material   = c_x.
      wa_order_item_inx-plant      = c_x.
      wa_order_item_inx-target_qty = c_x.
      wa_order_item_inx-target_qu  = c_x.
      append wa_order_item_inx to it_order_item_inx.
      clear wa_order_item_inx.
-Partner function changes--
      concatenate c_p wa_vbap-werks into  lv_garage1.
      wa_partnerchanges-updateflag = c_update.
      wa_partnerchanges-document   = wa_vbap-vbeln.
      wa_partnerchanges-p_numb_new = lv_garage.
      wa_partnerchanges-partn_role = c_shiptoparty.
      wa_partnerchanges-p_numb_old = lv_garage1.
      append  wa_partnerchanges to lt_partnerchanges.
      clear  wa_partnerchanges.
Schedule Lines--
      wa_schedule_lines-itm_number = wa_vbap-posnr.
      wa_schedule_lines-req_qty = wa_vbap-kwmeng.
      wa_schedule_lines-sched_line = '0001'.
      append wa_schedule_lines to lt_schedule_lines.
      clear wa_schedule_lines.
      wa_schedule_linesx-itm_number = wa_vbap-posnr.
     wa_schedule_linesx-updateflag = 'U'.
      wa_schedule_linesx-req_qty = 'X'.
      append wa_schedule_linesx to lt_schedule_linesx.
      clear wa_schedule_linesx.     
Thanks
Mohinder
Edited by: Mohinder Singh Chauhan on Dec 9, 2009 5:27 AM
Edited by: Mohinder Singh Chauhan on Dec 9, 2009 5:28 AM

Hi Mohinder,
Try giving schdule line number value also in wa_schedule_linesx sctructure.
wa_order_item_in-itm_number = wa_vbap-posnr.
wa_order_item_in-plant = wa_vbap-werks.
wa_order_item_in-material = wa_vbap-matnr.
wa_order_item_in-target_qty = '1'.
clear wa_order_item_in.
*--Adding second line item
wa_order_item_in-plant = pa_werks.
wa_order_item_in-material = wa_vbap-matnr.
wa_order_item_in-target_qty = '1'.
wa_order_item_inx-itm_number = wa_vbap-posnr.
wa_order_item_inx-updateflag = c_delete.
clear wa_order_item_inx.
wa_order_item_inx-itm_number = wa_vbap-posnr.
wa_order_item_inx-updateflag = 'I'.
wa_order_item_inx-material = c_x.
wa_order_item_inx-plant = c_x.
wa_order_item_inx-target_qty = c_x.
wa_order_item_inx-target_qu = c_x.
append wa_order_item_inx to it_order_item_inx.
clear wa_order_item_inx.
---Partner function changes-------------------------------------------
concatenate c_p wa_vbap-werks into lv_garage1.
wa_partnerchanges-updateflag = c_update.
wa_partnerchanges-document = wa_vbap-vbeln.
wa_partnerchanges-p_numb_new = lv_garage.
wa_partnerchanges-partn_role = c_shiptoparty.
wa_partnerchanges-p_numb_old = lv_garage1.
append wa_partnerchanges to lt_partnerchanges.
clear wa_partnerchanges.
--Schedule Lines------------------------------------------------------
wa_schedule_lines-itm_number = wa_vbap-posnr.
wa_schedule_lines-req_qty = wa_vbap-kwmeng.
wa_schedule_lines-sched_line = '0001'.
append wa_schedule_lines to lt_schedule_lines.
clear wa_schedule_lines.
wa_schedule_linesx-itm_number = wa_vbap-posnr.
wa_schedule_linesx-sched_line = '0001'. " Add this line and check
wa_schedule_linesx-updateflag = 'U'.
wa_schedule_linesx-req_qty = 'X'.
append wa_schedule_linesx to lt_schedule_linesx.
clear wa_schedule_linesx.
Regards,
Swarna Munukoti

Similar Messages

  • Why Synonym becomes INVALID when changes are made on the related object ?

    Hi all,
    WHY SYNONYMS becomes invalid when changes are made on related OBJECTS ?
    Is there any specific reasons for this.?
    Is there any method or procedures to make the synonym VALID as soon as the we perform any alteration on the related object.
    Thanks
    Himabala

    Synonym will be validated when it is accessed, no need to take an action.

  • Net Value in sales order becomes zero after changing the employ responsible in Web UI

    Hi All,
    We are in CRM 7.0 with EHP1, when we change employ responsible in the sales order and save, Net value is becoming zeroes.
    This is effecting most of the transactions. There is no custom development, every thing is standard.
    Could any one suggest me this.
    Thanks.
    Best regards,
    Hari

    Hi Raj,
    Thanks you for your reply.
    Could you please let me know where I can see this combinations in configuration. Actually this is happening for standard transactions also.
    I checked customer pricing proc for that BP and Document Pricing proc for that T type. They are maintained for the specific salea area.
    Regards,
    Hari

  • Order quantity is always showing zero in ECC  --- Urgent

    Hi Team,
    Service order created in CRM Web UI and with service material (Servicing charges) order quantity as u201C1 " at the SM item level defined.
    Order is getting saved without any errors and replicated well with the amount to the ECC ,  but the Issue is order quantity is always showing as " 0 " in ECC , instead of  u201C 1 u201C
    SAP Tem had proposed to change the SD Document category type From u201CCu201D ( Order ) to "L" (Debit memo req ) . We had changed the same and tested, but no use, still we see no change in the order quantity of the service material in the ECC.
    If any one knows, how to address this, pls respond at the earliest.
    Regards
    VCS

    Dear Brhmakumar,
    There is no option to enter Operation qty. in routing.
    And for the converstion factor from header qty to operation qty. is 1:1 is in routing.
    Thanks & Regards,
    Mihir mehta

  • Order Quantity (Config.) not set when using BAPI_SALESORDER_CREATEFROMDAT2

    Hi when I use BAPI_SALESORDER_CREATEFROMDAT2 order quantity is empty (missing also in the inclompent log in VA03)
    why ? what should be also set ? thanks a lot !
    I set this data:
    ls_order_header_in-doc_type    = 'TA'.
    ls_order_header_in-sales_org   = '1000'.
    ls_order_header_in-distr_chan  = '01'.
    ls_order_header_in-division    = '01'.
    ls_order_header_in-PURCH_NO_C  = 'test'.
    ls_order_partners-partn_role = 'AG'.
    ls_order_partners-partn_numb = 'CH10'.
    APPEND ls_order_partners TO lt_order_partners.
    ls_order_item_in-material = 'S-000'.
    APPEND ls_order_item_in TO lt_order_item_in.
    ls_order_cfgs_value-charc = 'S001'.
    ls_order_cfgs_value-value = '1'.
    APPEND ls_order_cfgs_value TO lt_order_cfgs_value.
    ls_order_cfgs_value-charc = 'S002'.
    ls_order_cfgs_value-value = '1'.
    APPEND ls_order_cfgs_value TO lt_order_cfgs_value.
    ls_order_cfgs_value-charc = 'S002'.
    ls_order_cfgs_value-value = '2'.
    APPEND ls_order_cfgs_value TO lt_order_cfgs_value.
    ls_order_cfgs_value-charc = 'S003'.
    ls_order_cfgs_value-value = '1'.
    APPEND ls_order_cfgs_value TO lt_order_cfgs_value.
    ls_order_cfgs_value-charc = 'S003'.
    ls_order_cfgs_value-value = '3'.
    APPEND ls_order_cfgs_value TO lt_order_cfgs_value.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
    *   SALESDOCUMENTIN               =
        order_header_in               = ls_order_header_in
    *   ORDER_HEADER_INX              =
    *   SENDER                        =
    *   BINARY_RELATIONSHIPTYPE       =
    *   INT_NUMBER_ASSIGNMENT         =
    *   BEHAVE_WHEN_ERROR             =
    *   LOGIC_SWITCH                  =
    *   TESTRUN                       =
    *   CONVERT                       = ' '
    * IMPORTING
    *   SALESDOCUMENT                 =
      TABLES
        return                        = lt_return
        order_items_in                = lt_order_item_in
    *   ORDER_ITEMS_INX               =
        order_partners                = lt_order_partners
    *   ORDER_SCHEDULES_IN            =
    *   ORDER_SCHEDULES_INX           =
    *   ORDER_CONDITIONS_IN           =
    *   ORDER_CONDITIONS_INX          =
    *   ORDER_CFGS_REF                =
    *   ORDER_CFGS_INST               =
    *   ORDER_CFGS_PART_OF            =
        order_cfgs_value              = lt_order_cfgs_value.
    *   ORDER_CFGS_BLOB               =
    *   ORDER_CFGS_VK                 =
    *   ORDER_CFGS_REFINST            =
    *   ORDER_CCARD                   =
    *   ORDER_TEXT                    =
    *   ORDER_KEYS                    =
    *   EXTENSIONIN                   =
    *   PARTNERADDRESSES              =
    *   NFMETALLITMS                  =
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    We use the same BAPI to process Web orders into SAP.  You have to have a corresponding ORDER_SCHEDULES_IN entry with matching ITM_NUMBER for every ORDER_ITEMS_IN entry.  Within ORDER_SCHEDULES_IN is where you put the quantity.  Should be stored in REQ_QTY.    We had to fill ITM_NUMBER and SCHED_LINE with the line number value in order to make it work.  Remember to fill in your corresponding X-structure fields as well.
    hope this helps,
    Chad

  • Sales Order Generating more than one event when changed

    Hey all,
    I have to trigger a workflow when a sales order is changed (bus2032.changed) .
    The event is triggered when any changes are made and the save button is clicked .
    However my problem lies in the fact that the system produces the event not once but 3 times .
    I checked if there are any active Badis for this , but none exist. Nor are there any user exits implemented. Therefore extra events could not have been called in the Badi nor the user exits .
    Has anybody come across a similar scenario ?
    Could anybody shed some light on this ?
    Thanks and Regards ,
    Amit

    Hi Gareth,
    First , Where do you set this event trigger per line item  ?
    Second, I have done no setting in the system and was just checking the event trace . I did this by changing the PO date on the order and saving the Order.
    Also, the sales order i have used has a single workitem .
    Thanks a lot for your help,
    Amit

  • Mass Contract Update - Item price become zero after Tax Code change

    HI Guru,
    I have issue on the contract net price which become zero after change in Tax code of item.
    Took the opportunity to update contracts to reflect the changing VAT code (from V0 to V1 for some items) from the Trx code: MEMASSCONTRACT. However, having run the transactions (ME33K) above the contracts are now displaying zero prices on the Item Overview.  The conditions are all correct (PB00) and the follow on purchase orders seem to be picking up the correct prices but we need to resolve the issue of zero prices on the item overview. 
    Please help me in this why it is happening like this? & what is the solution for it.
    Thanks in advance
    Praveen Katageri

    Hi,
    If pricing picking , just check  validity period ( Valid from & Valid to) in  condition of the  Info record.Also check any scale is used & price active or not in condition of Info record.
    Regards,
    Biju K

  • Value of Manual Pricing Condition is becoming zero while saving.

    My clientu2019s pricing calculation requirement is  complex. Here I am mentioning :-
    We have one pricing condition type YPR4 which is header as well as item condition. Value will come only from condition record . So, we maintained access sequence  in the configuration. Beside this we maintained u2018Manual entries u2018 in the configuration as u2018Not possible to process manuallyu2019. Condition record for this pricing condition type  we maintain for line items.
    We have another  pricing condition type Y255 which is also  Item condition as well as header condition. For this pricing condition  value ( header level) can come from condition records  if record exist , or , if condition record is not there or if user wants, user  can  enter value  in header level of the sales order. For getting this functionality  we maintained access sequence and u2018Manual Entryu2019 in the condition type configuration we have maintained as u2018No Limitationu2019.
    In the line item level Y255 will come only if YPR4 is there for that item. The total value of the Y255 in the header will need to be distributed in the line items accordingly as per existence of YPR4 in the line item.
    Issue:
    Now the issue is that, when  there no condition record for Y255 and when  we are entering the value of Y255 manually in the header, the value of Y255 is becoming zero  when we are moving from one screen to another screen in the same sales order , or when we are saving the sales order..
    Can anybody suggest what we need to do so that manually entered value of   Y255 remains in the sales order after moving to another screen or after saving the sales order ?

    Hi ,
    Please check the pricing routines funcationality which is assigned to both condition types.check the requirement and alt.cal. type routines of Y225 condition , on what basis condition record is updating manully entry as well as picking value from condition  records.

  • Tracking the actual sale order quantity

    Hi Friends,
    How to track the actual sales order quantity given by the customer.
    Ex: we assume the customer has placed an order of 100 units and stock is only 90 so we create the sales order for 90 units only.
    How to find out the difference of 10 units as a report in standard sap system.
    Thanks
    AJ

    Dear AJ,
    This is how normal sales process works.
    You create Sales Order line item for the quantity that customer has requested. (eg: 100)
    Then you do a ATP for that Line item. Let's say you have only 90 in the stock. In that case system will confirm 90 for the sales order line item. (You can see the confirmed quantity in the Schedule line tab)
    Normally we don't change the LI quantity as per the ATP confirmed quantity (i.e 90). Because then we loose the visibility to the customers original requested quantity (i.e 100).
    Say you don't change your Line Item Order quantity to 90. Then your delivery & billing will be for 90.
    So you can see in VA05, Order quantity as 100 and confirmed quantity as 90.
    Your sales reports will show delivery & billing as 90. So that you have a clear visibility to the original order quantity, delivered quantity & billed quantity.
    Further if remaining (open) quantity 10 is appearing your MRP & creating troubles, please use Line Item Rejection Reason as Completed. So that everything is perfect.
    Coming back to your issue.
    Since your changing LI quantity to 90, you cant see 100 in the VA05 report. It always show the existing sales order line item quantity, which is 90 in this example.
    Only way you can find your original sales order quantity is in the Line Item / Change Log.
    This can be view by selecting below Menu option.
    Environment -> Changes
    If you execute it for the relevant Line Item, you can see the Change log. In that by double clicking relevant quantity change line, you  can see the old value & new value. (In this example 100 & 90)
    But that is not a good practice to do as changes will show all quantity changes that you might do based on  customer request. (Imagine if you customer ask to change it later to 95 not 100).
    In that case change log will display 100 to 95, then 95 to 90. So your loosing the required visibility.
    Hope this is helpful to you !

  • Confirmed quantity = ordered quantity but stock 0

    Morning SAP gurus i have a scenario where i dont have stock on hand but confirmed quantity at schedule line is = to the ordered quantity.This causes a problem when i receive stock from another plant which is less than what i ordered as my delivery note is created for the original ordered amount.
    What can i do to make sure my schedule line does not confirm the quantity that i dont have on stock?
    Thanks
    Phenyo Ntshabele

    "Activate Availability Check (AvC) in your sch line cat (tcode VOV6).
    To do so, check/activate/tick mark Availability in Transaction of Sch Line cat.
    Or redetermine your sch line cat with active for AvC.
    before that, don't forget to check sch line cat determination (VOV5) with your I Cat
    Thanks & Regards
    JP"

  • Confirmed quantity becomes zero in process order

    What scenario did the confirmed quantity becomes 0 (zero) even though it has value upon the creation of the process order.
    You can see the confirmed quantity on the material list of the process order. The RESB table for the component becomes zero. But how it was become zero was the very big question.
    Thanks

    please run CORT, put your oder number and have a look WHO and WHEN confirmed zero
    also rum MB23 for your reservation, goto header and get the details

  • Actual quantity in service tab page becoming zero after updation

    Dear friends,
    We updated validity start date, end date in header and the field "form.val.2" in service tab page in item details of a service line item(item category D) in a Purchase order using the function module 'BAPI_PO_CHANGE'. After updation we observed the actual quantity (which denotes the total GR qty) becoming zero, making the PO completely open and allowing creation of service entry sheet for full quantity. This happend for so many POs. Now we want to correct the actual quantity. But as it is in display mode it now become difficult to change the actual quantity through any function module.
    Seeking for a genuine solution about how to correct the actual quantity.
    Regds
    Amitava

    hi
    check this sap note 938498 BAPI_PO_CHANGE: Reference update for a service item

  • Unable to change the order quantity value during save of sales order

    Hi Experts,
    There is a need to change the order quantity value, based on some conditions, when pressed 'ENTER' or during 'SAVE' of the sales order (VA01, VA02).
    We are trying to change the order quantity value (KWMENG) in table XVBAP in the subroutines userexit_field_modification, userexit_save_document and userexit_save_document_prepare of the user exit 'MV45AFZZ'. But the change is not replicated to field on GUI.
    The order quantity value can be changed in subroutine 'userexit_move_field_to_vbap', but the subroutine is not getting triggered when user changes only the order quantity on screen.
    Please help us in resolving this issue.
    Regards,
    Santosh

    Thanks for your time guys. The issue is resolved.
    SAP is not triggering the vbap user exit as the order quantity on screen is in structure RV45A.
    There are two ways of resolving the issue.
    1. Implement the SAP note #513342 - Quantity change and USEREXIT_MOVE_FIELD_TO_VBAP. But, it is SAP modification note.
    2. Write the code in VBEP exit of MV45AFZZ. This user exit is called whenever the order quantity is changed. But, it is called multiple times in some cases. Hence, need to write code to limit our code execution only once e.g. maintain a global table with our quantity & uom. Check when the quantity and uom in our table is same as quantity on screen. If not, exit from user-exit.
    Edited by: Santosh Kacham on Nov 11, 2011 6:37 AM

  • Changing quantity using bapi_salesorder_change function

    hi ,
    i am changing quantity using 'bapi_salesorder_change' function.what are the minimum parameteres that needs to be passsed to the function.i am not able to change the quantity for some items.also for some sales orders i am not getting any error message but commit work is not working.
    thanks ,
    nitin

    Hi Nitin,
    After you call the BAPI_SALESORDER_CHANGE, specifically call BAPI_TRANSACTION_COMMIT , as BAPI_SALESORDER_CHANGE does not run a database commit.(as per the documentation provided by SAP for BAPI_SALESORDER_CHANGE)
    Thanks
    Lakshman

  • How to update order quantity using the fn BAPI_SALESORDER_CHANGE

    Hi experts,
    I have a requirement that,
    when the quantity in the delivery is edited manually , the order quantity  in the sales order should be updated automatically.
    can we achieve that using the Function module BAPI_SALESORDER_CHANGE?
    if so, kindly let me know.
    TIA.
    kanthi.

    kanthi,
    in tables tab in second parameter ORDER_ITEM_IN you can see couple of field for different type of quantity among them you can choose appropriate one.
    field are:
    TARGET_QTY
    RNDDLV_QTY

Maybe you are looking for

  • IMac G5 - boots up to blue screen - tried everything

    I have an iMac G5 (no iSight) 2GHz. Came across following problem (running MacOs 10.4.11): - Normal boot: Mac goes through normal start up, but never gets beyond the blue screen - i.e. just before log in. - Safe boot: boots up OK & can log in. Up to

  • Payment Exceptions in f110

    Hi All, Can any one help to know different payment exceptions in automatic payment run i.e f110. Thanks in advance

  • How to Send the result of a report to a user through email.

    Hi, We have a report. It creates quotation. It automatically sends the report to the printer. in nace transction - for the particular quotation type - the output types are defined. The output types for printer, Fax, External Send and Edi is defined.F

  • Can u trade and old ipod for a newest one

    Yes i have a question i have a 4th genartion ipod and when the new 5th genartion ipod comes out i dont know if i could trade my 4th genartion for a 5th genartion and just pay the diffrence of it? Can you please write ASAP                             

  • Domain Juggler / Domains Juggler ??

    Just found all the posts about this wonderful little helper, but can't find it anywhere. All the links appear to be dead. Who can help me find a good link?