Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Commit Work and Wait after Rollback really needed?

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

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.

4 REPLIES 4

Sandra_Rossi
Active Contributor

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.

raghug
Active Contributor
0 Kudos

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!

Former Member
0 Kudos

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

Jelena
Active Contributor
0 Kudos

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.