Skip to content
IT Canvass
SAP ABAP development · Lesson

Classes

Quick answer

Learn encapsulation (public/private sections), instantiation (NEW), inheritance and interfaces, and static vs instance members.

Key takeaways

  • OO ABAP replaces sprawling procedural programs with encapsulated classes: data (attributes) and behaviour (methods) bundled…
  • Local classes: defined inside a program (DEFINITION/IMPLEMENTATION).
  • Global classes: created in class builder (SE24) or ADT, reusable across the system.
  • Watch out: Writing procedural code where OO would be cleaner/reusable.

Why object-oriented ABAP

OO ABAP replaces sprawling procedural programs with encapsulated classes: data (attributes) and behaviour (methods) bundled together, with clear interfaces and reuse through inheritance and interfaces. SAP’s modern frameworks (RAP, many APIs) are OO, and unit testing (ABAP Unit) works naturally with classes.

Local vs global classes

  • Local classes: defined inside a program (DEFINITION/IMPLEMENTATION).
  • Global classes: created in class builder (SE24) or ADT, reusable across the system.

A simple class

CLASS lcl_calculator DEFINITION.
  PUBLIC SECTION.
    METHODS add IMPORTING iv_a TYPE i iv_b TYPE i
                RETURNING VALUE(rv_sum) TYPE i.
ENDCLASS.
CLASS lcl_calculator IMPLEMENTATION.
  METHOD add.
    rv_sum = iv_a + iv_b.
  ENDMETHOD.
ENDCLASS.

DATA(lo_calc) = NEW lcl_calculator( ).
DATA(lv_result) = lo_calc->add( iv_a = 2 iv_b = 3 ).

Key OO concepts

Learn encapsulation (public/private sections), instantiation (NEW), inheritance and interfaces, and static vs instance members. These enable clean, reusable designs and are expected in modern SAP development.

Common pitfalls

  • Writing procedural code where OO would be cleaner/reusable.
  • Exposing everything public, breaking encapsulation.
  • Ignoring ABAP Unit testing that OO enables.

Want to learn this properly?

Our live, instructor-led SAP Training covers this hands-on, with real projects and a certification path.

Check your understanding

  1. Which statement is true of Classes?

    • A. A strong SAP resume proves real, specific experience, the modules/technologies you have worked with, the…
    • B. SAP’s modern frameworks (RAP, many APIs) are OO, and unit testing (ABAP Unit) works naturally with classes.
    • C. A routing defines the sequence of operations, the steps, work centers and times, needed to manufacture a…
    Show answer

    B. SAP’s modern frameworks (RAP, many APIs) are OO, and unit testing (ABAP Unit) works naturally with classes.

    Covered in the “Why object-oriented ABAP” section of this lesson.

  2. Which of these also applies to Classes?

    • A. Skipping the PAM check, running an unsupported combination.
    • B. Postings to a period during/after close, control periods tightly.
    • C. These enable clean, reusable designs and are expected in modern SAP development.
    Show answer

    C. These enable clean, reusable designs and are expected in modern SAP development.

    Covered in the “Key OO concepts” section of this lesson.

  3. Which part of the Learn SAP curriculum covers Classes?

    • A. SAP labs
    • B. SAP ABAP development
    • C. SAP FI
    Show answer

    B. SAP ABAP development

    This lesson sits in the SAP ABAP development section of the Learn SAP course.

Frequently asked questions

What does the term Classes refer to in SAP?

Classes bring object-oriented programming to ABAP. Modern ABAP is object-oriented, code is organised into classes with attributes and methods, and understanding OO ABAP is essential for writing clean, reusable, testable code.

What is the practical takeaway on Classes?

Learn encapsulation (public/private sections), instantiation (NEW), inheritance and interfaces, and static vs instance members.

What is worth remembering about Classes in practice?

OO ABAP replaces sprawling procedural programs with encapsulated classes: data (attributes) and behaviour (methods) bundled together, with clear interfaces and reuse through inheritance and interfaces.

What tends to go wrong with Classes?

Writing procedural code where OO would be cleaner/reusable. Exposing everything public, breaking encapsulation. Ignoring ABAP Unit testing that OO enables.
CallWhatsAppEnquire