Skip to Content
Jul 10, 2006 at 11:06 AM

Singleton in ABAP



1) I have created a class with its instantiation set to private.

2) Declared a static attribute 'instance' in the class with TYPE REF to same class.

3) In the class constructor checked if instance is initial if it is then created an object.

if instance initial.

creat'e object instance.


4) Created a method get_instance which exports the 'instance' attribute of the class.

I suppose this is fine for implementing the Singleton class.

Created a sample program where I call get_instance of this class.

Open two sessions of SE80 and execute this program in debug mode. I see that each program is executing the class constructor and instance is initial every time.

If instance is initial in each execution (with two parllel executions) then what is the purpose of declaring it as static.

Since its initial create object is executed every time in

each execution. Then the instance is not unique and its not singleton.

Can somebody explain signleton in ABAP. Why is it different from JAVA.