‎2011 Jan 17 10:32 AM
Hi,
I have a requiremnt where in RFC contains many standard FM calls which writes values to database.
I want to commit work only if all the FM are executed succesfully.
I have an issue here used ws_reverse_goods_issue FM and didnot commit and had values in SAP LUW
after that tried exceuting BAPI_GOODSMVT_CREATE which is giving error MB_GOODSMVT_CREATE FM cannot be executed..
If commit its working fine..
I wan to commit work finally and not in between..
Please advice..
Thanks,
Phani
‎2011 Jan 17 10:55 AM
Hi,
Have you tried wrapping your code in an fm using 'in update task'?
http://help.sap.com/saphelp_nw04/helpdata/en/23/edae617ba64e85bd4997f25c77eb1f/content.htm
‎2011 Jan 17 11:31 AM
Hi phanisreedhar lakamsani,
Please note that a COMMIT WORK is not the same as the implicit database commit that will happen automatically after an RFC function call is finished.
COMMIT WORK will
- finally freeze all database changes done by update/insert/modify statements
- trigger the execution of all PERFORM ON COMMIT routines (frequently used in BAPI)
- trigger the execution of all function modules registered with CALL FUNCTION .. IN UPDATE TASK
One possibility is as Gemini Twin recommends the wrapping into one function called in UPDATE TASK.
But that means if any errors are raised in update task, you will get an express mail notifying of the failure.
The update task should be used if you do not expect any errors to occur.
Everything should be fine if, after calling BAPI_GOODSMVT_CREATE, you check for error in RETURN table:
LOOP AT RETURN WHERE type CA 'EAX' "severe error of type E, A, or X occured
TRANSPORTING NO FIELDS.
ENDLOOP.
IF SY-SUBRC = 0.
CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.
ELSE.
CALL FUNCTION BAPI_TRANSACTION_COMMIT.
ENDIF.This code should be at the end of the RFC call. You should take action for error situatio, i.e. record the errors in application log.
Regards,
Clemens