Skip to Content
-3

Commit Work and Wait after Rollback really needed?

Dec 16, 2016 at 08:55 AM

117

avatar image
Former Member

Dear experts,

I just've seen following code and would like to ask why I have to confirm after I did a rollback?

Thanks in advance.

BR.

Denis.

j0xq6.png (11.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Sandra Rossi Dec 16, 2016 at 09:21 AM
3

As you can see, COMMIT is not directly after ROLLBACK ; so maybe it's because the between code (INSERT_TABLE) updates the database, or do some other stuff related to SAP LUWs.

Share
10 |10000 characters needed characters left characters exceeded
Raghu Govindarajan Dec 16, 2016 at 04:35 PM
0

As Sandra said, looks good to me, you are logging the error and then committing the log to the database. Actually pretty darn good, because who ever wrote that code is thinking forward to supporting the system!

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 16, 2016 at 05:09 PM
0

Hi,

As you can see the message is into lv_msg.

and you do after that mo_log->insert_message()

That commit is because of the method insert_table, to make sure the data was inserted in the table..

If that table is for error log the commit after the error message is to guarantee the error was saved in the log table to display when necessary.

Best Regards

Filipe Sardinha

Share
10 |10000 characters needed characters left characters exceeded
Jelena Perfiljeva
Dec 16, 2016 at 07:11 PM
0

ABAP Help:

The statement ROLLBACK WORK closes the current SAP LUW and opens a new one.

In this case COMMIT WORK belongs to the LUW that was started after ROLLBACK. If there was no code at all in between then, of course, this would just make no sense. Also I'd say that you don't necessarily have to do COMMIT here (because there is always COMMIT at the end of the program) but it could be needed depending on the context and requirement, as Raghu noted.

Share
10 |10000 characters needed characters left characters exceeded