OOPS ABAP Tutorial: 7 Concepts Every SAP Developer Must Master

OOPS ABAP Tutorial: 7 Concepts Every SAP Developer Must Master

A lot of ABAP developers can write reports, SELECT queries, function modules, and ALV output, but they struggle when a project requires local classes, global classes, interfaces, events, or RAP-style design. That is where this OOPS ABAP tutorial becomes useful. It shows how these object-oriented concepts fit together and where they apply in real SAP development. Moreover, with ECC 6.0 and SAP S/4HANA 2026, OO ABAP remains an important foundation for building service classes, reusable frameworks, and maintainable 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 does it matter?

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 runtime system. The basic ABAP OOPS concepts are classes, objects, attributes, methods, constructors, encapsulation, inheritance, polymorphism, and interfaces. Seven basic concepts every SAP developer should learn first are: Classes and Objects, Attributes and Methods, Constructors, Encapsulation, Inheritance, Polymorphism, and Interfaces.

Still Searching for ABAP Answers?

Syntax, OOP, CDS, RAP, reports & integrations are all within easy reach.

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. How modularization works in ABAP programs.

OO ABAP allows you to put logic in the right place. Sales-order behaviour 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.

These concepts are especially important in S/4HANA because modern SAP development increasingly relies on class-based design patterns. Therefore, developers need to think beyond traditional FORTRAN-style routines and global variables.

Instead, they should understand how object-oriented design supports RAP, service classes, testable utility classes, ALV wrappers, and clean-core custom development. In addition, these concepts help developers structure business logic into reusable components that are easier to test and maintain.

How OOPS ABAP Tutorial Works

ABAP Objects is an extension of ABAP that is object-oriented. 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 public methods of the class.

 Visibility is the degree to which the object is available to the outside world. PUBLIC SECTIONs are methods/attributes that are called by their caller. The private section holds internal data values and helper code. General callers are not allowed to access the 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, the behaviour of a superclass can be inherited and/or specialized by a subclass. One way to solve this is to use polymorphism so that one call to the reference can call a 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.

OOPS ABAP Tutorial: Classes, Objects, and Visibility

This OOPS ABAP tutorial starts with the basic relationship between classes and objects. ABAP Objects is an object-oriented extension of ABAP. Attributes and methods are defined in a class: attributes hold data, while methods perform actions. At runtime, ABAP creates an instance of the class when you create an object, allowing you to call its public methods.

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.

OOP in a Nutshell

ConceptWhat It MeansWhy Developers Need It
ClassBlueprint for objectsDefines behavior and structure
ObjectRuntime instanceExecutes class behavior
AttributeData inside class/objectStores state
MethodAction or functionPerforms logic
ConstructorSetup methodInitializes object correctly
EncapsulationControlled accessProtects internal state
InheritanceReuse through parent classReduces duplicate logic
PolymorphismDifferent behaviour through same callSupports flexible design
InterfaceContract without fixed parentSupports clean alternatives

7 Core Concepts Covered in This OOPS ABAP Tutorial


This OOPS ABAP tutorial focuses on the seven concepts that form the foundation of object-oriented ABAP: classes and objects, attributes and methods, constructors, encapsulation, inheritance, polymorphism, and interfaces.

Seven DNA strands of OOP ABAP

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 behaviour. If you are moving from SAP GUI-based development to ADT, see our guide to ABAP Development Tools for Eclipse for the modern development workflow.

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.

Prove Your ABAP Expertise

real-world questions on architecture, performance, OOP, and integrations.

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.

ConceptABAP constructMain purpose
ClassCLASS ... DEFINITIONDefine structure and behaviour
ObjectNEW / CREATE OBJECTCreate runtime instance
AttributeDATA / CLASS-DATAStore object/class state
MethodMETHODS / CLASS-METHODSEncapsulate behaviour
ConstructorMETHODS constructorInitialise an instance
EncapsulationPRIVATE SECTIONProtect internal state
InheritanceINHERITING FROMSpecialise a superclass
PolymorphismReferences/interfacesVary implementation behind a common contract
InterfaceINTERFACESDefine a reusable contract
Exception handlingRAISE EXCEPTION / TRY...CATCHHandle exceptional conditions

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

