A lot of ABAP developers can write reports, SELECT queries, function modules and ALV output, but when project requires local classes, global classes, interfaces, events or RAP-style design, they have problems. This oops abap tutorial is very important with regard to this. With ECC 6.0 and SAP S/4HANA 2026, OO ABAP is not just an interview question anymore, but the way to create modern SAP applications, service classes, frameworks and clean ABAP designs.
Most ABAP developers are capable of designing reports, SELECT statements, function modules and ALV output, but have a problem when it comes to designing a local class, global class, interface, event, or RAP-like design for a project. This oops abap tutorial is very important in just this regard. OO ABAP isn’t just an interview question; it’s a crucial element in creating modern SAP apps, service classes, service design, frameworks, and clean ABAP designs in ECC 6.0 and SAP S/4HANA 2026.
What is OOPS ABAP and why it matters?
OOPS ABAP is an object oriented programming in ABAP. You have logically related data and behaviour in classes and objects, instead of in one procedural report. An object is an instance of a class, which is the structure in the run time system. The basic ABAP OOPS concepts are such as class, object, attributes, methods, constructors, encapsulation, inheritance, polymorphism and interfaces. Seven basic concepts every SAP developer should learn at first: Class & Object, Attributes & Methods, Constructor, Encapsulation, Inheritance, Polymorphism and Interfaces.
The reason behind the business is straightforward. SAP projects are constantly evolving. A pricing rule has to be updated, an ALV report has to be recalculated, a Fiori backend service requires a quick update of the business logic or a support ticket must be corrected without disrupting five other flows.
OO ABAP allows you to put logic in the right place. Sales-order behavior can be assigned to a sales-order class. Tax logic can be owned by a tax calculator class. Multiple calculation classes can follow the same contract with the help of an interface.
The points are important in S/4HANA since the modern development of SAP is more frequently based on class patterns. Developers need to do more than just think in FORM routines and global variables.Developers must think beyond FORM routines and global variables when thinking about RAP, service classes, testable utility classes, ALV wrappers, and clean-core custom development.
How It Works — The Internals
ABAP Objects is an extension of ABAP that is object-oriented. The attributes and methods are used in a class. Attributes hold data. Methods perform actions. At runtime, ABAP gives you an instance of a class when you create an object, and allows you to call the open methods of the class.
The visibility is the degree to which the object is available to the outside world. PUBLIC SECTION are Methods/attributes that are called by their caller. Private Section holds an internal data value and helper code. General callers are not allowed to access PROTECTED SECTION, subclassed callers are.
An object’s ability to maintain its private state is encapsulation. A method is called to change an attribute rather than changing the attribute directly. This will preserve the business rules and validations for the class. Using inheritance, behavior of a superclass can be inherited and/or specialized by subclass. One way to solve this is to use polymorphism so that one call to the reference can call to different implementation depending on the type of object. All the different classes can implement the interfaces without sharing a parent class, as it’s a contract.
In classic ECC development, many custom programs used reports, includes, subroutines, and function modules. Those still exist. In modern OO ABAP, especially in S/4HANA and ADT-based development, you should prefer class methods for business logic because they create clearer boundaries.
SE24 is the SAP Class Builder transaction. It lets you create and maintain global classes in SAP GUI. SE80 is the Object Navigator, used for programs, function groups, classes, and other repository objects. ADT is ABAP Development Tools in Eclipse, used widely in modern ABAP and S/4HANA projects.
| Concept | What It Means | Why Developers Need It |
| Class | Blueprint for objects | Defines behavior and structure |
| Object | Runtime instance | Executes class behavior |
| Attribute | Data inside class/object | Stores state |
| Method | Action or function | Performs logic |
| Constructor | Setup method | Initializes object correctly |
| Encapsulation | Controlled access | Protects internal state |
| Inheritance | Reuse through parent class | Reduces duplicate logic |
| Polymorphism | Different behavior through same call | Supports flexible design |
| Interface | Contract without fixed parent | Supports clean alternatives |
Practical Code Walkthrough: 7 OOPS ABAP Concepts
The best way to learn ABAP OOPS concepts with examples is to build small SAP-style classes. We will use a sales-order style example because most ABAP developers understand orders, amounts, and calculations.
1. Class and Object
A class is the definition. An object is the real instance created at runtime. In ABAP, you define a class with CLASS … DEFINITION and implement the logic with CLASS … IMPLEMENTATION.
REPORT zoops_abap_tutorial_basic.
CLASS lcl_sales_order DEFINITION.
PUBLIC SECTION.
METHODS display_order. ” Public method can be called by the report
ENDCLASS.
CLASS lcl_sales_order IMPLEMENTATION.
METHOD display_order.
WRITE: / ‘Sales order object created successfully’. ” Simple output from object method
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_order TYPE REF TO lcl_sales_order. ” Reference variable for the object
CREATE OBJECT lo_order. ” Create runtime object from the class
lo_order->display_order( ). ” Call public method of the object
This is the first step in any oo abap tutorial. You stop thinking only in report blocks and start thinking in objects that own behavior.
2. Attributes and Methods
Attributes store data. Methods process data. A class without methods is just a data container, and a class without meaningful attributes may not represent a real object.
REPORT zoops_abap_attributes.
CLASS lcl_customer DEFINITION.
PUBLIC SECTION.
METHODS set_name IMPORTING iv_name TYPE string. ” Receives customer name from caller
METHODS display_name. ” Displays stored customer name
PRIVATE SECTION.
DATA mv_name TYPE string. ” Private attribute stores customer name safely
ENDCLASS.
CLASS lcl_customer IMPLEMENTATION.
METHOD set_name.
mv_name = iv_name. ” Save input into private attribute
ENDMETHOD.
METHOD display_name.
WRITE: / ‘Customer:’, mv_name. ” Read private attribute inside class method
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_customer TYPE REF TO lcl_customer. ” Object reference for customer class
CREATE OBJECT lo_customer. ” Create customer object
lo_customer->set_name( iv_name = ‘ACME Trading’ ). ” Set attribute through method
lo_customer->display_name( ). ” Display customer name
Notice that the report does not change mv_name directly. That is the start of proper code control.
3. Constructor
A constructor runs automatically when the object is created. Use it when an object must start with valid data.
REPORT zoops_abap_constructor.
CLASS lcl_invoice DEFINITION.
PUBLIC SECTION.
METHODS constructor IMPORTING iv_invoice TYPE string. ” Constructor receives invoice number
METHODS display_invoice. ” Displays initialized invoice number
PRIVATE SECTION.
DATA mv_invoice TYPE string. ” Private invoice number
ENDCLASS.
CLASS lcl_invoice IMPLEMENTATION.
METHOD constructor.
mv_invoice = iv_invoice. ” Initialize object state during creation
ENDMETHOD.
METHOD display_invoice.
WRITE: / ‘Invoice:’, mv_invoice. ” Display value set by constructor
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_invoice TYPE REF TO lcl_invoice. ” Reference for invoice object
CREATE OBJECT lo_invoice
EXPORTING
iv_invoice = ‘9000001234’. ” Pass required value during object creation
lo_invoice->display_invoice( ). ” Constructor already prepared object data
A constructor prevents half-ready objects. If the invoice number is mandatory, the class should demand it when the object is created.
4. Encapsulation
Encapsulation means hiding internal data and exposing controlled methods. This keeps bad values from entering the object.
REPORT zoops_abap_encapsulation.
CLASS lcl_payment DEFINITION.
PUBLIC SECTION.
METHODS set_amount IMPORTING iv_amount TYPE decfloat34. ” Controlled setter method
METHODS get_amount RETURNING VALUE(rv_amount) TYPE decfloat34. ” Controlled getter method
PRIVATE SECTION.
DATA mv_amount TYPE decfloat34. ” Amount cannot be changed directly outside class
ENDCLASS.
CLASS lcl_payment IMPLEMENTATION.
METHOD set_amount.
IF iv_amount < 0.
MESSAGE ‘Amount cannot be negative’ TYPE ‘E’. ” Protect object from invalid state
ENDIF.
mv_amount = iv_amount. ” Store only valid amount
ENDMETHOD.
METHOD get_amount.
rv_amount = mv_amount. ” Return controlled value to caller
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_payment TYPE REF TO lcl_payment. ” Payment object reference
DATA lv_amount TYPE decfloat34. ” Local variable for returned amount
CREATE OBJECT lo_payment. ” Create payment object
lo_payment->set_amount( iv_amount = ‘1500.50’ ). ” Set amount through validation method
lv_amount = lo_payment->get_amount( ). ” Read amount through getter
WRITE: / ‘Payment amount:’, lv_amount. ” Display validated amount
This is why OO ABAP is safer than scattered procedural variables. The class controls its own rules.
5. Inheritance
Inheritance lets one class extend another class. Use it when the child class really “is a” specialized version of the parent class.
REPORT zoops_abap_inheritance.
CLASS lcl_document DEFINITION.
PUBLIC SECTION.
METHODS constructor IMPORTING iv_id TYPE string. ” Parent constructor
METHODS get_type RETURNING VALUE(rv_type) TYPE string. ” Method can be redefined
METHODS get_id RETURNING VALUE(rv_id) TYPE string. ” Returns document ID
PROTECTED SECTION.
DATA mv_id TYPE string. ” Subclasses can access protected data
ENDCLASS.
CLASS lcl_document IMPLEMENTATION.
METHOD constructor.
mv_id = iv_id. ” Store document ID in parent class
ENDMETHOD.
METHOD get_type.
rv_type = ‘Generic document’. ” Default parent behavior
ENDMETHOD.
METHOD get_id.
rv_id = mv_id. ” Return stored document ID
ENDMETHOD.
ENDCLASS.
CLASS lcl_invoice DEFINITION INHERITING FROM lcl_document.
PUBLIC SECTION.
METHODS constructor IMPORTING iv_id TYPE string. ” Child constructor
METHODS get_type REDEFINITION. ” Child changes parent behavior
ENDCLASS.
CLASS lcl_invoice IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_id = iv_id ). ” Call parent constructor
ENDMETHOD.
METHOD get_type.
rv_type = ‘Invoice document’. ” Specialized child behavior
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_invoice TYPE REF TO lcl_invoice. ” Reference for child class
CREATE OBJECT lo_invoice
EXPORTING
iv_id = ‘INV-1001’. ” Create invoice object with ID
WRITE: / lo_invoice->get_id( ). ” Method inherited from parent
WRITE: / lo_invoice->get_type( ). ” Method redefined in child
Do not use inheritance just to avoid typing code. Use it when the relationship is natural and stable.
6. Polymorphism
Polymorphism means the same method call can behave differently depending on the object behind the reference.
REPORT zoops_abap_polymorphism.
CLASS lcl_document DEFINITION.
PUBLIC SECTION.
METHODS get_type RETURNING VALUE(rv_type) TYPE string. ” Method to be redefined
ENDCLASS.
CLASS lcl_document IMPLEMENTATION.
METHOD get_type.
rv_type = ‘Document’. ” Default behavior
ENDMETHOD.
ENDCLASS.
CLASS lcl_invoice DEFINITION INHERITING FROM lcl_document.
PUBLIC SECTION.
METHODS get_type REDEFINITION. ” Invoice-specific behavior
ENDCLASS.
CLASS lcl_invoice IMPLEMENTATION.
METHOD get_type.
rv_type = ‘Invoice’. ” Runtime behavior for invoice object
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_doc TYPE REF TO lcl_document. ” Parent reference can point to child object
CREATE OBJECT lo_doc TYPE lcl_invoice. ” Runtime object is invoice
WRITE: / lo_doc->get_type( ). ” Calls invoice version through parent reference
This is powerful in frameworks. A caller can work with a general reference while each class supplies its own behavior.
7. Interfaces
An interface defines what a class must provide. It does not force a parent-child relationship.
REPORT zoops_abap_interface.
INTERFACE lif_tax_calculator.
METHODS calculate_tax
IMPORTING iv_amount TYPE decfloat34
RETURNING VALUE(rv_tax) TYPE decfloat34. ” Contract for tax calculation
ENDINTERFACE.
CLASS lcl_gst_calculator DEFINITION.
PUBLIC SECTION.
INTERFACES lif_tax_calculator. ” Class promises to implement interface method
ENDCLASS.
CLASS lcl_gst_calculator IMPLEMENTATION.
METHOD lif_tax_calculator~calculate_tax.
rv_tax = iv_amount * 18 / 100. ” GST-style tax calculation
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA lo_tax TYPE REF TO lif_tax_calculator. ” Reference typed to interface
DATA lv_tax TYPE decfloat34. ” Stores calculated tax
CREATE OBJECT lo_tax TYPE lcl_gst_calculator. ” Class chosen at runtime
lv_tax = lo_tax->calculate_tax( iv_amount = ‘1000’ ). ” Interface method call
WRITE: / ‘Calculated tax:’, lv_tax. ” Expected result: 180
Interfaces matter in S/4HANA projects because they help separate business rules from calling programs. They also make code easier to replace later.
When to Use It vs. Alternatives
OO ABAP is important, but not every line of code needs a new class. Good design means choosing the right style for the problem.
| Scenario | Prefer OO ABAP | Prefer Procedural ABAP |
| New S/4HANA business logic | Service class, helper class, interface | Avoid large procedural blocks |
| Simple one-time report | Local class if logic grows | Straight report may be enough |
| ALV output with formatting rules | ALV wrapper class | Basic procedural ALV for tiny reports |
| Reusable calculation logic | Global class or interface | Copy-paste FORM routines |
| Legacy ECC report fix | Small method or careful FORM | Full rewrite without business approval |
| RAP/Fiori backend logic | Class-based design | Procedural code spread across includes |
| Interview preparation | Explain OOP principles with examples | Memorize only definitions |
Use OO ABAP when the logic has state, rules, reuse potential, or multiple implementations. Pricing, tax, validation, output formatting, workflow helpers, API preparation, and RAP behavior classes are good examples.
Use procedural ABAP when the program is tiny, temporary, or clearly not worth extra structure. A ten-line utility report does not need five classes.
Avoid overusing inheritance. Many developers create deep parent-child trees because they learned inheritance as the main OOP feature. In real SAP projects, interfaces and composition are often easier to maintain.
A strong abap oops concepts with examples answer should show judgment. Interviewers do not only want “class, object, inheritance, polymorphism.” They want to know whether you can design code that another SAP developer can support.
Frequently Asked Questions
What does OOPS stand for in ABAP?
ABAP Objects is object-oriented programming in ABAP. It structures logic in classes and objects, attributes, methods and constructors, inheritance, interfaces and polymorphism. The proper oops abap tutorial should teach the use of the syntax as well as the design, not just definitions.
What are the major Object Oriented Programming concepts in SAP ABAP?
Class, object, attribute, method, constructor, encapsulation, inheritance, polymorphism and interface are the key OOPS concepts. Class/object, attributes/methods, constructor, encapsulation, inheritance, polymorphism, and interfaces are the best learning sequence for novices.
How ABAP differentiate class and object?
A class is a blueprint and an object is a runtime instance that is created from this blueprint. An oo abap tutorial starts with a class that is used to define methods and attributes, the object is used for storing actual runtime data and to execute method calls.
Why in ABAP OOPS encapsulation is important?
Encapsulation is done to keep the data of an object from being changed by the outside. Callers invoke public methods for changing the class attributes, rather than changing them directly; the public methods perform validation. This is very helpful when creating ABAP business rules, due to the fact that business rules should not be distributed between reports, includes, function modules, and exits.
What is Inheritance in the ABAP OOPS?
An Inheritance is a way to reuse and specialize behaviour from a parent class. When a child is a special case of a parent apply inheritance. Document and Invoice is a simple problem to explain for abap oops concepts with examples.
Explain difference between Inheritance and interface in ABAP?
An interface is a contract that many unrelated classes can implement and inheritance is implemented by a parent class. A common way to write interfaces is when several classes require similar method names but they have different naturally-occurring parents.