Skip to Content
avatar image
-3
Former Member

Commit Work and Wait after Rollback really needed?

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Dec 16, 2016 at 09:21 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 16, 2016 at 04:35 PM

    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!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 16, 2016 at 05:09 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 16, 2016 at 07:11 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded