ARTICLE
Visibility of Instance Constructors
For technical reasons, the system declares the instance constructor of a
class in a visibility area ; it is
therefore theoretically visible to the appropriate users. However, an
instance constructor is only executed during the creation of an object
of this class using CREATE OBJECT . Therefore the instance
constructor is only visible to those users of a class that can also
create objects of this class.
The additions ABAP_KEY CREATE PUBLIC|PROTECTED|PRIVATE of the
statement CLASS determine whether every user,
only the heirs, or just the class itself can create objects of the
class. This means that these additions define the actual visibility of
the instance constructor. Therefore the following applies:
The instance constructor of a class defined using CREATE PUBLIC
can be called by any user.
The instance constructor of a class defined using CREATE PROTECTED
can only be called by the class itself and its subclasses.
The instance constructor of a class defined using CREATE PRIVATE
can only be called by the class itself.
This has the following important consequence:
If a class was defined using CREATE PRIVATE , only the class
itself can instantiate itself. Subclasses of this class cannot even
instantiate themselves, because they would have to call the superclass
constructor using CALL
super- constructor (also see
Inheritance and Instance Creation ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved