Update quantity in sales order by 'BAPI_SALESORDER_CHANGE'

I am trying to use the 'BAPI_SALESORDER_CHANGE' to change a sales order. I have to add a line item for empties in the sales order. the line gets sucessfully added but the quantity is not gettign updated.
I have tried all the fields of table ITEM_IN (target_qty COMP_QUANT RNDDLV_QTY) and set the flag for the corresponding in item_in as 'X' but still the order quantity field in sales order remains empty. How can I add the value in order quantity.

Hi,
Have you tried using the BAPI table SCHEDULE_LINES? This should work. Just add one line to this table for the required quantity.
Hope this helps,
Sumant.

Similar Messages

  • Updating quantity in sales order using api

    Hi all,
    SET SERVEROUTPUT ON;
    DECLARE
    v_api_version_number NUMBER := 1;
    v_return_status VARCHAR2 (2000);
    v_msg_count NUMBER;
    v_msg_data VARCHAR2 (2000);
    -- IN Variables --
    v_header_rec oe_order_pub.header_rec_type;
    v_line_tbl oe_order_pub.line_tbl_type;
    v_action_request_tbl oe_order_pub.request_tbl_type;
    v_line_adj_tbl oe_order_pub.line_adj_tbl_type;
    -- OUT Variables --
    v_header_rec_out oe_order_pub.header_rec_type;
    v_header_val_rec_out oe_order_pub.header_val_rec_type;
    v_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
    v_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
    v_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
    v_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
    v_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
    v_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
    v_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
    v_line_tbl_out oe_order_pub.line_tbl_type;
    v_line_val_tbl_out oe_order_pub.line_val_tbl_type;
    v_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
    v_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
    v_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
    v_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
    v_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
    v_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
    v_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
    v_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
    v_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
    v_action_request_tbl_out oe_order_pub.request_tbl_type;
    v_msg_index NUMBER;
    v_data VARCHAR2 (2000);
    v_loop_count NUMBER;
    v_debug_file VARCHAR2 (200);
    b_return_status VARCHAR2 (200);
    b_msg_count NUMBER;
    b_msg_data VARCHAR2 (2000);
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Starting of script');
    -- Setting the Enviroment --
    mo_global.init('ONT');
    fnd_global.apps_initialize ( user_id => 1153,resp_id => 50602,resp_appl_id => 7000);
    mo_global.set_policy_context('S',85);
    -- Header Record --
    --v_header_rec                        := oe_order_pub.g_miss_header_rec;
    --v_header_rec.operation              := OE_GLOBALS.G_OPR_UPDATE;
    v_header_rec.request_date           := SYSDATE + 1; Updating the Request Date
    v_header_rec.header_id              := 6006; Existing order header id
    v_action_request_tbl (1) := oe_order_pub.g_miss_request_rec;
    -- Line Record --
    v_line_tbl (1) := oe_order_pub.g_miss_line_rec;
    --v_line_tbl (1).operation            := oe_globals.g_opr_create;
    v_line_tbl (1).header_id := 1087; -- Existing order header id
    --v_line_tbl (1).inventory_item_id    := 9;
    v_line_tbl (1).ordered_quantity := 1;
    v_line_tbl(1).invoice_to_org_id := 1060;
    v_line_tbl(1).line_id := 1046;
    v_line_tbl(1).change_reason := 'Not provided';
    --v_line_tbl (1).unit_selling_price   := 10;
    --v_line_tbl (1).unit_list_price   := 10;
    --v_line_tbl (1).calculate_price_flag := 'Y';
    v_line_tbl(1).operation := OE_GLOBALS.G_OPR_UPDATE;
    DBMS_OUTPUT.PUT_LINE('Starting of API');
    -- Calling the API to update the header details of an existing Order --
    OE_ORDER_PUB.PROCESS_ORDER (
    p_api_version_number => v_api_version_number,
    p_header_rec => v_header_rec,
    p_line_tbl => v_line_tbl,
    p_action_request_tbl => v_action_request_tbl,
    p_line_adj_tbl => v_line_adj_tbl, -- OUT variables,
    x_header_rec => v_header_rec_out,
    x_header_val_rec => v_header_val_rec_out,
    x_header_adj_tbl => v_header_adj_tbl_out,
    x_header_adj_val_tbl => v_header_adj_val_tbl_out,
    x_header_price_att_tbl => v_header_price_att_tbl_out,
    x_header_adj_att_tbl => v_header_adj_att_tbl_out,
    x_header_adj_assoc_tbl => v_header_adj_assoc_tbl_out,
    x_header_scredit_tbl => v_header_scredit_tbl_out,
    x_header_scredit_val_tbl => v_header_scredit_val_tbl_out,
    x_line_tbl => v_line_tbl_out,
    x_line_val_tbl => v_line_val_tbl_out,
    x_line_adj_tbl => v_line_adj_tbl_out,
    x_line_adj_val_tbl => v_line_adj_val_tbl_out,
    x_line_price_att_tbl => v_line_price_att_tbl_out,
    x_line_adj_att_tbl => v_line_adj_att_tbl_out,
    x_line_adj_assoc_tbl => v_line_adj_assoc_tbl_out,
    x_line_scredit_tbl => v_line_scredit_tbl_out,
    x_line_scredit_val_tbl => v_line_scredit_val_tbl_out,
    x_lot_serial_tbl => v_lot_serial_tbl_out,
    x_lot_serial_val_tbl => v_lot_serial_val_tbl_out,
    x_action_request_tbl => v_action_request_tbl_out,
    x_return_status => v_return_status,
    x_msg_count => v_msg_count,
    x_msg_data => v_msg_data);
    DBMS_OUTPUT.PUT_LINE('Completion of API');
    IF v_return_status = fnd_api.g_ret_sts_success THEN
    COMMIT;
    DBMS_OUTPUT.put_line ('Order Header Updation Success : '||v_header_rec_out.header_id);
    ELSE DBMS_OUTPUT.put_line ('Order Header Updation failed:'||v_msg_data);
    ROLLBACK;
    FOR i IN 1 .. v_msg_count
    LOOP v_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
    dbms_output.put_line( i|| ') '|| v_msg_data);
    END LOOP;
    END IF;
    END;
    im getting errors pls send me a solution
    rgds,
    sandy

    if you just want to change qty , then comment v_line_tbl(1).invoice_to_org_id := 1060; and try to run again
    Regards
    eoracleapps.blogspot.com

  • Open quantity in Sales Order did not update after cancelling Reserve Invoice

    Client created Credit Memo with reference to Reserve Invoice but this did not update the open quantity in Sales Order. Client is using SAP B1 8.82 PL9. I tested this in SAP 9.0 and still same behavior. Is there a work around other than creating another SO?
    I checked Document Settings and "Reopening Doc by creating credit memo based on Doc" is enabled.
    Thanks in advance.

    Thanks for the reply. How will the client be able to make new reserve invoices from the SO? They are trying to make partial reserve invoices from the sales order. I already suggested to just change the quantity in the reserve invoice before adding. But I have doubt because the SO might close prematurely before they complete the quantity in the SO because open quantity is much less then the quantity in SO.
    SO Quantity: 100
    Open Quantity: 40
    Reserve Invoice 1: 60
    Reserve Invoice 2: 40
    SO closes before they can make Reserve Invoice 2

  • Update ship-to partner in sales order using BAPI_SALESORDER_CHANGE

    Dear all,
    We are trying to update the ship-to partner in a sales order using BAPI_SALESORDER_CHANGE. This is working correctly for most of our orders, so we do fill the BAPI correctly. However for some of our orders on item level a different payer is specified than on header level. However in that case the BAPI will not update the ship-to partner, but given an error message VPD 034 u2018The document must contain the same credit control areas for all payersu2019. Debugging already learned that actually the message is given not because of different credit control areas, but due to the fact that the payers and therefore the credit customers are different (although in the same credit control areas). For this reason we can not update the ship-to party of a large number of our sales orders with this BAPI. Actually we have 2 questions:
    ·         Has somebody experienced the same issue and did you manage to solve it somehow, so the BAPI could be used for this purpose of updating partner data?
    ·         Do you know other ways of updating the partners or partner address of an existing sales order in the background?
    Thanks in advance for your assistance.
    Regards,
    Satish.

    It was caused by standard SAP.

  • How to get the back order quantity for sales Order

    Hi Friends,
    I want to get the back order quantity for sales order . in MD04 t-code,
    there is a field(MDEZ-MNG01) for Received Qty/ Required qty.  But MDEZ is a structure.
    I tried from MDTB table, but the table is not updated with the values in MD04.
    Please guide me from which table I can get the back order Qty for sales Order
    (ref: t-code  MD04, MRP element = CusOrd).
    Thanks,
    Sagar

    >
    VIdya Sagar wrote:
    > Hi,
    >
    > Isn't  there any difference b/n Open Sales Order and Back order??
    Yes Quite Difference.
    Read:
    http://www.sap-img.com/sap-sd/explain-the-meaning-of-an-open-sales-order.htm
    http://help.sap.com/saphelp_sbo2005asp1/helpdata/en/b6/bdb9b2f02842348c9edbe78af863c4/content.htm

  • Problem in confirming quantity in sales order

    Hi,
    Quantities are not confiming in sales order after releasing the QM LOT by transaction QA16. Here the stock is posted to unrestricted stock but the table QALS is not updated accordingly which causes the problem in confirming the quantity in sales order.
       Is there any scope of reversal of the QM lot so that further the lot can be released  by QA32 or QA11.
    Further when a lot is releaded the status of the lot is updated as the usage decision has been made. Where this status is stored?
    Regards
    Indranil

    Hi,
    Have yoou give the document category for quotation as B. Please try ginvg the same and run.
    Thanks
    Shiva

  • Custom program for availability check and update for existing sale order at Item level(VA02)

    Hi,
    I came to know Bapi_Saleorder_Simulate can be used for availability check and update an existing sale order.but there is no sample program explaining the process.I have tried this by passing parameters ORDER_HEADER_IN , ORDER_ITEMS_IN  ,ORDER_PARTNERS and ORDER_SCHEDULE_EX(for getting details),also i have assigned the sale document number ,custom document type(ZSO) in ORDER_HEADER_IN . while executing the BAPI I am getting the error external number range is not assigned for the document type ZSO . I am confused on seeing this error. It is possible to do availability check for existing sale order using this BAPI. Please explain how to achieve this.It will be really helpful if it is expalained with an example.   
    Regards,
    Shanmuga

    Hello, I think you may have been misinformed about this BAPI updating a sales order at item level. As far as I understand it this BAPI can be used to simulate the creation of a sales order which obviously would include and ATP check. This is why it is giving the error because it is simulating creation but you are entering a value in a field that should be automatically generated (i.e. the sales order number). For change the sales order at item level have you looked at BAPI_SALESORDER_CHANGE? I pretty sure this BAPI both updates sales order (header or item level) and can do an ATP first.
    Points are always welcome if you feel an answer has been helpful.

  • Blocking Quantity in Sales order

    Hi,
    We have a requirement to block Quantity in sales order.
    PP is not integrated with Sales order, its a MTO ( but actually client does not follow MTO in SAP)
    Once the production is completed for that sales order......he want to block the sales order quantity either manually or automatically ( they use a z transaction to declare production complete against sales order ) but this should not stop him doing delivery and billling.
    Please let me know how can we do this.
    Thanks
    Venkata Rama Reddy.K

    Hi,
    The Process goes this Way
    Sales order is created and confirmed ( by mail ) to PP that production should be started.
    PP completes the production and they update the qty against sales order number in a z transaction once production qty matches work order qty. the z transaction stops adding qty in this z t.code.
    What customer wants is once they update this ztransaction with complete Qty ( which equals sales order Qty) , the sales order item quantity should be locked automaticallly so that quantity can not be modified once this z transaction is completed.
    Hope this information provides clarity.
    Please suggest a solution.
    Thanks
    Venkata Rama Reddy.K

  • Delete Sales order through BAPI_SALESORDER_CHANGE

    Hoi folks,..
      Can we delete the entire Sales order using BAPI_SALESORDER_CHANGE.  If yes, pls let me know the process?
    Thx

    HI,
    You can try to pass 'D' in the update flag of the header Structure.
    ie.. ORDER_HEADER_INX-UPDATEFLAG = 'D'
    and SALESDOCUMENT = 'The SO# to be deleted'.
    Hope this helps.
    Gary

  • Change sales order using BAPI_SALESORDER_CHANGE

    Hi i want to add a new line item to the existing sales order using BAPI_SALESORDER_CHANGE
    but when i am trying it is giving
    'Schedule line 0001 for item 000020 does not exist ' error..
    please help me..

    *********I wanted to add an new line item.***.. this is my code..********
    LOOP AT gt_input3 INTO st_input3.
    *Finding Max No of line Items
        IF fl_set IS INITIAL.
          READ TABLE gt_vbap INTO st_vbap WITH KEY vbeln = st_input3-vbeln.
          IF sy-subrc EQ 0.
            lv_posnr = st_vbap-posnr.
            fl_set = 'X'.
          ENDIF.
        ENDIF.
    *Populate Item details
        lv_posnr = lv_posnr + 10.
        lv_vbeln = st_input3-vbeln.
        lv_order_header_inx-updateflag = 'U'.
        st_order_item_in-itm_number = lv_posnr.
        st_order_item_in-material  = st_input3-matnr.
        st_order_item_in-target_qty = st_input3-imv_qty.
        st_order_item_in-plant = st_input3-werks.
        st_order_item_in-store_loc = st_input3-lgort.
       st_order_item_in-store_loc = st_input3-lgort.
        APPEND st_order_item_in TO lt_order_item_in.
    *Populate item updation Details
        st_order_item_inx-itm_number = lv_posnr.
        st_order_item_inx-updateflag = 'U'.
        st_order_item_inx-material = 'X'.
        st_order_item_inx-plant = 'X'.
        st_order_item_inx-store_loc = 'X'.
        st_order_item_inx-target_qty = 'X'.
        APPEND st_order_item_inx TO lt_order_item_inx.
    *Populate the Schedule Lines
        st_schedule_lines-itm_number = lv_posnr.
        st_schedule_lines-sched_line = '0001'.
        st_schedule_lines-req_qty = st_input3-imv_qty.
        APPEND st_schedule_lines TO lt_schedule_lines.
    *Populate the update details of schedule lines
        st_schedule_linesx-itm_number = lv_posnr.
        st_schedule_linesx-sched_line = '0001'.
        st_schedule_linesx-req_qty = 'X'.
        st_schedule_linesx-updateflag = 'U'.
        APPEND st_schedule_linesx TO lt_schedule_linesx.
           AT END OF vbeln.
    *Call BAPI Sales order change
          CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
            EXPORTING
              salesdocument    = lv_vbeln
              order_header_inx = lv_order_header_inx
            TABLES
              return           = lt_return
              order_item_in    = lt_order_item_in
              order_item_inx   = lt_order_item_inx
              schedule_lines   = lt_schedule_lines
              schedule_linesx  = lt_schedule_linesx.
    *Save Sales Order
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait = 'X'.
          CLEAR lv_posnr.
          READ  TABLE lt_return INTO st_return WITH KEY type = 'E'.
          st_ipfile_err3-message = st_return-message.
    *Error Log
          LOOP AT gt_temp3 INTO st_temp3.
            IF st_ipfile_err3-message IS NOT INITIAL.
              MOVE st_temp3-record TO st_ipfile_err3-record.
              IF fl_set1 IS INITIAL.
                APPEND st_temp_err TO gt_ipfile_err3.
                fl_set1 = 'X'.
              ENDIF.
              APPEND st_ipfile_err3 TO gt_ipfile_err3.
            ELSE.
              APPEND st_temp3 TO gt_audit3.
            ENDIF.
            CLEAR : st_temp3,
                    st_temp_err,
                    st_ipfile_err3,
                    fl_set.
          ENDLOOP.
          REFRESH : gt_zrman,

  • How to Restrict Confirmed Quantity in Sales Order (Based on Batch Expiry)

    Dear SD Experts,
    Currently our sales order confirms any amount of quantity if stock is available. And only during delivery it checks for the expiration of the batch and reduces the delivery quantity to batches available in stock within expiry.
    But since we are doing a bulk creation of deliveries at the end of the day, the check for expired batches is happening too late and no visibility for the data entry operators of stock that cannot be delivered during creation of the sales orders.
    So I am looking for solution to restrict the confirmed quantity in sales order to actually confirm only stock what can be delivered. i.e. based on expiry of the batch.
    Thanks!

    hi
    in Logistic general - batch mangement - batch determination allocation and check activation - maintain allocate SD search Procedure/ activate check
    check this for your sales area and sales document type and then in the search procedure maitain the strategy to check the Expiration date.
    regards,
    Sudhir

  • Free goods determined in Delivery over Order Quantity in Sales Order Item

    Hi Gurus,
    I've a problem about using free goods determination.
    First I created free goods master record with following information
    ZG1010012060075 From 100 PC -> Free good ZG1040012060075 2 PC
    Free goods Category = '2' (Exclusive)
    Free goods delivery control = 'E' (Delivery proportional to quantity in main item)
    Then I've created Sales Order with
    Item 10 ZG1010012060075 4,000 PC.
    Item 11 ZG1040012060075(Free good) has been automatically determined for 80 PC
    Then I've splitted Item 10 into 4 deliveries. The result of free goods determine in each delivery are as follow:
    Delivery#1)
    Item10 ZG1010012060075 = 1,176 PC
    Item20 ZG1040012060075 = 24 PC
    Delivery#2)
    Item10 ZG1010012060075 = 1,176 PC
    Item20 ZG1040012060075 = 24 PC
    Delivery#3)
    Item10 ZG1010012060075 = 1,176 PC
    Item20 ZG1040012060075 = 24 PC
    Delivery#4)
    Item10 ZG1010012060075 = 472 PC
    item20 ZG1040012060075 = 9 PC
    *Remark : Total quantity of 'ZG1040012060075'(free goods) = 92424+24 = 81 PC
    (Greater than 80 PC)*
    I think the system determined free goods in Delivery#4 correctly due to rounding up. But It might not be over the order quantity in Sales Order Item 11. Even though I've set the item category in delivery with Check overdelivery = 'B' (Situation rejected with an error message), the free goods are determined over order qty. BUT if I change delivery qty in delivery#4 Item20 from 9 PC -> 8 PC -> 9 PC, the error message occurred.
    My point is to fix the system not determine free goods in delivery items over order quantity in sales order item.
    Has anyone met this situation before? Do you have any idea about this issue?
    Best Regards,
    Prachya Lalitnorasate

    Dear Sai,
    Thank you for your advice, but it didn't solve my problem.
    I would like the system to determine free goods with proportional to main item AND In the last delivery main item delivered completely free goods must be determined equal to remaining open delivery item.
    Do you have any idea about configuration/customization?

  • In which table,i could find order quantity for sales order..??

    In which table, i could find order quantity for sales order..??
    and also in which table i could find delivery for sales order..
    need help..??
    Moderator message: please search.
    Edited by: Thomas Zloch on Feb 23, 2012

    Check the table AUFM.
    Give the order number in AUFNR.
    For movement type 261 (GI) & 101 (GR), you can get the material document number (MBLNR), Material (MATNR), Qty (MENGE) & UoM (MEINS).

  • Run Time Error while Entering Quantity in Sales Order

    Dear All,
    Iam getting Run time Error while iam entering material quantity in sales order.Please  find the screenshot of the same.
    kindly Help Me.Me. Plz note that we had done a system copy two days back to our new server.
    Rgds
    Thomson
    ST22 Screenshot

    Dear All
    Its Resolved Thanks For your Valuable time Support
    INCLUDE LV03VFB4 inside below code trigger error.
    PERFORM VVBBD_AUFBAUEN USING WA_AVBBD
                                        WA_AVBBD-APOMOBILE
                                        DA_SUBRC
                                        DA_UPDKZ
                                        DA_VVBBD_TABIX
                                        0.
    This Was the Error some how 0 was there we are removed the 0 now it is working fine
    Rgds
    Thomson

  • How to control not to confirm quantity in sales order schedule line

    Hi,
    We have a problem with confirmed quantity in sales order schedule line.
    When I reject a position in a sales order, confirmed quantity still remains with quantity ( diferent to 0).
    I need in some cases that system not to confirm quantity in schedule line at item level.
    I've tried to do this with a new routine in OVB8 transaction, but it didn't work.
    Could you help me? How can I avoid the system to confirm quantity in a sales order item?
    Thanks in advance....

    Hi Lakshmipathi,
    I'm sorry. The rejection was a bad example.
    I need, in some cases, that the system doesn't confirm quantity in sales orden item. We have a custom field in sales order item and we need to confirm with 0 quantity , when that field has a specific value.
    Due to that field is a custom field, I need an exit, or rutine, or .. i don't know...to inform a standard field too ( delivery block, rejection...) something to get confirmed quantity to 0.
    I've tried with rutine in OVB8. But It didn`t work
    I've tried with delivery block, but with this all items in sales order, confirms with 0. I need at item level.
    Thanks

Maybe you are looking for