2023 Jul 27 11:35 AM
Dear All,
is there a way to get notified before the current internal session ends? The use case:
There is a CLASS-DATA instance of a logging class, e.g. /scwm/cl_log. Now I would like to know that the internal session is about to end, so that the log data accumulated until now can be saved to the DB.
Within the internal session, there can be multiple COMMIT WORK inbetween, and I don't wand to create a separate log on every commit.
What I am looking for is more like addShutdownHook() in java, if you see an ABAP internal session as an equivalent to a java runtime. Something you can execute before everything is destroyed.
2023 Jul 27 11:35 AM
Welcome to the SAP Community! Thank you for visiting us to get answers to your questions.
Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.
First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Secondly, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community.
Finally, I recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.
I hope you find this advice useful, and we're happy to have you as part of SAP Community!
2023 Jul 27 11:54 AM
Probably it doesn't exist.
What is the reason of having COMMIT WORK in "your" code? (or in code called)
Also, why can't you execute your code at the last place of code? Is it because there may be an interruption anywhere you can't handle like a short dump, or is there another reason?
2023 Jul 27 2:53 PM
Hello,
IMHO there is no equivalent to FINALIZE java method in ABAP world...
2023 Jul 28 9:06 PM
sandra.rossi there is (quite a lot of) a legacy code. It has its own logging class being used as a singleton literally from anywhere. The point is, more often than not the internal session ends without saving the log data - hence the log messages get lost forever.
To fix it - at least somehow - in java, I would write a shutdownHook making sure that the log has been saved prior to destroying the runtime. I am looking for smth. similar at the end of the internal session.
2023 Jul 29 9:06 AM
Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
2023 Jul 29 9:27 AM
I don't get how it works exactly, so I can't say what I would do.
Probably you can find an end point to place your code, and so one simple solution is to write to a custom table and at the end transfer the data of this table to one log.
I think it's over-engineering to write the log in case of abnormal end/short dump.