Extension of BAPI - BAPI_SALESORDER_CHANGE

Hi All,
I have added some custome fields in the table VBAK. Now i want to update these fields using BAPI_SALESORDER_CHANGE which are not present in it currently. So how can i extend BAPI to update the custom fields ???

Hi,
first, go to SE37 and check the BAPI's default documentation for the EXTENSIONIN table parameter. There, it explains analytically what you have to do in order to update Z fields that have been appended in VBAK or VBAP through the standard BAPI.
NOTE that you MUST have updated accordingly the tables/structures VBAKKOZ, VBAKKOZX, BAPE_VBAK, BAPE_VBAKX
So, if the sales order number is 1000000001 and your added custom field is named ZZCUST with length 5 chars and you want to set the ZZCUST value to ABCDEm, then append a line in EXTENSIOIN as follows:
EXTENSIONIN-STRUCTURE = BAPE_VBAK
EXTENSIONIN-VALUEPART1 = 1000000001ABCDE
Also, call the BAPI passing the 1000000001 (sales order document number to the SALESDOCUMENT parameter and set the UPDATEFLAG field of the structure ORDER_HEADER_INX to 'X' to make the BAPI actually update the sales document header data (includind the new Z field).
Try it and READ the BAPI's standard documentation!
Reward if it helps,
Regards,
George

Similar Messages

  • Unable to update sales order unsing the BAPI 'BAPI_SALESORDER_CHANGE'

    Hi All,
    I am unable to update the payment method field for some sales orders using the bapi 'BAPI_SALESORDER_CHANGE'. I am getting the reason in the table RETURN as 'Field 'ZLSCH' cannot be changed, VBAPKOM 000050  ready for input'.
    Could anyone throw some light on it.
    Thanks a ton.
    Regards,
    Santosh Kotra.

    Hi
    Without reversing invoice we can't update price and this is standard bevaior which is logical too. For your scenario I am wondering why would you want to change price for a line item or order which is alrady invoiced and posted to FI. What difference would it make to change price in sale order when this has already been posted in FI?
    Thank$

  • 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

  • BAPI: BAPI_SALESORDER_CHANGE - Document Change History

    Hi ,
    When I change a Sales Order usingthe BAPI: BAPI_SALESORDER_CHANGE, will it create the change history for the document?
    Appreciate Your help.
    Thanks,
    Kannan.

    Transaction is SCDO and look at object called VERKBELEG
    Check the below link :
    http://help.sap.com/saphelp_nw04s/helpdata/en/c7/69bccff36611d3a6510000e835363f/content.htm
    Thanks
    Seshu

  • Updating Condition Rate in SO using BAPI 'BAPI_SALESORDER_CHANGE'

    Hi,
    I want to update the price related to condtions(both automatic and manual) in Sales Order items from input file. I am using bapi 'BAPI_SALESORDER_CHANGE' to for this.
    I used follwing code,
    wa_so_cond-itm_number = wa_input-so_item.
    wa_so_cond-cond_type  = wa_input-kschl.
    wa_so_cond-cond_st_no = '011'.
    wa_so_cond-cond_count = '00'.
    wa_so_cond-cond_value = wa_input-kbetr.
    APPEND wa_so_cond TO i_so_cond.
    CLEAR wa_so_cond.
    wa_so_condx-itm_number = wa_input-so_item.
    wa_so_condx-cond_type  = wa_input-kschl.
    wa_so_condx-cond_st_no = '011'.
    wa_so_condx-cond_count = '00'.
    wa_so_condx-updateflag = c_u.
    wa_so_condx-cond_value = c_x.
    APPEND  wa_so_condx TO i_so_condx.
    CLEAR wa_so_condx.
    But this is creating a new line in conditions instead of updating the existing line, even though the existing line is a inactive by crerating a new line I want to update the exsting line with new condition rate instead of creating a new line. Please help me if you have any soultion for this.
    Thanks in Advance,
    Prasad JVV.

    Hi Sandipan,
    I used APPEND to fill the conditions_in & conditions_inx, without filling the tables how can I modify?
    Thanks,
    Prasad JVV.

  • Performance of bapi BAPI_SALESORDER_CHANGE.

    Now we meet the reqeust to split the order item by quantity in order to assign wbs number to each material
    For example the sales order contains one item with 10 Qty and we need to split to 10 items and each item with 1Qty
    Order:
         Line 0001          Material            10Qty
    Change to:
        Line  0001          Material            1Qty      WBS-001
        Line  0002          Material            1Qty      WBS-002
        Line  0003          Material            1Qty      WBS-003
        Line  0010          Material            1Qty      WBS-010
    We used bapi BAPI_SALESORDER_CHANGE to do above process but the run time seems very slowly (time out)
    I tried to delete the schedule_lines and schedule_linessx from import for test.
    it runs fast but the result is there is no quantity in each line item.
    without schedule_line import, the order will be:
        Line  0001          Material            0Qty      WBS-001
        Line  0002          Material            0Qty      WBS-002
        Line  0003          Material            0Qty      WBS-003
        Line  0010          Material            0Qty      WBS-010
    Does any one tried BAPI BAPI_SALESORDER_CHANGE and met the same problem (slowly)?
    And any suggestion?
    Thank you very much!

    Hi,
    BAPI_SALESORDER_CHANGE should not raise time out,
    unless you process huge amount of data.
    Maybe some data are locked or some user-exit causes infinite loop or incorrect select on large table.
    Try to perform runtime analysis with small amount of data,
    and during execution check SM12 for locks and SM50 for sequential reads.
    Regards,
    Przemysław

  • BAPI  'BAPI_SALESORDER_CHANGE'

    Hello guru's,
    I am trying to figure out why my bapi is not working. I hope that someone can help me out.
      SELECT *
        FROM vbak
        INTO TABLE it_vbak
        WHERE vbeln = '3245349'.
      LOOP AT it_vbak into wa_vbak.
        CLEAR : s_bapisdh1 , s_bapisdh1x.
        MOVE : 'U'  TO s_bapisdh1x-updateflag,
               'X'  TO s_bapisdh1x-dlv_block,
               'Z9' TO s_bapisdh1-dlv_block.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument    = wa_vbak-vbeln
            order_header_in  = s_bapisdh1
            order_header_inx = s_bapisdh1x
          TABLES
            return           = it_bapiret2.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDLOOP
    Thanks.

    SELECT *
        FROM vbak
        INTO TABLE it_vbak
       you need to append the internal table before passing it to BAPI.
    WHERE vbeln = '3245349'.
      LOOP AT it_vbak into wa_vbak.
        CLEAR : s_bapisdh1 , s_bapisdh1x.
        MOVE : 'U'  TO s_bapisdh1x-updateflag,
               'X'  TO s_bapisdh1x-dlv_block,
               'Z9' TO s_bapisdh1-dlv_block.
             Append s_bapisdh1x.
            Append s_bapisdh1.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument    = wa_vbak-vbeln
            order_header_in  = s_bapisdh1
            order_header_inx = s_bapisdh1x
          TABLES
            return           = it_bapiret2.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDLOOP

  • Extension of BAPI's

    Baseline Information:
    -- We are running SAP ECC v6.
    -- We have added two new columns to the Equipment Master database, on the EQUI table.  These columns are entitled GUIDNO and Z_GISGRID.  These columns were added to the EQUI table within the SAP-delivered customer Include entitled "CI_EQUI".
    -- we've looked at the method using "Extension In" and "Extension Out" parameters.  The BAPI's were not configured by SAP to include these parameters.  Plus, we not sure we completely understand the use of these parameters to extend the BAPI if we were to create the extensions ourselves.
    Challenge:
    We want to add the ability to update these columns from the SAP-delivered BAPI's BAPI_EQUI_CREATE and BAPI_EQUI_UPDATE.  We also want to include these columns in the return structures from the BAPI_EQUI_GETDETAIL call.
    We are struggling with modifying these BAPIs to include these columns in such a way that the BAPIs will still "survive" a future upgrade.  What is the SAP-prescribed method for adding new columns to these BAPIs?

    Hi,
    you can try to enhance the BAPI  using enhancement framework - particularly enhance function module interface and implicit enhancement points. Recently I briefly described how you can do it for BAPI BAPI_BILLINGDOC_CREATEMULTIPLE. Have a look at [this thread|Extend BAPI_BILLINGDOC_CREATEMULTIPLE?;. Similarly, you can add an optional structure/table to BAPI interface and then find a suitable enhancement point to populate standard table.
    Cheers

  • BAPI 'BAPI_SALESORDER_CHANGE' - Change a field

    Hi all!
    I am doing an exercise which it's necessary to change just one field (PO number) in a sales order using the BAPI from the subject. After the execution of the BAPI, "return" table shows the following message:
    E   |V2                  |051   |Terms of delivery FH are not defined.    <
    E   |V4                  |219   |Sales document 0000001666 was not changed<
    Here follows the code:
    DATA: " for BAPI use
        v_vbeln LIKE vbak-vbeln, " order that i would like to change
        v_order_header_in LIKE bapisdh1,
        v_order_header_inx LIKE bapisdh1x,
        v_purch_no_c LIKE bapisdh1-purch_no_c, "
        v_return LIKE TABLE OF bapiret2.
    INITIALIZATION.
      p_vbeln = 1666.
      v_order_header_inx-updateflag = 'U'.
      v_order_header_inx-purch_no_c = 'X'.
      CONCATENATE 'test_' v_purch_no_c INTO v_purch_no_c.
      v_order_header_in-purch_no_c = v_purch_no_c.
      v_order_header_inx-purch_no_c = 'X'.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument               = v_vbeln
          order_header_in             = v_order_header_in
          order_header_inx            = v_order_header_inx
        TABLES
          return                      = v_return.
    If sy-subrc = 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    What does the error "Terms of delivery FH are not defined" mean? Did i forget to import an obligatory entry?
    Thanks a lot!

    Hi guys!
    after a lot of tries i found what this error means. Let me explain what was the problem:
    I was trying to update a single field at the sales order (po number), but l didn't see that this order had another field with a value ("FH") which was deleted and was get from another table.
    So as you just specify in BAPI which fields you would like to change when in an update, problably the BAPI try to keep the rest of the fields without doing any kind of check. And this resulted in my problem with that error message.
    Can i go ahead at this and ask if there is a way to make BAPI check the fields not specified at the import of the function?
    Thanks a lot for everybody who tried to help me.

  • Can't update Configuration via BAPI  BAPI_SALESORDER_CHANGE

    According to  Note 562124 - Configuration change via BAPI.
    I create a customer  program to change characteristic value in SO by BAPI_SALESORDER_CHANGE
    It is confused , I can change the 'from value' (BAPICUVA-VALUE) successfully, but I can't change the 'To value' (BAPICUVAL-VALUE_TO)  for characteristic.
    What is the reason, anyone come across this problem?

    Any suggestion?

  • Extension of BAPI

    Hi All,
    I want to extend the BAPI - "BAPI_CTRACDOCUMENT_CHANGE".
    There is a parameter "EXTENSIONIN" in the tables part of the BAPI. But, I don't know, how to extend it.
    I want to pass the Vtref of Dfkkop to the BAPI to update the contract for a particular Document no.
    Can anyone please help me with this?
    Helpful answers will be rewarded.
    Thanks & Regards,
    Anshumita Baksi.

    Hi,
    SAP help covers this decision making rather extensively here:
    http://help.sap.com/saphelp_nw04/helpdata/en/6b/3f6d016d0711d396a50004ac96334b/frameset.htm
    You need to consider upgrades and the BOR objects themselves as you move toward object oriented programming.  You most likely want to extend the object by creating a subtype.  See the documentation and examples in the link above.
    Sincerely,
    Ray Mannion

  • Custom fields update using BAPI: BAPI_SALESORDER_CHANGE

    Hi,
          I have append one field into VBAP Table, and i want to update that filed value by using BAPI_SALESORDER_CHANGE FM. I have done all the coding but still its not updating the table. I have checked with SAP fields like order quantity, its upadating the database but the custom fileds are not upadting.
    steps i have done:  Append field to :           VBAP,BAPE_VBAP,VBAPKOZ
                                   Append Check field to : BAPE_VBAPX,VBAPKOZX
    Here is the code : plz check and add ur comments
      DATA : l_wa_bapiparex        TYPE bapiparex,
             l_wa_ord_header        TYPE bapisdh1x,
             l_itab_bapiparex      TYPE STANDARD TABLE OF bapiparex INITIAL SIZE 0,
             l_itab_return         TYPE STANDARD TABLE OF bapiret2   INITIAL SIZE 0,
             l_wa_item              TYPE bapisditm,
             l_itab_item           TYPE STANDARD TABLE OF bapisditm  INITIAL SIZE 0,
             l_wa_itemx             TYPE bapisditmx,
             l_itab_itemx          TYPE STANDARD TABLE OF bapisditmx INITIAL SIZE 0,
             ORDER_HEADER_IN       LIKE BAPISDH1.
      l_wa_ord_header-updateflag = 'U'.
      ORDER_HEADER_IN-REF_DOC = '0000000244'.
    *Populate Item detail
      l_wa_item-itm_number = '000010'.
      l_wa_item-NET_WEIGHT = '5000'.
      APPEND l_wa_item TO l_itab_item.
    *Populate Item detail checkbox
      l_wa_itemx-itm_number = '000010'.
      l_wa_itemX-NET_WEIGHT = 'X'.
      l_wa_itemx-updateflag = 'U'.
      APPEND l_wa_itemx TO l_itab_itemx.
      l_wa_bapiparex-structure = 'BAPE_VBAP'.
      l_wa_bapiparex-valuepart1+0(10) = '0000000244'.
      l_wa_bapiparex-valuepart1+10(6) = '000010'.
      l_wa_bapiparex-valuepart1+16(15) = 'ABCDEF'.
      APPEND l_wa_bapiparex TO l_itab_bapiparex.
      CLEAR l_wa_bapiparex.
      l_wa_bapiparex-structure = 'BAPE_VBAPX'.
      l_wa_bapiparex-valuepart1+0(10) = '0000000244'.
      l_wa_bapiparex-valuepart1+10(6) = '000010'.
      l_wa_bapiparex-valuepart1+17(1) = 'X'.
      APPEND l_wa_bapiparex TO l_itab_bapiparex.
      clear l_wa_bapiparex.
      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument    = '0000000244'
          order_header_in  = ORDER_HEADER_IN
          order_header_inx = l_wa_ord_header
        TABLES
          return           = return
          order_item_in    = l_itab_item
          order_item_inx   = l_itab_itemx
         schedule_lines   = l_itab_schedule
         schedule_linesx  = l_itab_schedulex
          extensionin      = l_itab_bapiparex.
    IF SY-SUBRC = 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          = 'X'
    IMPORTING
      RETURN        =
    ELSE.
       RAISE ERROR.
    ENDIF.
    I HAVE GONE THROUGH DEBUGGING AND FOUND ALL ARE GOING FINE...ITS UPDATING VBKOM AND VBKOMX STRUCTURE BUT AT LAST ITS NOT UPDATING THE CUSTOM FIELDS
    Thanks,
    Baidya

    Sorry guys........this code is correct one.......there is a problem in IDES....i tried in client server its working fine
    If anyone is having this type of requirement then copy this program.
    thanks,
    Baidya

  • Extension to Bapi

    There is a bapi BAPI_BUPA_CREATE_FROM_DATA for creation of business partners. I need to extend this bapi by adding few custom fields.
    What is the method to follow inorder to extend this bapi and please give me the procedure so that it helps me...
    Thanks,
    Vinod

    Hi Vinod,
    You can use EEWB to add custom fields to the Business Partner. You need not enhance the bapi BAPI_BUPA_CREATE_FROM_DATA.
    EEWB : You will need to create a project there and assign an package. And then decide whether customization or workbench.
    Just refer the link below to add custom fields to BP through EEWB :
    http://help.sap.com/saphelp_crm50/helpdata/en/20/a4ffee7e0fcc4ebb7e5466d3903d38/frameset.htm
    After adding the fields through EEWB, just create the Business Partner using the bapi BAPI_BUPA_CREATE_FROM_DATA.
    After creating the business partner call the function module BUPA_CENTRAL_CI_CHANGE to populate the custom fields added through the EEWB transaction.
    <b>Reward points if it helps.</b>

  • Populate Z fields or extension on BAPI

    Hi
    I'm adding a sales order using VC, adds the sales order fine.
    But now there are custom fields we have added in SAP on the sales order screen. Need to populate these trhough VC.
    I'm using BAPI_SALESORDER_CREATEFROMDAT2, the custom fields are meant to be populated via tables paramter extensionin.
    But the problem is I have to pass a structure type, then a structure with all the values. So if I did this in ABAP I would have a internal table and pass this along. How do I do this in VC???
    Or is there another way to update these fields?
    Thanks in advance

    Hi Louis,
    I have done something similar with purchase requisitions and Adobe forms. It should work for VC the same  way I think.
    The ExtensionIn structure of the BAPI import parameters is what you need to fill. I think you should be able to pass your structure name directly to the field EXTENSIONIN-STRUCTURE. Then you need to pass to EXTENSIONIN-VALUEPART1, a concatenated string that has the field values for your structure in the appropriate positions with spaces as filler if needed.
    so for example if your structure is something like
    field1 CHAR5
    field2 CHAR2
    field3 CHAR30
    and your values are
    field1  'test'
    field2  empty
    field3  'a'
    you would pass
    "test   a"
    where there are 3 spaces between "test" and "a".
    Does that make sense? It's been a while since I did this but I am pretty sure this is the way it's done.
    Hope it helps.
    Margaret

  • How to use Extension parameter in BAPI

    Hi,
    Can anyone provide any clue about how to use the EXTENSION paramenters in BAPI? Thanks.
    Regards,
    Chris

    Hi,
    just check this thread you can get some idea how to use extension in BAPI.
    BAPI_ACC_DOCUMENT_POST  (EXTENSION)
    Regards
    Vijay

Maybe you are looking for