OBJECT ORIENTED PROGRAMING SYSTEM IN
SAP ABAP
OOPS IN SAP ABAP:Object-oriented programming (OOP) is a programming paradigm that organizes and structures code around
the concept of "objects," which are instances of classes
CLASS ENCAPSULATION
OBJECT OOPS POLYMORPHISM
ABSTRACTION
INHERITANCE
CLASS : A class is a blueprint or template for creating objects. It defines the data and behavior (methods) that the objects created
from the class will have. In ABAP, classes are defined using the CLASS statement.
Object: An object is an instance of a class. It represents a specific occurrence of the class and can interact with other objects
through its methods
Method: A method is a subroutine or function defined within a class that encapsulates a specific behavior or action. It is used to
perform operations related to the class's data or functionality. In ABAP, methods are defined within a class using the METHOD
statement.
CLASS SHAPE
ATTRIBUTE : SHAPE_NAME,COLOUR
METHOD : INFO
Instance
Multiple copy for a class
Attribute : Accessed only by object. It can be used only in the instance method.
Methods : Accessed only by Object. Both instance and static attribute can be use inside the method.
Static
Single copy for a class.
Attribute: Accessed by object and class name. It can be use in the either static or instance method.
Methods: Accessed by object and class name.
STATIC
INSTANCE
ATTRIBUTE
ATTRIBUTE METHODS
METHODS
CONSTRUCTOR:
“A constructor is a special method within a class that is used to initialize objects of that class”.
Instance constructor:
Only one for class.
It call automatically at the time of object creation.
We have to place it in public section.
Importing and exception are allow but isn't have exporting parameter.
INSTANCE
CONSTRUCTOR
Static Constructor. STATIC
Single static Constructor for a class.
Before the object creation we can call static constructor by using class name.
We have to place it in public section.
No Parameter are exception is allowed.
Polymorphism: Polymorphism is the ability of a variable, function or object to take multiple forms.
1.Compile Time Polymorphism.
Add(int a,intb) Add(int a,intb,intc) Add(int a,intb,int c)
2.Run Time Polymorphism
Inheritance: Inheritance is a mechanism in which a class can inherit the properties and behaviors of another class. In ABAP,
inheritance is achieved using the “INHERITING FROM” clause.
HORACE LION COW BUFFALO
HORACE
DONKEY
DEAR CAT DOG DEAR
DEAR
Multiple Inheritance
Polymorphic Inheritance
Single Inheritance
COW
Hierarchical Inheritance
Encapsulation
Encapsulation is the concept of bundling data (attributes) and methods that operate on that data within a class. It allows
data to be hidden and accessed only through the methods of the class, promoting data protection and modularity.
Key Points of Encapsulation:
▪ Data Hiding
▪ Access Control PUBLIC
Access by self, derived
▪ Information Hiding and outside classes
▪ Code Organization and Maintenance PROTECTED
▪ Encapsulation and Inheritance
Access by self, derived
PRIVATE classes
Access by only self
CLASS
Abstraction: Abstraction is a methodology of hiding the implementation detail from user and only provide functionality to user.
Interface:An interface in java is a blueprint of a class or you can say it is a collection of abstract and static constant. In
interface each method is public and abstract but it does not contain any constructor. Thus interface basically is a group of
related methods with empty bodies.
INTERFACE CLASS OBJECT
References
SAP ABAP - Object Orientation | Tutorialspoint
SAPTechnical.COM - ABAP Tutorials
(8064) 1 ABAP OOPS Introduction - YouTube
(8064) Video 1: OO ABAP - Introduction about OO ABAP - YouTube