OOPS Concept Documentation
OOPS Concept Documentation
2.3 Inheritance
Inheritance is a mechanism that allows one class to acquire the attributes and methods of
another class. In ABAP, a class can inherit from another class using the 'INHERITING FROM'
keyword. This promotes code reuse and enhances modularity.
2.4 Polymorphism
Polymorphism allows objects of different classes to be treated as objects of a common
superclass. This is achieved through method overriding, where a method in a subclass has
the same name as a method in the superclass, but with different behavior.
2.5 Encapsulation
Encapsulation is the concept of bundling data and methods that operate on that data within
a single unit (class). It restricts direct access to some of the object's components, which
helps to protect the integrity of the data. In ABAP, encapsulation is achieved by defining
attributes as private or protected.
2.6 Abstraction
Abstraction is the process of hiding the implementation details and showing only the
essential features of an object. This allows the user to focus on high-level operations
without worrying about low-level details. In ABAP, abstract classes and methods can be
used to achieve abstraction.
3.1 Methods
Methods are functions that are defined within a class. They can perform operations on the
object's data or carry out other business logic. Methods in ABAP can be either instance
methods or static methods.
3.2 Attributes
Attributes are variables that store the state or data of an object. They can have different
visibility levels, such as public, protected, or private, depending on the design needs.
4.1 Constructor
A constructor is a special method that is automatically called when an object is created. It is
used to initialize the object's attributes. In ABAP, constructors are defined using the
'METHODS CONSTRUCTOR' syntax.
4.2 Destructor
A destructor is a method that is automatically called when an object is destroyed. It is used
to clean up resources and perform any necessary final operations before the object is
removed from memory.
5. Conclusion
The OOPS concept in ABAP provides a structured way to write modular, reusable, and
maintainable code. By applying the principles of classes, objects, inheritance,
polymorphism, encapsulation, and abstraction, ABAP developers can create flexible and
scalable applications.