Show TOC Start of Content Area

Function documentation Visibility Sections in Classes  Locate the document in its SAP Library structure


The declaration section of a class can be split into the following visibility sections. These sections define the external visibility of the class components and the interfaces of the class for their users. Each component of a class must be explicitly assigned to one of the visibility sections.


Public Visibility Section

All components declared in the public visibility section defined with PUBLIC SECTION are accessible to all users as well as in the methods of all heirs and the class itself. The public components are the interface of the class to each user. However, a subclass cannot access the protected components of a subclass from a different branch in the heritage hierarchy, even though they are inherited from a shared superclass.

Protected Visibility Section

All components declared in the protected visibility section defined with PROTECTED SECTION are accessible in the methods of all heirs and in the class itself. The protected components form a specific interface between the class and its subclasses.

Private Visibility Section

All components declared in the private visibility section defined with PRIVATE SECTION are only accessible in the class itself, and are also not visible to the heirs. The private components do not form an interface to the users of the class.

Package Visibility Section

All components declared with PACKAGE SECTION in the package visibility section are visible for all users belonging to the same package. They are invisible to all users outside the package. For the repository objects of the same package, the components visible within the package represent an interface of the class.


The visibility sections form the basis for the important object property of encapsulation in ABAP Objects. When defining a class, you should declare the minimum possible number of components in the public section and these public components must be created carefully. For global classes, they can no longer be changed after the class is released.


The class is the smallest encapsulation unit in ABAP Objects. A method can use all components of all instances of the same class, except for the components of its own class. The exceptions to this rule are subclasses, which cannot access the private components of superclasses if they are not their friends.



End of Content Area