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

Similar Messages

  • 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

  • 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

    Hi Friends,
    I am having a problem in BAPI when i am executing the program i am getting a error message like this,
    <b>Error message:</b>
    144The field MARA-MEINS/BAPI_MARA-BASE_UOM(_ISO) is defined as a required field; it does not contain an entry   .
    any solutions to the above problem.
    I am sending the code along with this mail.
    <b>coding:</b>
    REPORT ZYC_BAPI_MATERIAL_CREATE .
    STRUCTURE DECLARATIONS *
    TABLES: BAPIMATHEAD, "Headerdata
    BAPI_MARA, "Clientdata
    BAPI_MAKT, "Material description
    BAPIRET2. "Return messages
    data : bapi_mara1 LIKE bapi_mara. "Client Data
    DATA:V_FILE TYPE STRING.
    DATA:
    BEGIN OF LSMW_MATERIAL_MASTER,
    MATNR(018) TYPE C, "Material number
    MBRSH(001) TYPE C, "Industry sector
    MTART(004) TYPE C, "Material type
    MAKTX(040) TYPE C, "Material description
    MEINS(003) TYPE C, "Base unit of measure
    END OF LSMW_MATERIAL_MASTER.
    INTERNAL TABLE DECLARATIONS *
    *to store the input data
    DATA: BEGIN OF it_matmaster OCCURS 0.
    INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
    DATA: END OF it_matmaster.
    *for material description
    DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT .
    DATA:END OF IT_MATERIALDESC.
    *to return messages
    DATA:BEGIN OF IT_RETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA:END OF IT_RETURN.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1 .
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = SYST-CPROG
    DYNPRO_NUMBER = SYST-DYNNR
    FIELD_NAME = 'P_FILE'
    IMPORTING
    FILE_NAME = P_FILE.
    TO UPLOAD THE DATA *
    START-OF-SELECTION.
    V_FILE = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = V_FILE
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    tables
    data_tab = IT_MATMASTER
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    OTHERS = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    DATA POPULATIONS *
    LOOP AT IT_MATMASTER.
    BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
    BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
    BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-MTART.
    BAPIMATHEAD-BASIC_VIEW = 'X'.
    refresh it_materialdesc.
    IT_MATERIALDESC-matl_desc = IT_MATMASTER-maktx.
    append IT_materialdesc.
    bapi_mara1-base_uom = 'TO'. "it_matmaster-meins.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    headdata = BAPIMATHEAD
    CLIENTDATA = BAPI_MARA
    CLIENTDATAX = BAPI_MARAx
    IMPORTING
    RETURN = IT_RETURN
    TABLES
    MATERIALDESCRIPTION = IT_MATERIALDESC.
    WRITE:/ IT_RETURN-TYPE,
    2 IT_RETURN-ID,
    22 IT_RETURN-NUMBER,
    25 IT_RETURN-MESSAGE.
    ENDLOOP.
    Regards,
    Dinesh

    Hi
    Basic Unit of Measure is required field in the material master
    You are not populating it in the Bapi
    populate it in the CLIENTDATA
    IT WILL SOLVE THE ISSUE.
    CLIENTDATA-BASE_UOM = it_matmaster-meins
    Reward points if useful
    Regards
    Anji

  • Problem with BAPI BAPI_REQUISITION_CREATE

    Hello,
    I have problems with BAPI BAPI_REQUISITION_CREATE. I need to create Purchase requisition for services. If I use BAPI BAPI_REQUISITION_CREATE, Purchasing requisition is created, but field NETWR in table EBNK is 0. If I create purchasing requisition manualy using transaction ME51N, field NETWR in table EBNK is filled with correct price.
    Can you pls. help me, what do I wrong in calling BAPI_REQUISITION_CREATE?
    Thanks&regards,
    Jirka

    Not sure if you got your answer or went to OSS for a resolution. But, as I was searching OSS for my issue, I came across the following note:
    Note 1498435 - BAPI_REQUISITION_CREATE: EBKN-NETWR is not updated

  • 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.

  • Problem in bapi enstension in BAPI_SALESORDER_CHANGE

    Hi All,
    I am trying  to updating on z-field by using bapi extension in valuepart1 by passing to BAPI_SALESORDER_CHANGE,
    do i need to write the code for mapping  to z-field from extension structure ?
    if yes what is the user exit/enhancement name ?
    Regards,
    Suresh.

    Hi Suresh,
    We don't need to write any code in exits for the extended fields. you just need to pass the parameters properly in EXTENTIONIN paramter in BAPI_SALESORDER_CHANGE. Make sure to watch character lengths in VALUEPART1.
    Rgs,
    Khanshi

  • 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?

  • Problem using BAPI to create Service Confirmation in CRM

    Good afternoon all.
    I have raised this is CRM forum too, just thought it best to ask the broader ABAP community the question too.
    We are encountering a problem using a BAPI to create a transaction in CRM, specifically:
    I am trying to create a Service Confirmation (BUS2000117) in a CRM system using the BAPI BAPI_BUSPROCESSND_CREATEMULTI.
    The BAPI succeeds in creating the header of the transaction, but I cannot make the BAPI create any other data in the transaction such as partners or items.
    Just want to be sure that I am not being foolish...has anyone succeeded in using this BAPI to create an error-free Service Confirmation?
    Regards
    Nick

    I am going to pop this thread into General ABAP forum too.
    Nick

  • Problem with BAPI of Material Master creation

    Hi,
    I am creating material master(mm01) through BAPI_MATERIAL_SAVEDATA.
    Program is working fine but when i m checking in MM03 to display uploaded data through BAPI, i cant able to see material which i created to through BAPI but i can see in MARA table.
    i dont know wht is the problem ?
    can anybody let me know abt this ?

    then u are not committing the work.
    flow will be like this
    call ' BAPI'
    if return[] is initial.
    commit work.
    else.
    endif.
    Regards
    peram

  • A problem about bapi dd check

    Hi, all.
        I tried to use arfc2 to call a bapi to get PO data from R/3 in 7.1.1. So I did model binding for my component controller`s context. Then I tried to get the result from these parameters programly. But I always got dd check error.
    For example. If an attribute "A" `s data type is int. But the attribute "A" is empty in R/3, so it always returns " " to the attribue "A". Then it will raise an dd check error. The bapi which I used is BAPI_PO_GET_LIST. There are many attributes with this bapi. How can I solve this problem?
    Thanks.

    Hi,
    please check if the below link can help in your case.
    [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bc_db/~form/handler]
    Regards
    Narendra
    Edited by: Narendra Singh on Apr 3, 2009 11:54 AM

  • Sneak Preview - problems getting BAPI into VC

    Hi everybody,
    I installed Full Java Edition 2004s Release SAP NetWeaver 04s SP7 on Windows XP SP2 to test Visual Composer.
    First I defined an R/3 System (4.6 C) in portal and did the user mapping for this system. For testing the connection to R/3 with the WinGUI I generated an iView. Using this iView to logon via SSO to the R/3 system with the mapped user-id and password worked fine.
    Next step was to try out the bank example in Visual Composer. When seraching for bapis in the defined R/3 system Visual Composer got connection problems.
    In R/3 system's log I found the request of Visual Composer. My user-id was transfered well but the password apparently wasn't. The errormessage in the log said, that there are problems with user-id or password.
    After spending a lot of time with solving this problem by myself unsuccessfully I post this message and hope that anybody can help.
    Michael

    Hi Michael,
    Please make sure you followed the steps below, as I faced similar problem, for accessing R/3 System Alias and BAPI's ofcourse on Visual Composer.
    a. <b>Create a system alias from Administrator Login credentials on Portal (assume, you have done the same).</b>
    b. Usermapping done for the System Alias with proper R/3 login credentials.
    c. Now try to access the system alias created by reloging to VC and search for BAPI's.
    For the query that you have posted, hopefully this should solve your problem.

  • Problem for Bapi Call  in Integration Scenario

    Hi
    I am creating an Integration Scenario at Design time which can be used during configuration time.In the Int. Scenario, I am using a Int Process(BPM). I am making a synchronous call to BAPI from my BPM. How can this be implemented in Integration Scenario.
    So how can I send a input message from BPM to BAPI and then take further steps only after getting response from BAPI. Is there any way to define synchronous Action in Int Scenario??? And another point to be noted is that we are not using any communication channel to send the message from BPM or receive the response in BPM. We have only a receiver communication channel which receives the message for the BAPI.
    So please help in solving this problem.
    regards,
    Biranchi

    > Thanks for ur reply. I am trying to follow the suggestion given by u. U have specified that the BAPI  in R/3 system has to be inserted as an application component. But I am unable to do that. I am using IDES system for the BAPI,but in the selection screen for the Application Component we have only instances of installed product in the SLD. So how to find out the application component to be imported.
    >
    What you need to do is, first of all your import the BAPI (RFC) into XI system. (I hope you must be knowing how to import the RFC & IDOCs into XI system). Make sure this BAPI is remote-enabled under attribute TAB in R3 ---> SE37.
    Now this imported BAPI (RFC) will be used in your message interfaces and this message interface will be used inside ACTION. And then you can use this action in your Integration Secnario as mentioned in the picture above in my first reply.
    Sorry for the confusion, you need to R3 business system name rather inserting the BAPI as a business system under 3rd swim lane.
    > And another problem is that I have to create an action for in the application Component containing BAPI and then it should be connected to the action in BPM for interaction. I have created one action for this and given the BAPi as both outbound and inbound interface. Is this the proper way to do this???
    >
    As mentioned above, after you import the BAPI (RFC) in XI you can create the messge interface. There should be two Message Interfaces. One for sending the request and other for receiving the response message.
    Regards,
    Sarvesh

