Skip to Content
avatar image
Former Member

One instance of a class over several sessions (ABAP singleton not working)

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Nov 28, 2017 at 07: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

    https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenmemory_organization.htm

    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).

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 24, 2017 at 09:36 AM
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 24, 2017 at 09:09 AM

    The only way i can think of achieving this is via "serializing" the object. Cf.

    https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abenasxml_class_instances.htm?file=abenasxml_class_instances.htm

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 24, 2017 at 09: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

    Add comment
    10|10000 characters needed characters exceeded

    • 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