Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CHANGE not working when updating profit_ctr

Former Member
0 Kudos

Hi,

I am having problems when using the BAPI_SALESORDER_CHANGE function module trying to update the profit_ctr of the sales order. 

After the FM call i get the success message  V1 311 but the profit center is not changed. 

I am calling the FM 'BAPI_TRANSACTION_COMMIT' after i have called BAPI_SALESORDER_CHANGE.

Can anyone assist with what could be wrong?

Here is my code below: 

* fill bapi data

    i_bapisdh1x-updateflag = 'U'.

    t_bapisditm-itm_number = w_sopos.

    t_bapisditm-profit_ctr = f_prctr.

    APPEND t_bapisditm.

                                                                                                                                                                                                                                                              

    t_bapisditmx-itm_number = w_sopos.

    t_bapisditmx-profit_ctr = 'X'.

    t_bapisditmx-updateflag = 'U'.

    APPEND t_bapisditmx.

                                                                                                                                                                                                                                                              

    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

      EXPORTING

        salesdocument    = w_so

        order_header_inx = i_bapisdh1x

      TABLES

        return           = t_bapiret2

        order_item_in    = t_bapisditm

        order_item_inx   = t_bapisditmx.

* Check for a success message

    READ TABLE t_bapiret2 WITH KEY

                          type = 'S'

                          id   = 'V1'

                          number = '311'.

    IF sy-subrc = 0.

      CONCATENATE 'SO:' w_so ' updated successfully'

      INTO f_message.

      f_error = ' '.

    ELSE.

      CONCATENATE 'SO:' w_so ' NOT updated'

      INTO f_message.

      f_error = 'X'.

    ENDIF.

                                                                                                                                                                                                                                                              

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        wait = 'X'.

Thanks.

Regards,

Barbara

1 REPLY 1

former_member195402
Active Contributor
0 Kudos

Hi Barbara,

your code looks fine, I've checked it against a working BAPI call in our system. Although I would call BAPI_TRANSACTION_COMMIT only in case of success (SY_SUBRC=0 after reading the message table), this is not the reason for your issue.

But there might be a userexit (for example in MV45AFZZ), which will cause this issue.

Can you change the profit center in your sales item using VA02 without any issue?

Regards,

Klaus