Calling a Sales Order Change BAPI in a Sales Order Exit

Functional Requirement:
While creating a Sales Order with Reference to another Sales Order, on saving the new sales order, change something in the referenced sales order.
I am trying to achieve the same by doing the following:
In the standard SAP user exit called during saving the new sales order USEREXIT_SAVE_DOCUMENT I am calling the BAPI BAPI_SALESORDER_CHANGE on the referenced Sales Order.
However the BAPI is unable to change the other sales order giving an error Enter the document number. I am specifying the Document Number while calling the BAPI, so I know that is not the error.
I just wish to know whether it is technically possible to call a BAPI to update another Sales Order while we are currently saving one Sales Order.

Hi Girish,
If it works correctly when run seperately and you are sure the data passed into the BAPI is exactly the same then it may be something like table locks or similar causing your original problems...
What about packaging up your working Z program into a custom function module and calling that from within USEREXIT_SAVE_DOCUMENT as a seperate task (IN NEW TASK) and building in a slight delay of say 5 seconds at the start of your code?
I'll be honest, this isn't an ideal solution but might be sufficient to resolve your issues.  I'd be inclined to see if you could just run your Z program as a background process every 5 minutes or so to capture any changes and perform updates but if this is a no no from your functional people I'm not sure what else to suggest sorry.  I've never personally had to update a document from within the save routine of another document so can't give any advice based on my own experiences sorry.
Gareth.

