Posts

SAP ABAP : OOPS Concept - Encapsulation

Image
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.  Technically in encapsulation, the variables or data of a class is hidden from any other class and can be accessed only through any member function of its own class in which it is declared. As in encapsulation, the data in a class is hidden from other classes using the data hiding concept which is achieved by making the members or methods of a class private, and the class is exposed to the end-user or the world without providing any details behind implementation using the abstraction concept, so it is also known as a  combination of data-hiding and abstraction . Encapsulation can be achieved by Declaring all the variables in the class as private and writing public methods in the class to...

SAP ABAP : OOPS Concept - Inheritance

Image
Inheritance is an important pillar of OOP(Object-Oriented Programming). It is the mechanism in ABAP by which one class is allowed to inherit the features(fields and methods) of another class.  Important terminology:  Super Class:  The class whose features are inherited is known as superclass(or a base class or a parent class). Sub Class:  The class that inherits the other class is known as a subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods. Reusability:  Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class. How to use inheritance in ABAP The keyword used for inheritance is  INHERITING FROM . Example : REPORT ...