Maybe you are looking for

  • Unable to format external hard drive

    so I'm trying to replace the hard drive in my MacBook Pro. I bought a 2.5 inch hard drive and a caddy to transfer the data with. according to the internet, I had to "erase" it, first. which is fine. but every time I try to erase it, it says "file sys

  • I need to move my itunes library to new PC?

    I have to move my itunes library to my new laptop. How would I do this? Bearing in mind I have an iPhone, iPod, and ipad, i want to keep all stuff on it, contacts, messages, apps and music etc. thanks Joshua.

  • Mac OS X Lion Server - Clean Installation

    I do have a Mac mini server with OS X Snow Leopard Server. I would like to go to Lion Server but I don't want to use the default installation method. I understood, that Lion Server usually is no operating system but an App, which is to be installed b

  • How do I save a Quicktime MP3 that I have downloaded in a Safari browser?

    My friend has uploaded a new mix cd in mp3 format onto his website as a link. When I click on the link it opens in Safari and starts to playback in a quicktime window. Once the download is complete, how do I save this to my hard disk?

  • After EM agent installation, only database is not visible in EM Grid Contro

    Dear All, I am using Oracle 10g2 database. I have a problem with EM agent configuration. After installation the database (SID=BITEX) is not visible in the EM Grid Control, which is installed on the other host. Listener, ASM and host are visible and s