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: 

Private constructor

Former Member
0 Kudos

Hi Gurus,

I have a question. I know that there is a constructor in ABAP Objects and it is declared in Public class. But i would like to know that how do we make a constructor as private. Please let me know your feedbacks.

Thanks,

Siby Chakko.

1 ACCEPTED SOLUTION

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Siby,

have you ever heard about the Singleton Class. It is declared aa Private.

The constructor in the class may be called as Private class.

Thanks,

Bhargav.

2 REPLIES 2

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Siby,

have you ever heard about the Singleton Class. It is declared aa Private.

The constructor in the class may be called as Private class.

Thanks,

Bhargav.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Siby,

My two cents ...

As of Release 701, you could declare the instance constructor in the Public visibilty section of the class. Of course you could mark the instantiation level of the class as Private & prevent creation of the object by the usual CREATE OBJECT statement.

As of Release 702 you can declare the instance constructor in any visibility section of the class. Check this out: [http://help.sap.com/abapdocu_702/en/abennews-71-abap-objects.htm#!ABAP_MODIFICATION_1@1@].

BR,

Suhas