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 in adding "Reason for Rejection" using BAPI_SALESORDER_CHANGE

Former Member
0 Likes
550

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.

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.

2 REPLIES 2
Read only

Former Member
0 Likes
513

When using BAPI_SALESORDER_CHANGE, you set the fields your are updating to 'X'. In the example you gave, you are trying to change the header data, material number, etc.

Try slimming it down to:

  • Populate the headerX details

it_bapisdh1x-updateflag = 'U'.

it_bapisditmx-itm_number = '00010'.

it_bapisditmx-updateflag = 'U'.

it_bapisditmx-reason_rej = 'X'.

APPEND it_bapisditmx.

it_bapisditm-itm_number = '00010'.

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

return = it_bapiret2.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

endif.

I hope this helps,

Mark

Read only

Former Member
0 Likes
513

Hi Mark,

Many Thanks for your reply. It worked out. ThanQ.