Ansicht
Dokumentation

ABENCONSTRUCTOR_VISIBILITY - CONSTRUCTOR VISIBILITY

ABENCONSTRUCTOR_VISIBILITY - CONSTRUCTOR VISIBILITY

CPI1466 during Backup   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

- Visibility of Instance Constructors

For technical reasons, the instance constructor of a class is declared in a visibility section and is therefore theoretically visible to the corresponding consumers. However, an instance constructor is only executed when an object of this class is created using CREATE OBJECT. Therefore, the instance constructor is only visible to the users of a class that can also create objects of this class.

The additions CREATE PUBLIC$|PROTECTED$|PRIVATE of the statement CLASS determine whether each 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 implicitly. 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 (see also Inheritance and Instance Creation). 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).






ABAP Short Reference   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 2427 Date: 20240426 Time: 194331     sap01-206 ( 46 ms )