Example of Classes in SAP ABAP
REPORT demo_class_usage.
CLASS demo_class DEFINITION.
PUBLIC SECTION.
METHODS:
display_name.
PRIVATE SECTION.
DATA:
name TYPE string.
ENDCLASS.
CLASS demo_class IMPLEMENTATION.
METHOD display_name.
WRITE: / 'Name:', name.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: obj TYPE REF TO demo_class.
CREATE OBJECT obj.
obj->name = 'John Doe'.
obj->display_name( ).
Output:
Name: John Doe
You use these access modifiers to control the visibility and access to the various parts of your class. By doing so, you can maintain the encapsulation of your class’s internal logic and provide a well-defined public interface for other parts of your ABAP program or other classes. This is a fundamental principle of object-oriented programming that helps improve code organization, reusability, and maintainability.
Visibility Section in Classes | SAP ABAP
SAP ABAP (Advanced Business Application Programming) is a high-level programming language created by the German software company SAP SE. ABAP is primarily used for developing and customizing applications within the SAP ecosystem, which includes enterprise resource planning (ERP) systems and other business software solutions. C++ is used to implement the ABAP kernel. A procedural and object-oriented programming model are both supported by the hybrid programming language ABAP.