Access specifiers define the visibility and accessibility of class components such as attributes, methods, and events. They help in implementing encapsulation, a core concept of object-oriented programming (OOP), by controlling which parts of a class can be accessed from outside the class or by its subclasses.
There are three main access specifiers in SAP ABAP:
1. PUBLIC
2. PROTECTED
3. PRIVATE
Steps to Use Access Specifiers in ABAP Classes
1. Create a class using CLASS…ENDCLASS.
2. Define sections for PUBLIC, PROTECTED, and PRIVATE using PUBLIC SECTION, PROTECTED SECTION, PRIVATE SECTION.
3. Place the methods or attributes under the appropriate section based on the intended visibility.
4. Instantiate the class and test accessibility from outside and inside (e.g., subclasses).
Access Specifier Visibility Scope Accessible From Use Case Example
PUBLIC High Anywhere (outside class too) General methods available to all
PROTECTED Medium Inside class + subclasses Internal logic exposed to subclasses only
PRIVATE Low Only inside the class Helper methods/data hidden from outside
Access specifiers in SAP ABAP enable secure and modular class design:
· Use PUBLIC for features meant to be openly accessible.
· Use PROTECTED when you want subclass access but hide from external calls.
· Use PRIVATE to fully encapsulate internal logic or helper routines.


so Outside the class
we cannot call the Private and protected Methods or attributes