11-24-2017 7:43 AM
Hi all,
in other programming languages the singleton works different from ABAP.
In ABAP more than one Instance of the singleton can be created, as the creation/instanciating in ABAP is only per session.
What I need is a "real" singleton as in JAVA ...
Multiple sessions should only have exactly one common class (in the sense of other programming languages)
Does anybody know, how to achieve this?
Regards
Mario
11-24-2017 9:09 AM
The only way i can think of achieving this is via "serializing" the object. Cf.
11-24-2017 9:12 AM
Hi suhas,
thanks. As I don't have any knowlege regarding asXML I think it is not a apropriate solution for my problem 🙂
Many thanks
Regards
Mario
11-24-2017 9:22 AM
Hi Mario,
The (de)serialization is handled by the identity Transformation(id).
You could have a look at the demo program DEMO_SERIALIZABLE_OBJECT to see how it works.BR Suhas
11-24-2017 9:36 AM
You should to look into Shared Memory Objects...
https://help.sap.com/saphelp_nw70/helpdata/en/c5/85634e53d422409f0975aa9a551297/frameset.htm
11-28-2017 5:05 AM
Hi Jörgen,
unfortunately the shared memory does not meet my requirements.
What I wanted to achieve:
I created an ALV-Grid: Think of a ToDo-Liste where more than one user can work with simultationously.
Asuming user #1 is updating a row #xy in the ALV Grid. Now I wanted to notify all other users by a popUp working on the ALV-Grid, that row xy was updated by user #1.
My initial attempted was to create a singleton-class which throws an event.
As I wrote before, a singleton is instanciated for each session. So this does not work.
Also - unfortunatelly- the shared memory does not work as events are not allowed in shared-memory classed.
Do you see any other approach?
Regards
Mario
11-28-2017 5:07 AM
I forgot to mention that the ALV-Grid class ist listening for the notifierr-event, when my notifier-class is throwing the event "row xy " changed.
11-28-2017 6:24 AM
I see. So basically what you want is for one instance of your ALV-Grid to be able to send a message to the other instances to say "Hey, my user just updated this item". You should check out ABAP Messaging Channels
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenamc.htm
11-28-2017 7:08 AM
"in other programming languages the singleton works different from ABAP"
Well other programming languages are not running on an AS ABAP. Look at the picture under
Where should your singleton reside? Normal objects live in the internal session. Above we have shared objects in the shared memory. Before release 7.52 that's all ABAP can offer.From 7.52 on, the user memory will comprise the ABAP Daemon Memory, where ABAP Daemons can store their context specific memory. ABAP Daemons also will be able to react on events. (the German version of the ABAP Keyword documentation already introduces Daemons, an upload of the englisch translation will follow soon). Daemons can be created as singletons (but not so easy).