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: 

event on end of internal ABAP session

ydzh
Discoverer
0 Kudos
569

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.

6 REPLIES 6

moshenaveh
Community Manager
Community Manager
0 Kudos
458

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!

Sandra_Rossi
Active Contributor
0 Kudos
458

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?

stanislaslemaire
Participant
458

Hello,
IMHO there is no equivalent to FINALIZE java method in ABAP world...

ydzh
Discoverer
0 Kudos
458

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.

Sandra_Rossi
Active Contributor
0 Kudos
458

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.

Sandra_Rossi
Active Contributor
0 Kudos
458

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.