Application Development and Automation 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: 
Read only

Private constructor

Former Member
0 Likes
827

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
Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
671

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
Read only

Venkat_Sesha
Product and Topic Expert
Product and Topic Expert
0 Likes
672

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
671

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