Skip to Content
0
Former Member
Feb 19, 2009 at 01:00 PM

Problem in adding "Reason for Rejection" using BAPI_SALESORDER_CHANGE

37 Views

Hi all,

I have a requirement to stop further processing of sales order by changing the reason for rejection at line item. I have done the code and passed the reason code in the item table to BAPI. The return message says the sales order ammended successsfully, but when i go and see the sales order I dont see it getting updated. when i go to check the order its throwing an error message "Update was terminated" Could some one please help in getting this solved.

The code is shown below

  • Populate the headerX details

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

  • Populate the header details

it_bapisdh1-sales_org = '1298'.

it_bapisdh1-distr_chan = '95'.

it_bapisdh1-division = '00'.

it_bapisdh1-purch_no_c = 'Test1'.

  • Partner Roles

it_bapiparnr-partn_role = 'AG'.

it_bapiparnr-partn_numb = '9820000049'.

it_bapiparnr-itm_number = '00000'.

APPEND it_bapiparnr.

it_bapiparnr-partn_role = 'WE'.

it_bapiparnr-partn_numb = '9820000049'.

it_bapiparnr-itm_number = '000000'.

APPEND it_bapiparnr.

it_bapisditmx-itm_number = '00010'.

it_bapisditmx-updateflag = 'U'.

it_bapisditmx-material = 'X'.

it_bapisditmx-cust_group = 'X'.

it_bapisditmx-reason_rej = 'X'.

APPEND it_bapisditmx.

it_bapisditm-itm_number = '00010'.

it_bapisditm-material = 'YAG'.

it_bapisditm-reason_rej = '01'.

APPEND it_bapisditm.

BREAK-POINT.

salesd = '4000004045'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = salesd

order_header_in = it_bapisdh1

order_header_inx = it_bapisdh1x

behave_when_error = ' '

int_number_assignment = ' '

TABLES

order_item_in = it_bapisditm

order_item_inx = it_bapisditmx

partners = it_bapiparnr

return = it_bapiret2.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

endif.