Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarative statemnts →  Classes and Interfaces →  CLASS →  CLASS - DEFINITION 

PRIVATE SECTION

Other versions: 7.31 | 7.40 | 7.54

Syntax


PRIVATE SECTION. 

Effect

This statement can only be used in the declaration part of a class. It defines the private visibility section of the class class. All components of the class defined in the section behind the PRIVATE SECTION statement can only be addressed in the class itself, and in its friends.


Notes

  • The class is the smallest encapsulation unit in ABAP Objects. This means that a method can use all private components of all instances of the same class, apart from the private components of its own class. An exception to this rule are subclasses that cannot access the private components of superclasses, if they are not their friends.
  • The declaration of attributes in the private section does not stop methods of the References class from declaring externally to these attributes in the form of reference variables or field symbol, and therefore making the attributes visible and modifiable outside the private section.
  • Private components declared in a class but not used statically there produce a warning in the extended program check.
  • Private attributes are the only attributes for which the declaration of the addition READ ONLY is not required and therefore can not be specified.

Example

See Visibility Sections.