Similar Messages

  • Sale Order change BAPI - Storage loc not updated

    Hi Everybody,
    Iam using "BAPI_SALESORDER_CHANGE", to change the sale order items.
    First iam calling above bapi with switch B, for new pricing & then second time for material change.
    When i change any material number, it is getting updated correctly.
    But the storage location, even though iam passing in the bapi it is not updated, & is blank - updation flag is also passed.
    When i execute sale order change again it is updated - ie, for any material change for first bapi call, storage loc is not updated - for 2nd bapi call storage loc is updation - for same input in both the cases.
    Is there any way to update the storage loc is first call of sales order change bapi.
    Below is the parameters iam passing in bapi :
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          SALESDOCUMENT      = LS_SALESDOCUMENT
          ORDER_HEADER_IN    = LT_HEADER_IN
          ORDER_HEADER_INX   = LT_HEADER_X
        TABLES
          RETURN                            = LT_RETURN
          ORDER_ITEM_IN               = LT_ITEMS
          ORDER_ITEM_INX             = LT_ITEM_X
          ORDER_CFGS_REF          = LT_CFGS_REF
          ORDER_CFGS_INST         =  LT_PARTS
          ORDER_CFGS_VALUE     = LT_VALUES
          ORDER_CFGS_BLOB        = LT_CUBLOB
          ORDER_CFGS_VK            = LT_CUVK
          ORDER_CFGS_REFINST   = LT_CUREF
          SCHEDULE_LINES            = LT_SCHEDULE_L
          SCHEDULE_LINESX         = LT_SCHEDULE_X
          ORDER_TEXT                   = LT_TEXT
          CONDITIONS_IN                = LT_CONDITION_L
          CONDITIONS_INX              = LT_CONDITION_X.
    Any help is appreciated.
    Regards,
    Nagarajan.J

    Hi,
    Storage location is updated only when same sale order bapi is called another time with required details.
    rgs,
    Nagarajan J

  • Extending sales order change BAPI and updating custom fields

    Hi
    i added 3 new fields into VA01/02/03 screen.i added at the header level in the additional data tab B area and appended them in VBAK table.
    i want to change these values using sales order change BAPI.i added the fields in the structure VBAKKOZ,VBAKKOZX,BAPE_VBAK,BAPE_VBAKX.
    may i know what else i need to do?should i move them anywhere with in the code or does the bapi take those values automatically using EXTENSIONIN structure?
    also can some one send me code to actually check if bapi is changing my values?
    if poss tell me how should i populate values into BAPI.

    After adding field in structures VBAKKOZ,VBAKKOZX,BAPE_VBAK,BAPE_VBAKX, create pair of name-value pair extensiot structure and value.
    Fill values as follows :
    Data :   ls_parex  TYPE  bapiparex,
                lt_parex  TYPE STANDARD TABLE OF  bapiparex.
    ls_parex-structure = 'BAPE_VBAK'.
    ls_parex-valuepart1+0(10) = Sales order no
    ls_parex-valuepart1+10(XX) = somevalue.  <---- Value for custom field no 1
    ls_parex-valuepart1+XX(XX) = somevalue.  <---- Value for custom field no 2
    APPEND ls_parex TO lt_parex  .
    clear ls_parex.
    ls_parex-structure = 'BAPE_VBAKX'.
    ls_parex-valuepart1+0(10) = Sales order no
    ls_parex-valuepart1+10(1) = 'X'. <--- checkbox mark for custom field no 1
    ls_parex-valuepart1+11(1) = 'X'. <--- checkbox mark for custom field no 2
    APPEND ls_parex TO lt_parex.
    Same pair for VBAKKOZ & VBAKKOZX
    Updating custom fields
      CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          salesdocument    = Sales order number
          order_header_inx = 'U'   <--- U for update
        TABLES
          extensionin      = lt_parex[].
    Edited by: nkarwa on Oct 25, 2010 12:39 PM

  • Credit card handling using sales order change BAPI

    Hi all,
      Currently, I am working on creating a custom BAPI for changing the sales order information. I am having a scenario where I need to handle multiple credit cards during the change of the sales order data. For example, if I have created a sales order  with a credit card A and a bill amount of 100. Now, in the change BAPI, I need to handle the situation like I would be getting two credit cards data out of which I need to Bill against credit card A with 200 and credit card B with 300. I need to see the entries in the sales order processing in the following fashion:
    During the creation:
    Credit card type    Credit card number    Maximum amount  Limit To
    AMEX                   A                             100                        Flag checked
    After performing change order:
    Credit card type    Credit card number    Maximum amount  Limit To
    AMEX                   A                             100                       Flag checked
    VISA                    B                              300                       Flag checked
    AMEX                   A                             100                       Flag checked
    Which implies that I am billing 200 against card A and 300 against card B.
    I want to acheive this functionality. Can any one throw some light in order to accomplish my task?
    Thanks in advance,
    From,
    Adithya

    i already used same But it's not working
    s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
    BAPISDITM
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
    BAPISDITMX
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

  • Sales Order Change BAPI - Reason for Rejection

    Hi,
    I want to update reason for rejection field for a particular sales order at item level. When I am executing the BAPI "BAPI_SALESORDER_CHANGE", I am getting the error "Field header_inx-updateflag is not an input field". I did not check this field as I'm not making any change in the header part.
    Please help me in resolving this issue. Let me know if I have to provide any other information.
    regards,
    ravikiran.

    Found BAPI myself...... BAPI_SALESORDER_CHANGE

  • Sales order change BAPI not updating items Profit center

    Dear ,
    I am facing the problem in using the BAPI for Item 's profit centre  in blank space.
    I write down the below code <but it's not at all updating the profite centre .
    please ccorrect the code if any required'
    TYPES: BEGIN OF file_data ,
           vbeln TYPE vbap-vbeln, " order numner
           posnr TYPE vbap-posnr, " orderitem
           profit_ctr TYPE vbap-prctr, " [profite centre
          END OF file_data.
    DATA: t_data TYPE STANDARD TABLE OF file_data .
    DATA : wa_data LIKE LINE OF t_data.
    DATA: t_data_item TYPE STANDARD TABLE OF file_data .
    DATA : wa_data_item LIKE LINE OF   t_data_item.
    **DATA: t_data_item TYPE file_data OCCURS 0.
    *DATA: return TYPE STANDARD TABLE OF bapiret2.
    *DATA: wa_return LIKE LINE OF return.
    DATA: wait LIKE bapita-wait VALUE 'X'.
    DATA: s_order_header_in LIKE bapisdh1.
    DATA: s_order_header_inx LIKE bapisdh1x.
    DATA: BEGIN OF i_order_item_in OCCURS 0.
            INCLUDE STRUCTURE bapisditm.
    DATA: END OF i_order_item_in.
    DATA: BEGIN OF i_order_item_inx OCCURS 0.
            INCLUDE STRUCTURE bapisditmx.
    DATA: END OF i_order_item_inx.
    DATA: BEGIN OF it_return OCCURS 0.
            INCLUDE STRUCTURE bapiret2.
    DATA: END OF it_return.
    ***********************selection
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS : file LIKE rlgrap-filename OBLIGATORY.
    "ctu_mode  TYPE ctu_mode  DEFAULT 'N'.
    SELECTION-SCREEN END OF BLOCK b1.
    *********assign file
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
      CLEAR file.
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = file
        EXCEPTIONS
          OTHERS    = 1.
      DATA:  it_text TYPE truxs_t_text_data .
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = 'X'
          i_line_header        = 'X'
          i_tab_raw_data       = it_text
          i_filename           = file
        TABLES
          i_tab_converted_data = t_data[] " Your internal table of structure of Excel sheet
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      t_data_item[] =  t_data[].
      DELETE ADJACENT DUPLICATES FROM t_data COMPARING vbeln.
    Header update indicator
      s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

    i already used same But it's not working
    s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
    BAPISDITM
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
    BAPISDITMX
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

  • Sales Order Change BAPI Extension for Customer Fields

    Hello!
    I am working on customer field enhancement for BAPI_salesorder_change. The extensionin parameter has more than 1000 characters (fields in the structure BAPE_VBAP) and hence, the two fields that I added to VBAP (using append structure) are not getting the data.
    I have followed all the steps that was given in the documentation to fill extensionin like adding the fields to VBAPKOZ and BAPE_VBAP. This is the logic I have used to fill EXTENSIONIN:
    BAPE_VBAP-VBELN = P_order.
    BAPE_VBAP-POSNR = i_vbap-posnr.
    BAPE_VBAP-ZZSTART_DT = sy-datum.
    BAPE_VBAP-ZZdnload_DT = sy-datum.
    T_EXTEN-STRUCTURE = 'BAPE_VBAP'.
    *T_EXTEN+30 = BAPE_VBAP.
    T_EXTEN-valuepart1 = bape_vbap.
    T_EXTEN-valuepart2 = bape_vbap+240(240).
    T_EXTEN-valuepart3 = bape_vbap+480(240).
    T_EXTEN-valuepart4 = bape_vbap+720(240).
    APPEND T_EXTEN.
    Clear t_exten.
    BAPE_VBAPX-VBELN = P_order.
    BAPE_VBAPX-POSNR = i_vbap-posnr.
    BAPE_VBAPX-ZZSTART_DTX = 'X'.
    BAPE_VBAPX-ZZdnload_DTX = 'X'.
    T_EXTEN-STRUCTURE = 'BAPE_VBAPX'.
    T_EXTEN-valuepart1 = bape_vbapx.
    APPEND T_EXTEN.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_order
    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'
    I guess there is 960 character limitation for BAPIPAREX structure but I would like to know if there is a way to work around it.
    Thanks to all for your time.

    Found BAPI myself...... BAPI_SALESORDER_CHANGE

  • Using Planned order Change BAPI with out changing date

    Hi
    I have a planned order with start date in future.
    With in a program, I want to call the planned order using the FM BAPI_PLANNEDORDER_CHANGE to re-explode the order BOM.
    I find that only if I change the order start date to system/current date, the planned order BOM gets updated/re-exploded. Else there is no change in the order BOM.
    My requirement is to re-explode the BOM with out changing the order dates. In the function module I am maintaining "X' against BOM_EXP_FIX_IND.
    But when I do it manually using MD12 and explode BOM with out changing the future start date, the order BOM gets updated.
    Please help on this. Or is there any other FM/BAPI for this purpose.

    Dear Pradeep,
    you could try to set DET_SCHEDULE = X with out
    FIRMING_IND  --> No
    BOM_EXP_FIX_IND   --> No
    Let me Know if it modification setting have solved your problem and i have useful for you,
    Daniele

  • Need FM or BAPI to create Notification Order (Like TCode IW34)

    Hi PLM Expert,
    Can you give hints to create Notification Order (Like TCode IW34) from FM or BAPI?
    Thanks in advance,
    Gilang

    Hello Raj and other experts, I need help creating a a maint order referencing notification. I am using method CREATETONOTIF to create Order refer notification. I am successful in creating order however bapi is creating two orders. One without reference to notification and second one with reference to notification. Please note i have to use create header object type and method 'Create' as well.
    If i get rid of first method below it_methods - Object id header & Method create so i only execute method called CREATETONOTIF , i get a error on "Enter another operation number" from bapi . Your help would be greatly appreciated. I am stuck on this error now.

  • Production order changes Tracing

    dear all,
    in the production order how can i find out who make changes like delete materials if there are many people can use co02 , I need to make a tracing to a particular order , is there's any log to do this?
    thanks in advance
    Milad

    There is no std T code available for check the changes made in production order
    IF you want you need to activate the OCM or apply the note 390635
    please refer below thread
    Process Order Change Log history
    Re: Production Order Change Management

  • Photo order changes when burn CD

    I created iPhoto album in a certain order. When I burn CD the order changes, seemingly randomly. The order of the show is important. How do I prevent this? Thank you, MP

    The order is probably alpha-numeric, based on the File Name of the photos. iPhoto allows you to change the photo's title, but to change the file name you must export a copy outside of iPhoto.
    Select your album. Then export to a desktop folder, with "use album name" checked. If your album is named "Winter" then the photos will be names "Winter 01," "Winter 02," etc. Your order should be preserved.
    If your photo titles are important, you could pad the beginning of each title with a numeral. Then export with "use title" checked, and the file name will become the photo's title.

  • To update conditiontype values using change BAPI of sales order

    Hi Gurus,
    i am using the standard bapi 'BAPI_SALESORDER_CHANGE' and i am passing the values for the conditiontypes as follows.......
    vbeln is my sales order number..
    wa_conditions_in-itm_number = '00010'.
    wa_conditions_in-cond_count = '01'.
    wa_conditions_in-cond_type = 'ZCUS'.
    wa_conditions_in-applicatio = 'V'.
    wa_conditions_in-cond_value =  '1000.00'.
    wa_conditions_in-currency = 'INR'.
    wa_conditions_in-cond_p_unt = '1'.
    wa_conditions_inx-itm_number = '00010'.
    wa_conditions_inx-cond_count = '01'.
    wa_conditions_inx-cond_type = 'ZCUS'.
    wa_conditions_inx-updateflag = 'U'.
    wa_conditions_inx-cond_value = 'X'.
    wa_conditions_inx-currency = 'X'.
    wa_conditions_inx-cond_p_unt = 'X'.
        APPEND wa_conditions_in TO conditions_in.
        APPEND wa_conditions_inx TO conditions_inx.
    CLEAR : order_header_in, order_header_inx.
    order_header_in1-purch_no_c = 'Order'.
    order_header_inx1-purch_no_c = 'X'.
    order_header_in1-purch_no_s = 'Order'.
    order_header_inx1-purch_no_s = 'X'.
    order_header_inx1-updateflag = 'U'.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
      EXPORTING
        salesdocument               = vbeln
        order_header_in             = order_header_in1
        order_header_inx            = order_header_inx1
      SIMULATION                  =
      BEHAVE_WHEN_ERROR           = ' '
      INT_NUMBER_ASSIGNMENT       = ' '
      LOGIC_SWITCH                =
      TABLES
        return                      = return
       conditions_in               = conditions_in
       conditions_inx              = conditions_inx
      EXTENSIONIN                 =
    while executing in the order it is not updating the value for the condition type 'ZCUS' and it is inserting as new record.
    Please help me in this regard.
    Thanks & Regards,
    R.P.Sastry

    HI,
    Take the below sample code. for example and try to use like that.
    REPORT ZTEST_BAPI .
    Data: salesd like BAPIVBELN-VBELN.
    data: it_BAPISDH1 type BAPISDH1.
    data: it_BAPISDH1X type BAPISDH1X.
    data: it_BAPIPARNR type BAPIPARNR occurs 0 with header line.
    data: it_BAPIRET2 type BAPIRET2 occurs 0 with header line.
    data: it_BAPIPARNRC type BAPIPARNRC occurs 0 with header line.
    data: it_BAPISDITMX type BAPISDITMX occurs 0 with header line.
    data: it_BAPISDITM type standard table of BAPISDITM with header line.
    constants: c_bp(2) type c value 'BP'.
    it_BAPISDH1X-UPDATEFLAG = 'U'.
    it_BAPISDH1X-SALES_ORG = 'X'.
    it_BAPISDH1X-DISTR_CHAN = 'X'.
    it_BAPISDH1X-DIVISION = 'X'.
    it_BAPISDH1X-PURCH_NO_C = 'X'.
    it_BAPISDH1X-CUST_GROUP = 'X'.
    it_BAPISDH1-SALES_ORG = '1000'.
    it_BAPISDH1-DISTR_CHAN = '01'.
    it_BAPISDH1-DIVISION = '00'.
    it_BAPISDH1-PURCH_NO_C = 'Test1'.
    it_BAPIPARNR-PARTN_ROLE = 'RE'.
    it_BAPIPARNR-PARTN_NUMB = '0000000171'.
    it_BAPIPARNR-ITM_NUMBER = '00000'.
    append it_BAPIPARNR.
    it_BAPIPARNR-PARTN_ROLE = 'RE'.
    it_BAPIPARNR-PARTN_NUMB = '0000000179'.
    it_BAPIPARNR-ITM_NUMBER = '000000'.
    append it_BAPIPARNR.
    it_BAPIPARNRC-DOCUMENT = '000000375'.
    it_BAPIPARNRC-ITM_NUMBER = '000000'.
    it_BAPIPARNRC-UPDATEFLAG = 'U'.
    it_BAPIPARNRC-PARTN_ROLE = 'WE'.
    it_BAPIPARNRC-P_NUMB_OLD = '0000000171'.
    it_BAPIPARNRC-P_NUMB_NEW = '0000000179'.
    it_BAPIPARNRC-ADDRESS = '26324'.
    it_BAPIPARNRC-ADDR_LINK = '0000000003'.
    it_BAPIPARNRC-REFOBJTYPE = 'BUS2032'.
    it_BAPIPARNRC-REFOBJKEY = '000000375'.
    append it_BAPIPARNRC.
    data PARTNERADDRESSES like BAPIADDR1 occurs 0 with header line.
    PARTNERADDRESSES-ADDR_NO = '0000000003'.
    PARTNERADDRESSES-NAME = 'Test Cust'.
    PARTNERADDRESSES-STREET = '222nd AVE'.
    PARTNERADDRESSES-NAME_2 = 'NEW Bldg A2'.
    PARTNERADDRESSES-CITY = 'MILPITAS'.
    PARTNERADDRESSES-REGION = 'CA'.
    PARTNERADDRESSES-POSTL_COD1 = '950351'.
    PARTNERADDRESSES-COUNTRY = 'IN'.
    PARTNERADDRESSES-LANGU = 'E'.
    APPEND PARTNERADDRESSES. CLEAR PARTNERADDRESSES.
    it_BAPISDITMX-ITM_NUMBER = '00010'.
    it_BAPISDITMX-UPDATEFLAG = 'U'.
    it_BAPISDITMX-MATERIAL = 'X'.
    it_BAPISDITMX-CUST_GROUP = 'X'.
    append it_BAPISDITMX.
    it_BAPISDITM-ITM_NUMBER = '00010'.
    it_BAPISDITM-MATERIAL = '946'.
    append it_BAPISDITM.
    break-point.
    salesd = '0000000375'.
    call function 'BAPI_SALESORDER_CHANGE'
    exporting
    salesdocument = salesd
    ORDER_HEADER_IN = it_BAPISDH1
    order_header_inx = it_BAPISDH1X
    SIMULATION =
    BEHAVE_WHEN_ERROR = ' '
    INT_NUMBER_ASSIGNMENT = ' '
    LOGIC_SWITCH =
    tables
    ORDER_ITEM_IN = it_BAPISDITM
    ORDER_ITEM_INX = it_BAPISDITMX
    PARTNERS = it_BAPIPARNR
    return = it_BAPIRET2
    PARTNERCHANGES = it_BAPIPARNRC
    PARTNERADDRESSES = 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 =
    SCHEDULE_LINESX =
    ORDER_TEXT =
    ORDER_KEYS =
    CONDITIONS_IN =
    CONDITIONS_INX =
    EXTENSIONIN =
    If sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    RETURN =
    . endif.
    You need to sepaeately use the *Update* and *Change*  and *Insert* flags while filling the data
    Thanks!
    Edited by: Mr. M on Jan 9, 2009 6:23 PM

  • Change of open sales order : using BAPI

    Hi
       this  is ravi
                      can any one help me on this  topic
            1)change of open sales order  using BAPI .With appropriate reason( like header level reason)
                       thanks & regards

    hI,
        chk this FM BAPI_SALESORDER_PROXY_UPLOAD how the FM BAPI_SALESORDER_CHANGE was used
    Check this code,
    REPORT Z_SALES_ORDER_CHANGE
    NO STANDARD PAGE HEADING
    LINE-SIZE 132
    LINE-COUNT 65(0)
    MESSAGE-ID ZZ.
    TABLES: VBAP.
    DATA:
    V_FILEIN(90) TYPE C,
    V_RECIN TYPE I,
    V_RECVBAP TYPE I,
    V_RECORDER TYPE I,
    V_VBELN LIKE VBAP-VBELN,
    ORDERHEADERINX LIKE BAPISDH1X.
    DATA: BEGIN OF I_ORDERS OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    BRGEW(18) TYPE C,
    VOLUM(18) TYPE C,
    END OF I_ORDERS.
    DATA: BEGIN OF I_OUTPUT OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    GEWEI LIKE VBAP-GEWEI,
    BRGEW LIKE VBAP-BRGEW,
    VOLUM LIKE VBAP-VOLUM,
    CKWGT TYPE C,
    CKVOL TYPE C,
    END OF I_OUTPUT.
    DATA: BEGIN OF ORDERITEMIN OCCURS 0.
    INCLUDE STRUCTURE BAPISDITM.
    DATA: END OF ORDERITEMIN.
    DATA: BEGIN OF ORDERITEMINX OCCURS 0.
    INCLUDE STRUCTURE BAPISDITMX.
    DATA: END OF ORDERITEMINX.
    DATA: BEGIN OF RETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF RETURN.
    DATA: BEGIN OF BAPIRETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF BAPIRETURN.
    PARAMETERS:
    P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,
    P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.
    START-OF-SELECTION.
    CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE
    CONCATENATE P_PATH P_FNAME INTO V_FILEIN.
    OPEN DATASET
    IF V_FILEIN IS INITIAL.
    MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.
    ELSE.
    OPEN DATASET V_FILEIN
    FOR INPUT
    IN TEXT MODE.
    IF SY-SUBRC = 0.
    READ DATASET
    DO.
    READ DATASET V_FILEIN INTO I_ORDERS.
    IF SY-SUBRC = 0.
    APPEND I_ORDERS.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET
    CLOSE DATASET V_FILEIN.
    IF SY-SUBRC <> 0.
    MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.
    ENDIF.
    ELSE.
    MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.
    ENDIF.
    ENDIF.
    SORT AND REMOVE DUPLICATES FROM I_ORDERS
    SORT I_ORDERS BY VBELN POSNR.
    DELETE ADJACENT DUPLICATES FROM I_ORDERS.
    POPULATE I_OUTPUT
    LOOP AT I_ORDERS.
    SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.
    CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.
    SELECT SINGLE BRGEW VOLUM
    FROM VBAP
    INTO (VBAP-BRGEW, VBAP-VOLUM)
    WHERE VBELN = I_ORDERS-VBELN
    AND POSNR = I_ORDERS-POSNR.
    IF SY-SUBRC = 0.
    IF VBAP-BRGEW = 0.
    I_OUTPUT-CKWGT = 'X'.
    ENDIF.
    IF VBAP-VOLUM = 0.
    I_OUTPUT-CKVOL = 'X'.
    ENDIF.
    I_OUTPUT-VBELN = I_ORDERS-VBELN.
    I_OUTPUT-POSNR = I_ORDERS-POSNR.
    I_OUTPUT-GEWEI = 'ST'.
    I_OUTPUT-BRGEW = I_ORDERS-BRGEW.
    I_OUTPUT-VOLUM = I_ORDERS-VOLUM.
    APPEND I_OUTPUT.
    CLEAR: I_OUTPUT.
    ENDIF.
    V_RECIN = V_RECIN + 1.
    ENDLOOP.
    POPULATE BAPI DATA AND RUN BAPI
    CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ORDERHEADERINX-UPDATEFLAG = 'U'.
    LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.
    V_RECVBAP = V_RECVBAP + 1.
    IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    CLEAR: ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ENDIF.
    ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.
    IF NOT I_OUTPUT-CKWGT IS INITIAL.
    ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.
    ORDERITEMINX-GROSS_WGHT = 'X'.
    ENDIF.
    IF NOT I_OUTPUT-CKVOL IS INITIAL.
    ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.
    ORDERITEMINX-VOLUME = 'X'.
    ENDIF.
    APPEND ORDERITEMIN.
    ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMINX-UNTOF_WGHT = 'X'.
    ORDERITEMINX-UPDATEFLAG = 'U'.
    APPEND ORDERITEMINX.
    V_VBELN = I_OUTPUT-VBELN.
    ENDLOOP.
    RUN BAPI ON LAST ORDER
    IF NOT ORDERITEMIN IS INITIAL.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    ENDIF.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.
    SKIP.
    TOP OF PAGE
    TOP-OF-PAGE.
    WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,
    100(8) TEXT-H02, 126(8) SY-PAGNO.
    WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',
    20(77) TEXT-H04,
    100(8) TEXT-H05, 108(25) SY-REPID.
    WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,
    20(4) TEXT-H07, 25(32) SY-HOST,
    100(13) TEXT-H08, 121(8) SY-SYSID,
    129 '/', 130(3) SY-MANDT.
    ULINE.
    SKIP
    <b>Reward points</b>
    Regards

  • How to Change a Sales Order using BAPI

    Hi All
    How can we change the sales document using BAPI as the requirement is
    --> First we create a Sales order using a BAPI.
    --> If the sales order is changed then we get the changed order information alonge with the old order data in a CSV file.
    here i have the problem that we are uncertain which fields will be changed some times we may get the item changes or some times we may get the quantity changed information and some times the condition type may be changed . So how to handle this ?
    Thanks,
    Chindam

    Hi,
    try this
    DATA: IT_MESSAGE TYPE STANDARD TABLE OF BAPIRET2,
          WA_VBELN TYPE BAPIVBELN-VBELN.
    DATA: WA_BAPIHEAD TYPE BAPISDH1,
          WA_BAPIHEADX TYPE BAPISDH1X,
          WA_HEADDATA TYPE BAPISDH1.
    DATA: I_BAPIITEM TYPE STANDARD TABLE OF BAPISDITM,
          WA_BAPIITEM TYPE BAPISDITM,
            WA_DATA TYPE BAPISDITM,
          I_BAPIITEMX TYPE STANDARD TABLE OF BAPISDITMX,
          WA_BAPIITEMX TYPE BAPISDITMX.
    CHANGE ITEM DATA
    WA_BAPIITEM-ITM_NUMBER =WA_DATA-ITM_NUMBER.
    WA_BAPIITEM-REASON_REJ = WA_DATA-REASON_REJ. "(REASON FOR REJECTION)
    WA_BAPIITEMX-ITM_NUMBER = WA_DATA-ITM_NUMBER. "(ITEM NUMBER)
    WA_BAPIITEMX-UPDATEFLAG = 'X'.
    WA_BAPIITEMX-REASON_REJ = 'X'.
    APPEND WA_BAPIITEM TO I_BAPIITEM.
    APPEND WA_BAPIITEMX TO I_BAPIITEMX.
    TO CHANGE HEADER DATA
    WA_BAPIHEADX-UPDATEFLAG = 'U'.
    WA_BAPIHEADX-DLV_BLOCK = 'X'.
    WA_BAPIHEAD-SALES_ORG = WA_HEADDATA-SALES_ORG. "(COMPANY CODE)
    WA_BAPIHEAD-DLV_BLOCK = WA_HEADDATA-DLV_BLOCK. "(DELIVERY BLOCK)
    WA_VBELN = '0000000168'.
    CALL BAPI AND PASS THE VALUE
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
       EXPORTING
         SALESDOCUMENT               = WA_VBELN " (SALES AND DOCUMENT NO)
        ORDER_HEADER_IN             = WA_BAPIHEAD
         ORDER_HEADER_INX           = WA_BAPIHEADX
       TABLES
         RETURN                     = IT_MESSAGE
        ORDER_ITEM_IN               = I_BAPIITEM
        ORDER_ITEM_INX              = I_BAPIITEMX
    CLEAR IT_MESSAGE.

  • How to change pricing Conditions in Sales order in change sales order bapi

    Hi Experts,
    How to change pricing Conditions in Sales order in change sales order bapi.
    I have used the 2 function modules bapi-changesalesorder and sd salesdocument change, But it is creating the new record , instead of changing the existing one, Could please assist regarding the same
    Thanks in Advance .
    NLN

    HI NLN
      I have just tried on my system and managed to overwrite the existing price by passing the following parameters.
      <b>Import Paramters:</b>
         SALESDOCUMENT - Sales Document Number
         ORDER_HEADER_INX - UPDATEFLAG as <b>'U'</b>.
         LOGIC_SWITCH - Import Structure - Pass 'X' to LOGIC_SWITCH-COND_HANDL.
      <b>Tables:</b>
         CONDITIONS_IN - ITM_NUMBER,
                         COND_COUNT, -> Condition counter same as KONV-ZAEHK generally it is <b>'01'</b>
                         COND_TYPE,
                         COND_VALUE,
                         CURRENCY.
         CONDITIONS_INX - ITM_NUMBER,
                          COND_COUNT,
                          COND_TYPE,
                          UPDATEFLAG as <b>'U'</b>,
                          CURRENCY.
       Hope i have clarified your query.
    Kind Regards
    Eswar

Maybe you are looking for