Let us know here the OOPs ABAP step by step tutorial, SAP OO ABAP Class Definition, Objects, Types Of Class, Implementation, Public, private, protected in SAP ABAP, SAP ABAP OOPs sample example programs, How to create global and local class in SAP ABAP.
Class: – A class is a user-defined data type that is the collection of different types of components.
- A class only provides a template it’s doesn’t allocate memory.
Object: – An instance of a class is called as an object.
- Whenever we instance a class memory will be allocated.
Access Specifies (Visibility Section): –
Types Of Class
1) Local Class -> Local class to program (SE38-ABAP Editor).
2) Global Class -> Class Builder Tool (SE24).
The syntax for creating local classes: –
1) Definition of class -> Declaration of components.
2) Implementation of class -> Implementation of method
Definition of class
Class <class name> definition.
Declaration of components.
Endclass.
Implementation class
Class <class name> implementation.
Implementation of methods.
Endclass.
Object Creation: –
1) Create reference for the class
Syntax: – Data <ref name> type ref to <class name>
Note: – Whenever an Object is created memory will be allocated for the attributes of the class and the attribute gets initialized to default values.
Access specifiers in ABAP / Public, private, protected in SAP ABAP
1) Public Section
2) Protected Section
3) Private Section
Application Of OOPS: –
1) BAPI’S
2) BADI’S
3) Enhancement Frame Work
4) Webdynpro
5) HR-ABAP
6) CRM-Technical
7) SRM
8) EP
OOPs ABAP step by step tutorial
=========================LOCAL CLASS=========================
OO ABAP example programs / SAP ABAP OOPs sample programs
How to create local class in SAP ABAP?
REPORT Demo_oops.
CLASS EMP DEFINITION.
PUBLIC SECTION.
DATA EMPNO TYPE I. “instance attribute
DATA ENAME(20) TYPE C. “instance attribute
ENDCLASS. “emp DEFINITION
DATA K TYPE REF TO EMP.
CREATE OBJECT K.
WRITE :/ K->EMPNO,
K->ENAME.
K->EMPNO = 1.
K->ENAME = ‘abc’.
WRITE:/ K->EMPNO,
K->ENAME.
At any point of time, the object stores one set of values.
Note: – Only public components can be accessed outside of the class.
=========================GLOBAL CLASS SE24=========================
How to create global class in SAP ABAP?
REPORT Z915AM_OOPS2.
Data m type ref to z915am_class1.
CREATE OBJECT m.
write :/ m->empno,
m->ename.