Problem in BAPI_SALESORDER_CHANGE

Hi,
i am new to BAPI.
i am trying to execute ZBAPI_SALESORDER_CHANGE in SE37. We have appended VBAK table with zinfo table. our requirement is if i give the sales order no and status field in the input parameter, the particular status field need to change in the VBAK table. i am trying to execute the ZBAPI_SALESORDER_CHANGE in SE37 by enterring sales order and status, i am getting error " Field ABGURU cannot be changed.". i tired to debug the BAPI, but for the particular table order reason is not there.. please tell me whether this is the errr with order reason data or any other problem.

Hi
Please, see these notes:
SAP Note 143580 - Information on SD BAPIs and customer enhancement concept
SAP Note 509898 - BAPI enhancement concept and Unicode
SAP Note 700795 - Enhancement category of BAPI enhancement structures
and related notes
Regards
Eduardo

Similar Messages

  • Problem with BAPI_SALESORDER_CHANGE ("Enter part 2 of the incoterms")

    Hi,
    I have a problem when I try to create Sales Order and change it with BAPI_SALESORDER_CHANGE.
    Logic of my program is
    1. Use BAPI_SALESDOCUMENT_COPY to copy data from Billing to Create SO
    2. Use BAPI_SALESORDER_CHANGE to unblock Billing Block in Sales Order Created from step1
    Problem occurs in step 2. Returning Bapi Error Message that "Enter part 2 of the Incoterms". I already check that after step 1 Sales Order already have incoterm2. And in step 2, I didn't send input parameter 'X' to update fiend incoterm2 (Table order_header_inx1).
    I debug BAPI_SALESORDER_CHANGE and found that my error came from function 'SD_SALES_ITEM_MAINTAIN'. I think that this function is used for update item. I couldn't see why it gave me that error about INCOTERMS2 which is in header.
    Have anyone ever been through the same problem before?
    Thanks,
    Pavin

    I just found the cause of this problem and want to share in this topic.
    Here is the process of BAPI_SALESORDER_CHANGE that cause my problem.
    BAPI_SALESORDER_CHANGE -> SD_SALESDOCUMENT_CHANGE -> SD_SALES_ITEM_MAINTAIN  -> perform vbkd-inco1_pruefen(sapfv45k) -> RV_INCOTERMS_CHECK
    My problem occurs in Function RV_INCOTERMS_CHECK because value in field VBKD-INCO2 is missing. This case only happen when I try to create CFR SO with reference from EXW Billing.
    Hope it's useful.
    Regards,
    Pavin
    Edited by: Pavin P. on Apr 30, 2009 5:15 AM

  • Problem using BAPI_SALESORDER_CHANGE

    Hi Experts,
    I am inserting the Item in Sales order by using BAPI_SALESORDER_CHANGE.
    suppose there are 2 line item in sales i.e. 10 and 20 .
    now i want to insert line item i.e. 30.
    now the problem is that when i am trying to insert line item 30 it is getting inserted.
    but i want to update the quantity for line item 30.
    how to update the quantity of line item 30?
    anybody have the solution?
    Thanks in advance.
    Abhishek

    Hi,
      Fill tables parameter ORDER_ITEM_IN and ORDER_ITEM_INX for the line item you want to update the quantity for the field would be TARGET_QTY and TARGET_QU
    and in the ORDER_ITEM_INX have ITM_NUMBER = '30  the update indicator equal to 'X' and TARGET_QTY = 'X'and  TARGET_QU eq 'X' and that should do it.
    Regards,
    Himanshu

  • Problem with BAPI_SALESORDER_CHANGE function module

    I know lot of posts have been done about problems with this function module. However I was not able to find the answer to my problem. Hence posting a new thread
    I have the following code which changes the reason rejection (if required to 'ZF') and also updates the sales order quantity.
    The code works absolutely fine as long as the PGI date of the order item is either today or in the future. However if the PGI date of the order item is in the past. I get an error in the t_return table with error type 'E' saying 'PGI date is in the past hence could not update the item'.
    If I try to update the same order quantity in VA02 for the item with PGI date in the past it does so without any problem.
    Can someone please suggest what the problem might be. Or if there is some other way I can update the quantity. (I dont want to use BDC)
    FORM change_sales_order_item USING value(r_rtb_posnrs) TYPE zpsd_ztsdrtb_ro_track
                                 CHANGING r_return TYPE type_t_bapiret2.
      DATA: v_order_header_in TYPE bapisdh1,
      v_order_header_inx TYPE bapisdh1x,
      t_schedule_lines TYPE bapischdl OCCURS 0 WITH HEADER LINE,
      t_schedule_linesx TYPE bapischdlx OCCURS 0 WITH HEADER LINE,
      v_temp_rtb_vbeln TYPE vbeln,
      v_temp_rtb_posnr TYPE posnr,
      wa_old_rtb_posnrs TYPE ztsdrtb_ro_track,
      t_item_in TYPE bapisditm OCCURS 0 WITH HEADER LINE,
      t_item_inx TYPE bapisditmx OCCURS 0 WITH HEADER LINE,
      v_rtb_old_vbeln TYPE zrtbvbeln,
      v_rtb_old_posnr TYPE zrtbposnr,
      v_ro_old_vbeln TYPE zrovbeln,
      v_ro_old_posnr TYPE zroposnr,
      v_rtb_count TYPE i,
      v_next_row_index TYPE i,
      v_update_order_flg TYPE char1, "Update the sales order flag
      v_rtb_record_counter TYPE i,
      v_original_vbeln TYPE vbeln,
      t_bapiret TYPE STANDARD TABLE OF bapiret2.
      FIELD-SYMBOLS: <wa_r_rtb_posnrs> TYPE ztsdrtb_ro_track,
                     <wa_r_rtb_posnr_next> TYPE ztsdrtb_ro_track.
      CONSTANTS: c_updateflag TYPE bapisditmx-updateflag VALUE 'U'.
      v_order_header_inx-updateflag = 'U'.
    Get rid of the duplicate records for the same RTB order. Just use
    the last record quantity in the internal table
      LOOP AT r_rtb_posnrs ASSIGNING <wa_r_rtb_posnrs>.
        v_rtb_record_counter = v_rtb_record_counter + 1.
        <wa_r_rtb_posnrs>-seqnr = v_rtb_record_counter.
      ENDLOOP.
      SORT r_rtb_posnrs DESCENDING BY zrtbvbeln zrtbposnr seqnr zrtbconsumedflg.
      DELETE ADJACENT DUPLICATES FROM r_rtb_posnrs COMPARING zrtbvbeln zrtbposnr.
      DESCRIBE TABLE r_rtb_posnrs LINES v_rtb_count.
      v_rtb_record_counter = 0.
      v_update_order_flg = space.
      LOOP AT r_rtb_posnrs ASSIGNING <wa_r_rtb_posnrs>.
        v_rtb_record_counter = v_rtb_record_counter + 1.
        v_update_order_flg = space.
    Popluate the item quantity update flags for schedule lines
        t_schedule_linesx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
        t_schedule_linesx-sched_line = '0001'.
        t_schedule_linesx-updateflag = c_updateflag.
        t_schedule_linesx-req_qty = 'X'.
        APPEND t_schedule_linesx.
        CLEAR t_schedule_linesx.
    *Item (Order QQuantity Field to be changed "KWMENG")
        t_schedule_lines-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
        t_schedule_lines-sched_line = '0001'.
        t_schedule_lines-req_qty = <wa_r_rtb_posnrs>-zrtbchgqty.
        APPEND t_schedule_lines.
        CLEAR t_schedule_lines.
    If fully consumed then set the rejection flag
        IF <wa_r_rtb_posnrs>-zrtbconsumedflg = 'X'.
          t_item_inx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_inx-updateflag = 'X'.
          t_item_inx-reason_rej = 'X'.
          APPEND t_item_inx.
          CLEAR t_item_inx.
          t_item_in-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_in-reason_rej = 'ZF'.
          APPEND t_item_in.
          CLEAR t_item_in.
        ELSE.
          t_item_inx-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_inx-updateflag = 'X'.
          t_item_inx-reason_rej = 'X'.
          APPEND t_item_inx.
          CLEAR t_item_inx.
          t_item_in-itm_number = <wa_r_rtb_posnrs>-zrtbposnr.
          t_item_in-reason_rej = ' '.
          APPEND t_item_in.
          CLEAR t_item_in.
        ENDIF.
    If you have reached the last line of the RTB intern table update the sales order
    *Index pointing to the next row
        v_next_row_index = v_rtb_record_counter + 1.
        IF v_rtb_record_counter = v_rtb_count.
          v_update_order_flg = 'X'.
        ELSEIF v_rtb_record_counter < v_rtb_count.
    Get the next row data
          READ TABLE r_rtb_posnrs INDEX v_next_row_index ASSIGNING <wa_r_rtb_posnr_next>.
          IF sy-subrc = 0.
            IF <wa_r_rtb_posnrs>-zrtbvbeln <> <wa_r_rtb_posnr_next>-zrtbvbeln.
              v_update_order_flg = 'X'.
            ENDIF.
          ENDIF.
        ELSE.
          v_update_order_flg = space.
        ENDIF.
    update the rtb orders with quantities and the rejection flag (if required)
        IF v_update_order_flg = 'X'.
          CALL FUNCTION 'BAPI_SALESORDER_CHANGE' STARTING NEW TASK 'SOUPDATE'
            PERFORMING callbk_bapi_salesorder_change ON END OF TASK
            EXPORTING
              salesdocument    = <wa_r_rtb_posnrs>-zrtbvbeln
              order_header_in  = v_order_header_in
              order_header_inx = v_order_header_inx
            TABLES
              return           = t_return
              schedule_lines   = t_schedule_lines
              schedule_linesx  = t_schedule_linesx
              order_item_in    = t_item_in
              order_item_inx   = t_item_inx.
          WAIT UNTIL t_return[] IS NOT INITIAL.
          READ TABLE t_return INTO wa_return WITH KEY type = 'E'.
          IF sy-subrc <> 0.
          ELSE.
            r_return[] = t_return[].
            MESSAGE ID 'ZSD' TYPE 'E' NUMBER 613.
           RAISE errorinorderupdate.
          ENDIF.
          REFRESH t_schedule_linesx.
          REFRESH t_schedule_lines.
          REFRESH t_item_in.
          REFRESH t_item_inx.
          REFRESH t_return.
        ENDIF.
      ENDLOOP.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       IMPORTING
         return = t_bapiret.
    ENDFORM.                    "Change_Sales_Order

    see the following example and try to do this:
    i_hdrx-updateflag = 'U'.
    *" Fill required SCHEDULE_LINES data.
    i_sched-itm_number = p_posnr.
    i_sched-sched_line = p_etenr.
    i_sched-req_qty = p_reqqty.
    i_schedx-updateflag = 'U'.
    i_schedx-itm_number = p_posnr.
    i_schedx-sched_line = p_etenr.
    i_schedx-req_qty = 'X'.
    APPEND i_sched.
    APPEND i_schedx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_vbeln
    order_header_in = i_hdr
    order_header_inx = i_hdrx
    TABLES
    return = i_ret
    schedule_lines = i_sched
    schedule_linesx = i_schedx.

  • Problem with BAPI_SALESORDER_CHANGE for updating address details

    Hi,
    I am trying to update address details using the bapi BAPI_SALESORDER_CHANGE. I am unable to update. I am populating only the required fields.
    Could anyone tell whats the problem with BAPI?
    Thanks & Regards,
    Yaseen Mahammad.

    Yaseen,
    Do check whether you have passed values to the internal table ORDER_HEADER_INX. You have to pass value to the update field as 'U' and all the fields which you have passed in the header internal table as 'X'.
    and  behave_when_error = 'P'

  • Problem with BAPI_SALESORDER_CHANGE

    Hi Experts,
    I am using the following code to reject the sales orders and to update in the database.
    for the sales orders having multiple line items, when i select only one line item it should update only that particular line item but it is updating all the line items in that sales order.
    can anybody please tell me how to correct this error.
            I_ITEM-ITM_NUMBER = I_SELECTED_SO-POSNR.
            I_ITEM-REASON_REJ = I_SELECTED_SO-ABGRU.
            APPEND I_ITEM. CLEAR I_ITEM.
            I_ITEMX-ITM_NUMBER = I_SELECTED_SO-POSNR.
            I_ITEMX-UPDATEFLAG = 'U'.
            I_ITEMX-REASON_REJ = 'X'.
            APPEND I_ITEMX. CLEAR I_ITEMX.
          Save rejection reason text
            I_TEXT-DOC_NUMBER = I_SELECTED_SO-VBELN.
            I_TEXT-ITM_NUMBER = I_SELECTED_SO-POSNR.
            I_TEXT-LANGU      = SY-LANGU.
            APPEND I_TEXT.
            I_BAPISDH1X-UPDATEFLAG = 'U'.
            CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
              EXPORTING
                SALESDOCUMENT    = I_SELECTED_SO-VBELN
                ORDER_HEADER_IN  = I_BAPISDH1
                ORDER_HEADER_INX = I_BAPISDH1X
              TABLES
                RETURN           = I_RETURN
                ORDER_ITEM_IN    = I_ITEM
                ORDER_ITEM_INX   = I_ITEMX
                ORDER_TEXT       = I_TEXT.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    thanks & regards,
    sudheer

    Not sure why it would update all lines... Could it be something in the configuration or in the user exit that propagates the update from one line to the others?
    I used pretty much the same code with just a few differences and didn't use I_TEXT at all:
    DATA: s_da_order_item_in TYPE t_order_item_in WITH HEADER LINE.
    DATA: s_da_order_item_inx TYPE t_order_item_inx WITH HEADER LINE.
        s_da_order_item_in-material   = it_ztable-matnr.
        s_da_order_item_in-itm_number = it_ztable-posnr.
        s_da_order_item_in-reason_rej = c_abgru.
        APPEND s_da_order_item_in.
        CLEAR  s_da_order_item_in.
        s_da_order_item_inx-updateflag = c_updateflag.
        s_da_order_item_inx-reason_rej = c_updatefield.
        s_da_order_item_inx-itm_number = it_ztable-posnr.
        APPEND s_da_order_item_inx.
        CLEAR  s_da_order_item_inx.
    The rest was the same. It worked perfectly fine.

  • Problem using Bapi_Salesorder_Change (VBAP-ABGRU)

    Hello Guys,
    I currently encounter a big issue using BAPI "Bapi_Salesorder_Change " in order to replace the value stored in field VBAP-ABGRU (from 01 to blank). The system does not make any change even if call function 'BAPI_TRANSACTION_COMMIT' is called.
    Kind regards
    Chris

    Hi,
    Please set:  header_inx-updateflag = 'U' and
                      header_inx-ord_reason = 'X'.
    Try with this code.
    PARAMETERS:
          p_or_res TYPE augru.
    DATA : st_order_header_in  TYPE bapisdh1.
    DATA : st_order_header_inx TYPE bapisdh1x.
      CLEAR st_order_header_in.
      st_order_header_in-ord_reason = p_or_res.
      CLEAR st_order_header_inx.
      st_order_header_inx-updateflag = 'U'.
      st_order_header_inx-ord_reason = 'X'.
      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument               = vbeln
          order_header_in             = st_order_header_in
          order_header_inx            = st_order_header_inx.
    Regards,
    Neenu Jose.

  • Enter Document Number in "BAPI_SALESORDER_CHANGE".

    Hi All,
    I am facing some problem with BAPI_SALESORDER_CHANGE.
    I am trying to update the Sales Order header with the BAPI BAPI_SALESORDER_CHANGE.
    However, I am facing the below error though I pass the Sales document number correctly with all leading zeroes.
    "Enter Document Number".
    When I debugged, I found that it hits a function module SD_SALESDOCUMENT_CHANGE which inturn calls the FM
    SD_SALES_DOCUMENT_READ. Inside the FM SD_SALES_DOCUMENT_READ, I could see that the value is being assigned to
    VBAK-VBELN. But, there is a subroutine which gets executed after that. As soon as it enters in to the subroutine, the value of VBAK-VBELN gets vanished.
    VBAK-VBELN = DOCUMENT_NUMBER.
      PERFORM BELEG_LESEN(SAPMV45A).    "Once it enters inside this subroutine, the value of VBAK-VBELN gets cleared.
      PERFORM KONV_SELECT(SAPFV45P).
    Any pointers on this would be highly appreciated. I have gone through various posts of SDN. But, none of them could help me.
    Note:  When I execute the above FM from SE37, it works fine and the VBAK-VBELN value doesnt get vanish even after entering the above mentioned Subroutine.
    Thanks,
    Babu KIilari

    Hi Babu,
    Just replying to update this thread in case it can help others in the future, as I had a similar issue (at our same client ).  To paraphrase/quote your reply to my mail on similar error " the solution for the same is not the implicit enhancement that we have created there. It was just a temporary solution and as you have highlighted that transport never moved into any other system across the landscape. The actual issue that caused the error was due to a conflict between the subroutine pool and the program SAPMV45A.  Someone had defined a subroutines in SAPMV45A and they were calling the same in the USEREXIT_SAVE_DOCUMENT_PREPARE which I think belongs to the same program. Don’t recall the actual glitch at the variable level, however VBAK-VBELN was being reset by the subroutine pool. Instead of calling the external subroutines from the parent program SAPMV45A, I had created one Subroutine pool and consolidated all the 6 subroutines into it and then I am calling these 6 subroutines from the FM." 
    So your issue was within a sales order change being saved, in the save user-exit, someone was again referring to SAPMV45A which was blanking out VBAK-VBELN as you showed above.
    In my issue, same issue was happening that VBAK-VBELN was disappearing.  The scenario for us was as follows.  We have an interface from a TMS system which can update STOs or Sales Orders (1 doc per IDOC).  We saw the Sales Order IDOCs were sometimes getting a 51 status if the BAPI call failed with V1045 Enter the Document Number.  By the hints above, we suspected somehow SAPMV45A was being called.  By analysis, we realized that the issue happened when an IDOC to do a BAPI_PO_CHANGE preceded the BAPI call for the sales order.  And then debugging showed us that someone had put a user-exit in a gATP exit which was performing a subroutine in SAPMV45A for  an STO (which the logic was only pertinent to SOs).  By going into the SAPMV45A routine, the (SAPMV45A)VBAK-VBELN work area was created albeit empty.  Then, when the Sales Order BAPI gets called (his IDOC was next in line of the IDOC processing program) that blank work area overlaid VBAK-VBELN when code entered into BELEG_LESEN.  Our solution will be to prevent the gATP exit from calling a perform into SAPMV45A when its working with STOs.

  • Part 2 of the "HDMI" problem is now solved.

    I just bought and hooked up the component video cable for my DVD player.  The only other thing I had to do was add a regular audio cable (red and white) to get the sound (after a process of elimination) and I definitely see a huge improvement in the picture quality of my DVDs.  Even though my DVD player doesn't have the HDMI-DVI capacity, the quality of my DVD pictures with the component video cable looks just as good as the quality of my TV programs with the HDMI cable.  I didn't realize that the composite cable was considered the "lowest quality". 
    Now let's see if I can keep the same set up with my existing appliances for the next 10 years....too optimistic?  lol

    I just found the cause of this problem and want to share in this topic.
    Here is the process of BAPI_SALESORDER_CHANGE that cause my problem.
    BAPI_SALESORDER_CHANGE -> SD_SALESDOCUMENT_CHANGE -> SD_SALES_ITEM_MAINTAIN  -> perform vbkd-inco1_pruefen(sapfv45k) -> RV_INCOTERMS_CHECK
    My problem occurs in Function RV_INCOTERMS_CHECK because value in field VBKD-INCO2 is missing. This case only happen when I try to create CFR SO with reference from EXW Billing.
    Hope it's useful.
    Regards,
    Pavin
    Edited by: Pavin P. on Apr 30, 2009 5:15 AM

  • Delete pricing conditions line using BAPI_SALESORDER_CHANGE

    Hi experts.
    I've read the forum and OSS about this topic and don't have clear if it's possible to delete a price condition position (using BAPI). Using tx. VA02 I can delete pricing conditions, that's why I think should be possible.
    We have a sales order created, and depending on the sold-to-party we have some discounts: RA00 (% discount) or RB00 (absolute discounts).
    In some cases we need to insert/update or delete these pricing conditions. For insert/update, we don't have any problem using
    BAPI_SALESORDER_CHANGE and setting the appropiate updateflag.
    But... what would be the procedure to delete a discount, for example, RA00 fixed on a sales order? Has the logic_switch be informed specially?
            wa_cond-itm_number = lt_cond-itm_number.
            wa_cond-cond_type  = lt_cond-cond_type.
            APPEND wa_cond TO i_cond.
            wa_condx-itm_number = lt_cond-itm_number.
            wa_condx-cond_type  = lt_cond-cond_type.
            wa_condx-updateflag = 'D'.
            APPEND wa_condx TO i_condx.
    Lots of thanks.
    Javier

    I am not positive on being able to delete a pricing condition through program.
    Online when you try to change the pricing, SAP suggests us to redetermines the Pricing rather than just changing the values. And also the pricing condition config also plays a role... I think there was a setting which says Pricing condition to be manual which means you can add or delete the conditoin.

  • Update the price related to condtions in Sales Order

    Hi all,
    I want to update the price related to condtions in Sales Order from input file. I am using bapi 'BAPI_SALESORDER_CHANGE' to for this.
    the code for this
        wa_conditions-itm_number = wa_itab-itm_number.
        wa_conditions-cond_value = wa_itab-kbetr.
        wa_conditions-cond_type  = 'ZPSV'.
        wa_conditions-cond_count = wa_itab-kwmeng.
        APPEND wa_conditions TO it_conditions.
        wa_conditionsx-itm_number =  wa_itab-itm_number.
        wa_conditionsx-cond_count = wa_itab-kwmeng.
        wa_conditionsx-cond_value = 'X'.
        wa_conditionsx-cond_type  = 'ZPSV'.
        wa_conditionsx-updateflag = 'U'.
        APPEND wa_conditionsx TO it_conditionsx.
    But this is creating a new line in conditions instead of updating the existing line, I want to update the exsting line with new condition rate instead of creating a new line.
    i have tried by   lv_logic-pricing = 'B'.
    But it works when values are maintained in vk11.
    Please help me if you have any soultion for this.

    hi siya,
    plz refer to the following threads
    Re: problem using Bapi_Salesorder_Change
    http://www.sapfans.com/forums/viewtopic.php?p=160339&sid=bf9e3219db318d89596f7e911462416f
    i hope it helps.
    arjun

  • Problem while changing Sales order using 'BAPI_SALESORDER_CHANGE'

    Hi all,
    Below is my code to update delivery block value:
    FORM call_bapi_salesorder_change .
    DATA:  iv_bapi_view  LIKE order_view.
    DATA: gt_sales_doc TYPE STANDARD TABLE OF sales_key, " Document Numbers to Be Selected
            gt_items TYPE STANDARD TABLE OF bapisdit. " Order Item Data for Document Numbers
    *************************************************************8
    DATA:order_headers_out LIKE bapisdhd OCCURS 0 WITH HEADER LINE.
    DATA:order_header_inx LIKE bapisdh1x.
      DATA: lv_salesdocument LIKE bapivbeln-vbeln.
      data: lv_matnr(10) type c.
      DATA:
    gt_schdule TYPE STANDARD TABLE OF bapischdl, " for gl date & load date
    gt_schdulex TYPE STANDARD TABLE OF bapischdlx, " for partner role and partner function.
            gt_return TYPE STANDARD TABLE OF bapiret2,
            gt_itemin TYPE STANDARD TABLE OF bapisditm,
            gt_iteminx TYPE STANDARD TABLE OF bapisditmx ,
            gt_bapisdh1 TYPE STANDARD TABLE OF  bapisdh1.
      DATA:gs_head_bapi TYPE bapisdh1x,
           gs_schdule TYPE bapischdl,
           gs_schdulex TYPE bapischdlx,
           gs_return TYPE bapiret2,
           gs_itemin TYPE bapisditm,
           gs_iteminx TYPE bapisditmx,
           gs_bapisdh1 TYPE bapisdh1.
      CLEAR : gt_schdule,gt_schdulex,gs_return.
      REFRESH gt_return.
      gs_head_bapi-updateflag = 'U'.
    SORT gt_final BY vbeln.
    CLEAR gs_vbep.
    REFRESH gt_vbep[].
      CLEAR gs_final.
      LOOP AT gt_final1 INTO gs_final.
        gs_itemin-itm_number = gs_final-posnr.
    *move gs_final-matnr to lv_matnr."qx94162
       gs_itemin-material = gs_final-matnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = gs_final-matnr
          IMPORTING
            output = gs_final-matnr.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = lv_matnr
        IMPORTING
         output = lv_matnr.
       gs_itemin-material = lv_matnr.
        gs_itemin-material = gs_final-matnr.
        gs_iteminx-itm_number = gs_final-posnr.
        gs_iteminx-updateflag = 'U'.""changed to I
        gs_iteminx-material = 'X'.
        " gs_schdule-req_dlv_bl = gs_final-lifsp. " Delivery block
        gs_schdule-itm_number = gs_final-posnr.
        gs_schdulex-itm_number = gs_final-posnr.
        gs_schdule-sched_line = '0001'.
        gs_schdulex-sched_line = '0001'.
       MOVE gs_final-lifsp to gs_schdule-req_dlv_bl.
        gs_schdule-req_dlv_bl = gs_final-lifsp.
        gs_schdulex-req_dlv_bl = 'X'. " Delivery block
        gs_schdulex-updateflag = 'U'.
        gs_bapisdh1-sales_org = gs_final-vkorg.
        APPEND gs_schdule TO gt_schdule.
        APPEND gs_schdulex TO gt_schdulex.
        APPEND gs_itemin TO gt_itemin.
        APPEND gs_iteminx TO gt_iteminx.
       Append gs_BAPISDH1 to gt_BAPISDH1.
        lv_salesdocument = gs_final-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument               = lv_salesdocument     
           ORDER_HEADER_IN             = gs_BAPISDH1
            order_header_inx            = gs_head_bapi         
      SIMULATION                  =
      BEHAVE_WHEN_ERROR           = ' '
      INT_NUMBER_ASSIGNMENT       = ' '
      LOGIC_SWITCH                =
      NO_STATUS_BUF_INIT          = ' '
          TABLES
            return                      = gt_return            
       order_item_in               =    gt_itemin
       order_item_inx              = gt_iteminx
      PARTNERS                    =
      PARTNERCHANGES              =
      PARTNERADDRESSES            =
      ORDER_CFGS_REF              =
      ORDER_CFGS_INST             =
      ORDER_CFGS_PART_OF          =
      ORDER_CFGS_VALUE            =
      ORDER_CFGS_BLOB             =
      ORDER_CFGS_VK               =
      ORDER_CFGS_REFINST          =
          schedule_lines                = gt_schdule           
          schedule_linesx               = gt_schdulex          
      ORDER_TEXT                  =
      ORDER_KEYS                  =
      CONDITIONS_IN               =
      CONDITIONS_INX              =
      EXTENSIONIN                 =
      NFMETALLITMS                =
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        REFRESH: gt_schdule, gt_schdulex, gt_itemin , gt_iteminx.
        LOOP AT gt_return INTO gs_return.
          WRITE / gs_return-message .
        ENDLOOP .
      ENDLOOP.
    ENDFORM.                    " CALL_BAPI_SALESORDER_CHANGE
    When I am using material value as 18342 using CONVERSION_EXIT_ALPHA_OUTPUT:
    ORDER_HEADER_IN has been processed successfully
    Material  is not defined for sales org.A101,  distr.chan.00,  language DE
    Error in ITEM_IN 000030
    SCHEDULE_IN has been processed successfully
    The sales document is not yet complete: Edit data
    Sales document 5010000715 was not changed
    and when I am using CONVERSION_EXIT_ALPHA_INPUT (000000000000018342)or  while debuging when I am changing value to  0018342 :
    I am getting below dump:
    Runtime Errors         DATA_LENGTH_0
    Exception              CX_SY_RANGE_OUT_OF_BOUNDS
    Date and Time          21.10.2010 07:22:17
    Information on where terminated
         Termination occurred in the ABAP program "SAPLVBAK" - in
          "MAP_VBAP_TO_BAPISDIT".
         The main program was "RS_TESTFRAME_CALL ".
         In the source code you have the termination point in line 168
         of the (Include) program "LVBAK001".
         The termination is caused because exception "CX_SY_RANGE_OUT_OF_BOUNDS"
          occurred in
         procedure "MAP_VBAP_TO_BAPISDIT" "(FORM)", but it was neither handled local
          nor declared
         in the RAISING clause of its signature.
         The procedure is in program "SAPLVBAK "; its source code begins in line
         99 of the (Include program "LVBAK001 ".
    The same dump I am getting while executing this above BAPI from SE37 tcode with the same test data.
    but I am able to change it though Va02 tcode.
    Edited by: Arora26 on Oct 21, 2010 7:58 AM

    Hi,
    have you searched for OSS notes? The note 1137897 looks like related to your problem. It mentions different BAPI but I assume that both BAPI reuse same routines and therefore it might solve your problem as well.
    Cheers

  • BAPI_SALESORDER_CHANGE -Problem in Background

    Hi all,
    There is a requirement to change pricing conditions in Sales order.The pricing condition is based some values passed in tab
    additional data B. Am using the standard BAPI for modifying the value.
    But the changed pricing appears only when the SO is opened in Change mode but not in display mode.On adding the
    LOGIC_SWITCH -PRICING = 'B', this problem was eliminated.But now wat happens is if there are two pricing conditions, only the first condition appears in display mode whereas both conditions appear in change mode.
    Tried adding LOGIC_SWITCH --cond_handl = 'X' but to no avail, still the same. can anyone help me please.
    This problemm is faced only wen the BAPI_SALESORDER_CHANGE is run in Background.
    Else everything is fine in Foreground.
    Thanks in advance.

    HI kavitha
    I used the same bapi to update pricing field for sales order.
    Please specify which fields you want to update.
    are these fields present in bapi import or tables parameters.
    If no then these fields are Z fields and they have to be enhanced in tables first and then in exit.
    below is the demo program to pass z fields (ZZAGMID ) in bapi ( note : tables has to be enhanced before )
    this code will help u to understand how to update z fields
    let me if you are not able to follow..
    REPORT  ZTEST_BAPI.
    PARAMETERS: P_VBELN TYPE VBAK-VBELN,
                p_posnr TYPE vbap-posnr,
                P_AGMID type BAPE_VBAP-ZZAGMID.
    DATA: T_LINE LIKE BAPISDITM OCCURS 0 WITH HEADER LINE.
    DATA: T_LINEX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.
    DATA: T_EXTEN LIKE BAPIPAREX OCCURS 0 WITH HEADER LINE.
    DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
    DATA: BAPE_VBAP LIKE BAPE_VBAP.
    DATA: BAPE_VBAPX LIKE BAPE_VBAPX.
    DATA: ORDER_HEADERX LIKE BAPISDH1X.
    DATA: BAPE_VBAK type BAPE_VBAK .
    DATA: BAPE_VBAKX LIKE BAPE_VBAKX.
    DATA: W_RETURN LIKE BAPIRET2.
    data: v_val TYPE BAPIPAREX-VALUEPART1.
    data: v_number(5) TYPE c.
    ORDER_HEADERX-UPDATEFLAG = 'U'.
    T_LINE-ITM_NUMBER = p_posnr.
    T_LINE-PLANT = '5AP1'.
    APPEND T_LINE.
    T_LINEX-ITM_NUMBER = p_posnr.
    T_LINEX-UPDATEFLAG = 'U'.
    T_LINEX-PLANT = 'X'.
    APPEND T_LINEX.
    T_EXTEN-STRUCTURE = 'BAPE_VBAP'.
    BAPE_VBAP-vbeln = p_vbeln.
    BAPE_VBAP-posnr = p_posnr.
    BAPE_VBAP-ZZAGMID = P_AGMID.
    T_EXTEN+30 = BAPE_VBAP.
    APPEND t_exten.
    BAPE_VBAPX-VBELN = P_VBELN.
    BAPE_VBAPX-POSNR = p_posnr.
    BAPE_VBAPX-ZZAGMID = 'X'.
    T_EXTEN-STRUCTURE = 'BAPE_VBAPX'.
    T_EXTEN+30 = BAPE_VBAPX.
    APPEND T_EXTEN.
    IMPORT v_number from MEMORY ID v_number.
    BREAK-POINT.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_vbeln
    order_header_inx = ORDER_HEADERX
    tables
    return = T_RETURN
    ORDER_ITEM_IN = T_LINE
    ORDER_ITEM_INX = T_LINEX
    EXTENSIONIN = T_EXTEN.
    call function 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    * WAIT =
    * IMPORTING
    * RETURN =
    CLEAR: W_RETURN.
    LOOP AT T_RETURN INTO W_RETURN.
    WRITE: W_RETURN-MESSAGE,/.
    ENDLOOP.

  • BAPI_SALESORDER_CHANGE problem: change sold-to-party

    Hi guys,
    I am having a problem with my current dev. I am using BAPI_SALESORDER_CHANGE to change the sold-to of a sales order.
    However, I am getting error message: "You cannot change entry in partner function XX".
    Can anyone help me on this?
    Thanks!
    jac

    hi,
    REPORT  ZMYBAPI2                                .
    data : ordervbeln like bapivbeln occurs 0 with header line,
           order_header_in like bapisdh1 occurs 0 with header line,
           order_header_ix like bapisdh1x occurs 0 with header line.
    data : order_items_in like bapisditm  occurs 0 with header line,
           order_items_ix like bapisditmx occurs 0 with header line.
    data : order_partners like bapiparnr occurs 0 with header line.
    data : return1 like bapiret2 occurs 0 with header line.
    data : w_vbeln like bapivbeln occurs 0 with header line.
    data:
         order_schedules_in like bapischdl occurs 0 with header line,
         order_schedules_inx like bapischdlx occurs 0 with header line.
    order_header_in-sales_org  = 'JNJ1'.
    order_header_in-distr_chan = '02'.
    order_header_in-division   = 'J1'.
    order_header_in-sales_off  = 'JNJ1'.
    order_header_in-purch_no_c = 'testbapipo'.
    order_header_in-purch_date = sy-datum.
    order_header_in-req_date_h = sy-datum.
    append order_header_in.
    order_items_in-material      = '000000000000000727'.
    order_items_in-plant         = 'JNJ1'.
      append order_items_in.
      order_partners-partn_role = 'AG'.
      order_partners-partn_numb = '0000000011'.
      append order_partners.
      order_schedules_in-itm_number = '10'.
      order_schedules_in-req_qty   = '10'.
      append order_schedules_in.
    *Updating the indices
      order_header_ix-updateflag = 'U'.
      order_header_ix-sales_org  = 'X'.
      order_header_ix-distr_chan = 'X'.
      order_header_ix-division   = 'X'.
      order_header_ix-sales_off  = 'X'.
      order_header_ix-purch_no_c = 'X'.
      order_header_ix-purch_date = 'X'.
    order_header_ix-req_date_h = 'X'.
      append order_header_ix.
      order_items_ix-updateflag    = 'U'.
      order_items_ix-material      = 'X'.
      order_items_ix-plant         = 'X'.
      order_items_ix-division      = 'X'.
      order_items_ix-target_qu     = 'X'.
      append order_items_ix.
      order_schedules_inx-updateflag        = 'U'.
      order_schedules_inx-itm_number       = 'X'.
      order_schedules_inx-req_qty          = 'x'.
      append order_schedules_inx.
    call function 'BAPI_SALESORDER_CHANGE'
      exporting
       salesdocument               =
       ORDER_HEADER_IN             = order_header_in
        order_header_inx            = order_header_ix
      SIMULATION                  =
      BEHAVE_WHEN_ERROR           = ' '
      INT_NUMBER_ASSIGNMENT       = ' '
      LOGIC_SWITCH                =
      tables
        return                      = return1
       ORDER_ITEM_IN               = order_items_in
       ORDER_ITEM_INX              = order_items_ix
       PARTNERS                    = order_partners
      PARTNERCHANGES              =
      PARTNERADDRESSES            =
      ORDER_CFGS_REF              =
      ORDER_CFGS_INST             =
      ORDER_CFGS_PART_OF          =
      ORDER_CFGS_VALUE            =
      ORDER_CFGS_BLOB             =
      ORDER_CFGS_VK               =
      ORDER_CFGS_REFINST          =
       SCHEDULE_LINES              = order_schedules_in
      SCHEDULE_LINESX             =
      ORDER_TEXT                  =
      ORDER_KEYS                  =
      CONDITIONS_IN               =
      CONDITIONS_INX              =
      EXTENSIONIN                 =
    if sy-subrc ne 0.
        write: return1-message,return1-number,return1-type.
      else.
          write: return1-message,return1-number,return1-type.
          call function 'BAPI_TRANSACTION_COMMIT'
       EXPORTING
         WAIT          =
       IMPORTING
         RETURN        =
      endif.
    This may give an idea, This program written on 4.6B.
    still u r problem not solved, please post the code
    regards,
    pavan

  • Problem in BAPI  'BAPI_SALESORDER_CHANGE'.

    Hi All,
    I am facing a problem in BAPI  'BAPI_SALESORDER_CHANGE'. My requirement is as below.
    For a particular type of Sales Order i have to update all the ship-to PO.Basically in all these PO's we have to suffix
    'old'.
    I am pasting the code which I used. I am actually displaying the return message in a table.
    The message says 'Schedule Order is saved'.
    When i go and check the SO the ship-to PO is not updated.
    Also i have one more querry.
    Is thsi BAPI to be run for each item or can i collect all items in t_item_in and then call the BAPI.
    Please guide me on this.
    Thanks in Advance,
    Saket.
    LOOP AT t_vbkd INTO wa_vbkd.
    CONCATENATE wa_vbkd-bstkd_e '-' v_po INTO v_po_ref.
    t_item_in-purch_no_c    = v_po_ref.
    t_item_inx-purch_no_c   = v_po_ref.
    t_item_inx-updateflag  = 'X'.
      APPEND t_item_in.
      APPEND t_item_inx.
    *LOOP AT t_vbak INTO wa_vbak.
    v_vbeln = wa_vbkd-vbeln.
    w_headerx-updateflag = 'U'.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
      EXPORTING
        SALESDOCUMENT               = v_vbeln
        ORDER_HEADER_INX            = w_headerx
      TABLES
        RETURN                      = t_return
        ORDER_ITEM_IN               = t_item_in
        ORDER_ITEM_INX              = t_item_inx.
    READ TABLE t_return WITH KEY type = 'E'.
      IF sy-subrc = 0.
        t_output-rmks = t_return-message.
      ELSE.
        t_output-rmks = t_return-message.
      ENDIF.
      READ TABLE t_vbak INTO wa_vbak
       WITH KEY vbeln = v_vbeln.
      t_output-vbeln = v_vbeln.
      t_output-auart = wa_vbak-auart.
      t_output-vkorg = wa_vbak-vkorg.
      t_output-bstkd_e_old = wa_vbkd-bstkd_e.
      t_output-bstkd_e_new = t_item_in-purch_no_c.
      APPEND t_output.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = 'X'
    IMPORTING
      RETURN        =
    ENDLOOP.

    REPORT  ZSALESORDER_CHANGE MESSAGE-ID 38.
    PARAMETERS: p_vbeln TYPE vbap-vbeln OBLIGATORY, "Order Number
    p_posnr TYPE vbap-posnr OBLIGATORY, "Order Item
    p_etenr TYPE vbep-etenr OBLIGATORY, "Schedule Line
    p_reqqty TYPE bapischdl-req_qty OBLIGATORY. " Order Qty
    DATA: i_hdr TYPE bapisdh1,
    i_hdrx TYPE bapisdh1x,
    i_ret TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
    wa_ret TYPE bapiret2.
    DATA: BEGIN OF i_sched OCCURS 10.
    INCLUDE STRUCTURE bapischdl.
    DATA: END OF i_sched.
    DATA: BEGIN OF i_schedx OCCURS 10.
    INCLUDE STRUCTURE bapischdlx.
    DATA: END OF i_schedx.
    START-OF-SELECTION.
    REFRESH: i_sched, i_schedx, i_ret.
    CLEAR: i_sched, i_schedx, i_ret.
    i_hdrx-updateflag = 'U'.
    i_sched-itm_number = p_posnr.
    i_sched-sched_line = p_etenr.
    i_sched-req_qty = p_reqqty.
    i_schedx-updateflag = 'U'.
    i_schedx-itm_number = p_posnr.
    i_schedx-sched_line = p_etenr.
    i_schedx-req_qty = 'X'.
    APPEND i_sched.
    APPEND i_schedx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_vbeln
    order_header_in = i_hdr
    order_header_inx = i_hdrx
    TABLES
    return = i_ret
    schedule_lines = i_sched
    schedule_linesx = i_schedx.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    LOOP AT i_ret.
    WRITE / i_ret-message.
    ENDLOOP.
    http://abap.wikiprog.com/wiki/BAPI_SALESORDER_CHANGE
    Edited by: krupa jani on Jul 30, 2009 9:22 AM

Maybe you are looking for