Application Development and Automation 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: 
Read only

problem with BAPI_SALESORDER_CHANGE

Former Member
0 Likes
274

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

1 ACCEPTED SOLUTION
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
249

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.

1 REPLY 1
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
250

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.