2016 Jun 08 9:08 AM
Hi Experts,
I am using below code to update SO but it is not updating.
In the same program, First I am creating SO then updating SO later on.
" li_order_header_in-ord_reason = '000'."lc_augru.
li_order_header_in-cust_grp5 = '246'."lc_kvgr5.\
li_order_header_inx-updateflag = 'U'.
li_order_header_inx-ord_reason = 'X'.
li_order_header_inx-cust_grp5 = 'X'.
call function 'SD_SALES_DOCUMENT_INIT'
* EXPORTING
* STATUS_BUFFER_REFRESH = 'X'
* KEEP_LOCK_ENTRIES = ' '
* SIMULATION_MODE_BAPI = ' '
* CALL_ACTIVE = ' '
.
call function 'BAPI_SALESORDER_CHANGE' destination 'NONE'
exporting
salesdocument = p_l_vbeln
order_header_in = li_order_header_in
order_header_inx = li_order_header_inx
tables
return = li_return.
loop at li_return into lst_return
where type eq 'E'
or type eq 'A'.
exit.
endloop.
clear: lst_return.
call function 'BAPI_TRANSACTION_COMMIT'."
Please let me know if i am doing something wrong.
Regards,
Shiv
2016 Jun 08 2:48 PM
Your code is very strange: you call the BAPI in a separate RFC mode ('NONE') but you call BAPI_TRANSACTION_COMMIT in the current mode. You must be coherent, either call both of them in 'NONE', or call both of them in the current mode (remove DESTINATION 'NONE').
2016 Jun 08 10:38 AM
Hi Shivshanker,
What is in the return table li_return of BAPI_SALESORDER_CHANGE?
And, are you creating the SO in the same program and trying to change the same SO that you created?
Thanks,
Sowbhagya
2016 Jun 08 10:49 AM
It could be that the sales order is still locked from creating. Check return table.
2016 Jun 08 10:56 AM
2016 Jun 08 12:10 PM
Hi,
I suggest to test both the functionalities separately before calling then in sequence. It could be reason system is not updating data.
Regards,
Venu
2016 Jun 08 2:48 PM
Your code is very strange: you call the BAPI in a separate RFC mode ('NONE') but you call BAPI_TRANSACTION_COMMIT in the current mode. You must be coherent, either call both of them in 'NONE', or call both of them in the current mode (remove DESTINATION 'NONE').
2016 Jun 08 2:58 PM
2016 Jun 08 5:23 PM
Hi,
if you want the process done in own LUW, then create a new function module, put BAPI_SALESORDER_CHANGE AND BAPI_TRANSACTION_COMMIT in this function, call it DESTINATION 'NONE' if you need own LUW without commit in current LUW.
Your evaluation of li_return is wrong. It will call BAPI_TRANSACTION_COMMIT anyway.
Better
LOOP AT li_return transporting no fields where type ca 'EAX'.
* E, A or X error: Roll Back any Changes
call function 'BAPI_TRANSACTION_ROLLBACK'.
RETURN. "Leave current Function (form/method) - Exits only exits the LOOP
endloop.
* Get here only without errors
call function 'BAPI_TRANSACTION_COMMIT'.
Best regards,
Clemens