Skip to Content
avatar image
-3
Former Member

How to check whether update is successful or not in update function module

Hi..

I am using UPDATE FUNCTION MODULE to update a database table. I am calling the same function continuously for say fore times and then executing COMMIT statement.

Now , How can I come to know whether update is successful , if not which update task is failed.

Thanks in advance..

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 19, 2017 at 05:44 AM

    Call transaction SM13, to get list of FM called and the one that raised the error.

    Note that if one of the update tasks FMs fails for a single commit, every previous successful update will be reversed/rollbacked. Perform some search in online help on COMMIT statement or database LUW concept.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 19, 2017 at 06:34 AM

    In the ABAP program which does CALL FUNCTION ... IN UPDATE TASK, you may know whether the update function modules are okay only by using COMMIT WORK AND WAIT. Cf ABAP doc of COMMIT WORK:

    sy-subrcMeaning0The addition AND WAIT was specified and the update of the update function modules was successful.4The addition AND WAIT was specified and the update of the update function modules was not successful.

    But it doesn't mean you have to use COMMIT WORK AND WAIT : if you use COMMIT WORK alone, you must not test SY-SUBRC, but administrators regularly check transaction SM13 (cf Raymond's answer).

    In the update function modules, you must not do any validation logic (they must be done before the COMMIT WORK), you must do only database operations. All possible errors must be handled and terminated by MESSAGE ... TYPE 'E' (for instance) to trigger automatically a database rollback, and the logging in SM13.

    Note that CALL FUNCTION ... IN UPDATE TASK is only recording the call for later call, which is actually executed when the COMMIT WORK is reached.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 19, 2017 at 07:17 AM

    In simple terms:

    • If your application needs to know if the updates have been successful , then use synchronous updates (COMMIT WORK AND WAIT). Check SY-SUBRC after the commit.
    • If the status of your updates are not important for your application, then use asynchronous updates (COMMIT WORK)

    As Sandra & Raymond have already mentioned, SM13 should be regularly monitored by the admins.

    A small tip: You can use BAPI_TRANSACTION_COMMIT with WAIT = 'X' because the error handling (SY-SUBRC <> 0) is already there!

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 18, 2017 at 04:38 PM

    Check sy-subrc after every UPDATE and before COMMIT. You might want to check the examples in ABAP documentation and ABAP Editor (in the menu somewhere). Pretty sure there are quite a few on handling the DB updates.

    Add comment
    10|10000 characters needed characters exceeded

    • Sorry, I thought you were asking about a simple UPDATE. Haven't realized you meant CALL FUNCTION ... IN UPDATE TASK. It might make sense to just post the code next time. Either way, it seems this question has been answered already.