By the end of this OOPS ABAP tutorial, you should be able to identify where each OO ABAP concept fits into real SAP development and choose the right approach for your application.

Interfaces matter in S/4HANA projects because they help separate business rules from calling programs. They also make code easier to replace later. If you are building these skills from the ground up, our ABAP programming roadmap covers the progression from fundamentals into classes, modern ABAP, CDS, and newer development models.

When to Use It vs. Alternatives

OOP versus procedural ABAP comparison

OO ABAP is important, but not every line of code needs a new class. Good design means choosing the right style for the problem.

ScenarioPrefer OO ABAPPrefer Procedural ABAP
New S/4HANA business logicService class, helper class, interfaceAvoid large procedural blocks
Simple one-time reportLocal class if logic growsStraight report may be enough
ALV output with formatting rulesALV wrapper classBasic procedural ALV for tiny reports
Reusable calculation logicGlobal class or interfaceCopy-paste FORM routines
Legacy ECC report fixSmall method or careful FORMFull rewrite without business approval
RAP/Fiori backend logicClass-based designProcedural code spread across includes
Interview preparationExplain OOP principles with examplesMemorize only definitions

Conclusion:

OO ABAP becomes valuable when it changes how you design SAP code, not simply when you can define a class or explain inheritance in an interview.

To begin with, the seven concepts in this tutorial build on one another. Classes and objects give business logic a structure, while attributes and methods define its state and behaviour. Next, constructors establish a valid initial state, and encapsulation keeps that state under controlled access. At the same time, inheritance can specialize stable parent behaviour, while polymorphism lets callers work with different implementations through a common type. Finally, interfaces provide that common contract without requiring the classes to share a parent.

Therefore, the practical decision is not “Should every ABAP program become object-oriented?” Instead, ask: “Where does object-oriented design make the business logic easier to change, test, reuse, and support?”

Upgrade Your ABAP Skills for 2026

Learn OOP, CDS, RAP, AMDP, and modern APIs.

For modern SAP development, add one more question: which ABAP language version and API model does the target system require? Classic Standard ABAP and ABAP Cloud do not have identical restrictions, so production design needs to account for that context.

Once you can make those decisions deliberately, OO ABAP stops being a list of interview definitions and becomes a useful design tool for S/4HANA, RAP, integrations, and maintainable custom development.

By completing this OOPS ABAP tutorial, you should have a clearer understanding of how OO ABAP supports maintainable SAP development. Pricing, tax, validation, output formatting, workflow helpers, API preparation, and RAP behaviour classes are good examples.

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 does ABAP differentiate between a class and an object?

A class is a blueprint, and an object is a runtime instance that is created from this blueprint. In practice, an OOPS ABAP tutorial starts with a class that defines methods and attributes, while the object stores actual runtime data and executes method calls.

 Why is encapsulation important in ABAP OOPS?

In simple terms, encapsulation keeps an object’s internal data from being changed directly by outside code. Instead, callers use public methods to change class attributes, allowing those methods to validate the data before updating it. As a result, ABAP business rules can remain inside the class rather than being distributed across reports, includes, function modules, and exits.

What is Inheritance in ABAP OOPS?

 Inheritance is a way to reuse and specialize behavior from a parent class. When a child is a special case of a parent, apply inheritance. Document and Invoice is simple problems to explain ABAP OOPS concepts with examples.

Explain the difference between Inheritance and an 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.

References

SAP Help Portal

ABAP Keyword Documentation

ABAP OOPS

Share:

Facebook
Pinterest
LinkedIn
WhatsApp
Picture of Laeeq Siddique - SAP Technical Consultant

Laeeq Siddique - SAP Technical Consultant

I'm a technical and development consultant focused on S/4HANA and BTP, SAP Consultant specializing in developing innovative solutions for Manufacturing, Energy more.

Table of Contents