BAPI_SALES_ORDER_CHANGE issues removing delivery block

Hi Friends,

I’ve been encountering issues when trying to use BAPI_SALES_ORDER_CHANGE to remove delivery block. Here’s the issues I’m getting:

-When trying to change 2 sales orders, 1st one gets posted successfully while second throws an error saying “Sales document is still being process by (same user)

– When trying to change 4 sales orders, I get a random change of vbuk-uvals to value ‘B’ which means partially processed then on the latter part of the program, delivery fails…

Can you please help if there’s any missing parameters that I need to add? or if I’m missing anything. I attached my code below: 

 

loop at lt_salesorder_change assigning <lfs_salesorder_change>.

lwa_orderheader_in-dlv_block = ”.
lwa_orderheader_inx-updateflag = c_update_flag.
lwa_orderheader_inx-dlv_block = c_flag.

call function ‘BAPI_SALESORDER_CHANGE’
exporting
salesdocument = <lfs_salesorder_change>-vbeln
order_header_in = lwa_orderheader_in
order_header_inx = lwa_orderheader_inx
tables
return = lt_chg_return.

read table lt_chg_return into lwa_chg_return with key type = c_error.
if sy-subrc EQ 0.
call function ‘BAPI_TRANSACTION_ROLLBACK’.
else.
call function ‘BAPI_TRANSACTION_COMMIT’
exporting
wait = abap_on
importing
return = lwa_commit_return.
endif.

endloop.

 

 Thanks,

Geoff

Scroll to Top