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
1,014

Hi All,

I need a help in solving the problem with the BAPI 'BAPI_SALESORDER_CHANGE' while tryihg to update the sales order with the reason for rejection it returning a error message with 'Enter Document Number'.

I believe this could be avoided by using the STARTING NEW TASK with the bapi. Could anyone please guide to get the problem resolved.

Thanks in advance.

Thanks,

Karthik

6 REPLIES 6
Read only

Shahid
Product and Topic Expert
Product and Topic Expert
0 Likes
791

Are you passing the document number to the BAPI? the error message looks so

Read only

Clemenss
Active Contributor
0 Likes
791

your code?

Read only

Former Member
0 Likes
791

Hi,

Below is the code which has been written in a method.

clear: ex_subrc,

wa_bapisditm,

wa_bapisditmx,

wa_bapisdh1x,

wa_return,

it_return,

it_bapisditm,

it_bapisditmx.

if t_rejvbap is initial.

exit.

endif.

*--Prepare data

loop at t_rejvbap into wa_vbap.

wa_bapisditm-itm_number = wa_vbap-posnr.

wa_bapisditm-material = wa_vbap-matnr.

wa_bapisditm-reason_rej = k_02.

wa_bapisditmx-itm_number = wa_vbap-posnr.

wa_bapisditmx-reason_rej = k_x.

append wa_bapisditm to it_bapisditm.

append wa_bapisditmx to it_bapisditmx.

clear: wa_bapisditm,

wa_bapisditmx.

endloop.

*--Update Flag

move : k_u to wa_bapisdh1x-updateflag.

*--Change Sales Order

  • SET UPDATE TASK LOCAL.

wait up to 5 seconds.

call function 'BAPI_SALESORDER_CHANGE'

exporting

salesdocument = im_vbak-vbeln

order_header_inx = wa_bapisdh1x

tables

return = it_return

order_item_in = it_bapisditm

order_item_inx = it_bapisditmx.

*--Rollback, if errors

read table it_return into wa_return with key type = k_e.

if sy-subrc eq 0.

call method zasa_automated_delship=>asa_fill_bapireturn

exporting

im_message = wa_return-message

im_vgbel = im_vbak-vbeln

im_bstnk = im_vbak-bstnk

im_vsbed = im_vsbed

changing

t_error = t_error.

ex_subrc = 1.

call function 'BAPI_TRANSACTION_ROLLBACK'.

exit.

endif.

*--Commit Change

clear: wa_return.

call function 'BAPI_TRANSACTION_COMMIT'

importing

return = wa_return.

wait up to 5 seconds.

if wa_return-type = k_e.

call function 'BAPI_TRANSACTION_ROLLBACK'.

call method zasa_automated_delship=>asa_fill_bapireturn

exporting

im_message = wa_return-message

im_vgbel = im_vbak-vbeln

im_bstnk = im_vbak-bstnk

im_vsbed = im_vsbed

changing

t_error = t_error.

ex_subrc = 1.

exit.

endif.

Kindly advise on the same as soon as possible. This is urgent.

Thanks,

Karthikeyan.

Read only

0 Likes
791

hi,

just check if , this variable is being populated in debug mode.

salesdocument = im_vbak-vbeln

Read only

0 Likes
791

[How to post code in SCN, and some things NOT to do...|;

Read only

Former Member
0 Likes
791

Hi,

The parameters are passed i have checked in debugging mode. The solution is using parallel processing i believe by using 'STARTING NEW TASK'. Could anyone please suggest on the same.

Thanks,

Karthikeyan.