Skip to Content
-3

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

Oct 18, 2017 at 11:46 AM

376

avatar image
Former Member

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..

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Raymond Giuseppi
Oct 19, 2017 at 05:44 AM
2

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.

Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Oct 19, 2017 at 06:34 AM
2

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.

Share
10 |10000 characters needed characters left characters exceeded
Suhas Saha
Oct 19, 2017 at 07:17 AM
2

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!

Share
10 |10000 characters needed characters left characters exceeded
Jelena Perfiljeva
Oct 18, 2017 at 04:38 PM
0

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.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for your reply..

I wanted to know if i execute four update statements (using update module) and then execute commit , how can I come to know exactly which update statements were successfully executed , and which were failed..

Can you please give more explanation on this..

Thank you...

0

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.

0

No, don't check sy-subrc after call function in update task, as said in the ABAP documentation: "The system field sy-subrc is undefined after the statement CALL FUNCTION ... IN UPDATE TASK is executed"

0