ERPClimb logoERPClimb

SAP ABAP OOP ABAP Interview Questions

OOP ABAP is a standard block in SAP ABAP interviews. It is rarely asked as a definition; it is asked as a situation you have to talk your way through.

Master Object-Oriented ABAP with classes, objects, methods, constructors, encapsulation, interfaces, factory methods, testing and S/4HANA-ready design.

This page carries 26 reviewed SAP ABAP oop abap interview questions, each with a complete written answer and no sign-in required. The set breaks down into 5 foundational, 15 mid-level and 6 advanced questions, so you can start at the top for a first interview or skip ahead to the scenario-based items for a senior round.

Treat the answers as a starting structure, not a script. Interviewers in SAP ABAP rounds follow up on whatever you sound least certain about, so the value is in being able to keep going after the first answer.

26 OOP ABAP questions with answers

easyOOP ABAP

1. Explain visibility modifiers (PUBLIC, PROTECTED, PRIVATE) in ABAP OO. How do they enforce encapsulation, and what is the impact on inheritance hierarchies?

PUBLIC members are accessible from anywhere (same class, subclasses, external programs). PROTECTED members are accessible within the class and its subclasses but NOT from external programs. PRIVATE members are accessible only within the class itself. Encapsulation rationale: SAP designed visibility to prevent external dependencies on internal implementation details. PUBLIC attributes/methods form a contract; changing them breaks all consumers. PRIVATE attributes hide implementation; expose behavior via methods. PROTECTED members are available to subclasses, but exposing mutable state as PROTECTED should still be used carefully because it couples subclasses to the parent's implementation. Prefer protected methods or carefully controlled attributes when extension is genuinely intended. Example: CLASS lcl_employee DEFINITION. PUBLIC SECTION. METHODS display. PRIVATE SECTION. DATA salary TYPE p. ENDCLASS. External code cannot access salary directly; only display() method can expose it. Inheritance impact: if Employee subclass (e.g., Manager) needs salary, make it PROTECTED, not PUBLIC, to prevent accidental modification by unrelated code. When NOT: avoid PRIVATE in simple utility classes where flexibility is valued. Avoid PUBLIC for data attributes; use methods to enforce validation. Interview tip: explain encapsulation as a contract; PUBLIC = promise to maintain; PROTECTED = inheritance pact; PRIVATE = implementation detail. Real project: a material service exposes public query methods while keeping cached data and mutable state private.
easyOOP ABAP

2. Explain the difference between a local class and a global class in ABAP OO. When would you use each, and what are the implications for maintainability and reusability?

Local classes are defined within a program (report, function module, or class) using CLASS...ENDCLASS and are scoped to that program only. Global classes are defined in the class repository (SE24) and are visible across the entire SAP system. Local classes are suitable for single-program utility logic (e.g., helper classes in a report); they reduce repository clutter and are easier to modify without affecting other programs. Global classes are used for reusable business logic accessed by multiple programs, BAdIs, function modules, or web services. Maintainability implications: local classes are tightly coupled to their program; changes are isolated but duplication occurs if multiple programs need the same logic. Global classes enable centralized maintenance; one change benefits all consumers but requires more rigorous testing. Reusability: global classes are inherently reusable; local classes require duplication or refactoring to share. Design practice: use local classes for report-specific utilities, global classes for domain logic (materials, orders, customers). Example: a utility class to format dates locally in a report; a material master class globally for SD/MM/FI processes. Performance: no difference at runtime; both compile to the same bytecode. When NOT to use global classes: avoid creating a global class for trivial single-use logic; use local classes first, promote to global only if reuse is proven.
easyOOP ABAP

3. An ALV event handler is a local class in a report, while a material validation rule is needed by several programs. Where should each class live and why?

The ALV event handler is specific to that report's output: it reacts to double-clicks or user commands on that grid and uses the report's data. A local class is right — no one else needs it, and it can change freely with the report. The material validation is business logic needed elsewhere, so it belongs in a global class (SE24/ADT, e.g. ZCL_MATERIAL_VALIDATOR) with a stable public method, class-based exceptions and unit tests. Global classes have a where-used list, their own transport entries and can be reused by other reports, BAdIs or RFC wrappers. Copying a local class into several programs would create divergent versions.
easyOOP ABAP

4. A custom document class exposes its status as a public attribute, and different programs set invalid status values. How do you fix this with encapsulation?

I would make the status private and allow changes only through methods that enforce the allowed transitions — e.g. release( ), block( ), cancel( ) — each checking the current status and raising an exception for invalid transitions. If callers need to read it, a getter get_status( ) or a READ-ONLY public attribute is enough. Then I find all writers via the where-used list and change them to call the methods. Constants (or an enumeration) define the valid status values. This puts the rule in one place and makes invalid states impossible from outside; unit tests cover each allowed and forbidden transition.
easyOOP ABAP

5. Explain the CREATE OBJECT and NEW operator for instantiating objects. What are the differences, and when would you use each in modern ABAP?

CREATE OBJECT is the traditional ABAP syntax for instantiation, available since ABAP OO inception. NEW is a functional alternative (ABAP 7.4+) providing a more concise syntax. CREATE OBJECT: lref_emp TYPE REF TO lcl_employee. CREATE OBJECT lref_emp. NEW: lref_emp = NEW lcl_employee(). NEW supports inline constructor parameters: lref_emp = NEW lcl_employee( id = 123 name = 'John' ). Differences: CREATE OBJECT requires separate reference declaration and instantiation; NEW combines both. NEW is more concise, supports method chaining, and aligns with modern ABAP style. CREATE OBJECT is still valid but considered legacy in ABAP 7.4+. Constructor parameters: CREATE OBJECT lref_emp EXPORTING id = 123. NEW lcl_employee( id = 123 ) is equivalent. Exception handling: both can raise exceptions if constructor validation fails; use TRY-CATCH. Real project: new code uses NEW; legacy systems still use CREATE OBJECT. Performance: negligible difference; both compile to same bytecode. When NOT: CREATE OBJECT remains necessary in older SAP systems (pre-7.4); avoid mixing syntax in the same codebase for consistency. Best practice: use NEW in new development; migrate legacy CREATE OBJECT in refactoring. Interview tip: mention both for compatibility awareness; prefer NEW for modern ABAP style.
mediumOOP ABAP

6. Explain the difference between an interface and an abstract class in ABAP Objects.

An interface defines a contract (methods, events, constants) with no implementation; a class can implement many interfaces. An abstract class can provide partial implementation and state, but a class inherits from only one. Use interfaces for polymorphism across unrelated hierarchies (e.g., IF_SERIALIZABLE_OBJECT), and abstract classes when subclasses share code and structure (template method pattern).
mediumOOP ABAP

7. Explain the difference between the instance constructor and the static constructor in ABAP OO. When is each executed, and when would you use each?

ABAP OO provides two special constructor methods. The instance constructor is named CONSTRUCTOR and runs each time an object is created with CREATE OBJECT or NEW. It initializes instance attributes, validates constructor parameters, and establishes a valid object state. The static constructor is named CLASS_CONSTRUCTOR and runs automatically once in an internal session, immediately before the class is used for the first time. It initializes CLASS-DATA or other class-wide state. A static constructor has no parameters and cannot be called explicitly. For example, an employee object can receive an employee ID in CONSTRUCTOR, while a configuration class can load shared customizing once in CLASS_CONSTRUCTOR. Avoid heavy database access in either constructor unless it is genuinely required: expensive instance construction hurts bulk processing, while a failing or slow CLASS_CONSTRUCTOR can block every first use of the class. Use lazy-loading methods when initialization is optional or expensive.
mediumOOP ABAP

8. Explain abstract classes and final classes in ABAP OO. When would you mark a class as ABSTRACT or FINAL, and what design constraints does this enforce?

ABSTRACT class cannot be instantiated directly; enforces subclass implementation of abstract methods. FINAL class cannot be inherited; prevents subclassing. Abstract design: CLASS lcl_document DEFINITION ABSTRACT. PUBLIC SECTION. METHODS process ABSTRACT. ENDCLASS. 'Subclass must implement process()' Concrete subclass: CLASS lcl_invoice DEFINITION INHERITING FROM lcl_document. METHODS process. ENDCLASS. Benefits of ABSTRACT: (1) Forces subclasses to implement specific behavior. (2) Defines contract; concrete implementations vary. (3) Prevents instantiation of incomplete logic. FINAL design: CLASS lcl_material_final DEFINITION FINAL. ENDCLASS. 'Cannot inherit from this class' Benefits of FINAL: (1) Locks design; prevents unexpected subclassing. (2) Performance: compiler can inline final methods (minor). (3) Semantic: signals 'no extension intended'. When to use ABSTRACT: define behavior contracts for families of types (e.g., document types). When to use FINAL: prevent subclassing of utility classes or classes not designed for inheritance (e.g., cryptographic classes). Real project: abstract document class (ABSTRACT) with invoice, PO, delivery subclasses; utility classes (FINAL) for string formatting, date calculations. Interview tip: ABSTRACT enforces contract compliance; FINAL enforces design stability.
mediumOOP ABAP

9. Compare static methods and instance methods. When should you use each, and what are the implications for state management and testability?

Instance methods operate on instance attributes and have access to 'this' object state. Static methods (CLASS-METHODS) operate only on CLASS-DATA and input parameters; they have no access to instance state. Instance methods are suitable for business logic tied to object state (e.g., Employee.calculate_salary() uses emp_id and salary). Static methods are utility functions (e.g., Formatter.format_date()) or factory methods (e.g., Material.create_from_id()). Example: CLASS lcl_employee. PUBLIC SECTION. METHODS calculate_salary RETURNING value(sal) TYPE p. CLASS-METHODS validate_id IMPORTING id TYPE i RETURNING value(valid) TYPE abap_bool. PRIVATE SECTION. DATA salary TYPE p. ENDCLASS. calculate_salary() accesses instance salary; validate_id() is stateless. State management: instance methods encapsulate state; static methods are stateless, enabling easier testing and parallelization. Testability: static methods are easier to unit test (no object setup required); instance methods require object instantiation. Real project: Utility classes (date formatting, string manipulation) use static methods; domain classes (Material, Order) use instance methods. When NOT: avoid using static methods for logic that should vary per instance (violates polymorphism); don't use instance methods for shared logic (refactor to static/utility). Performance: static methods are marginally faster (no object overhead) but the difference is negligible. Concurrency safety depends on shared mutable state. A static method using only local data is safe within its execution context, while mutable CLASS-DATA introduces shared session state and must be designed carefully.
mediumOOP ABAP

10. Explain object references and object lifetime in ABAP OO. When are objects automatically garbage collected, and how does this differ from function module data?

Object references (REF TO) point to objects in memory. Objects are created on the heap; references provide access. Example: DATA lo_emp TYPE REF TO lcl_employee. lo_emp = NEW lcl_employee( ). Object lifetime is managed by the garbage collector; objects are freed when no references exist. Function module data (STATICS) persists across calls in the same session; OO objects are freed when all references are gone. Garbage collection timing: ABAP garbage collector runs periodically (not deterministic); objects may persist for some time after last reference is deleted. Explicit cleanup: use CLEAR lo_emp to release reference; if it's the last reference, object may be freed (but not guaranteed immediately). Real project implications: repeated object creation in loops (e.g., 100K materials); garbage collector may not keep pace, causing memory growth. Mitigation: use PACKAGE SIZE with CLEAR between iterations. Difference from function modules: STATIC data persists for session duration; OO objects freed when references gone. Best practice: design for object reuse (factory/singleton) to reduce allocation overhead. Interview tip: mention garbage collection is non-deterministic; avoid relying on specific cleanup timing.
mediumOOP ABAP

11. What is the difference between an interface and an abstract class?

An interface only defines method signatures and constants — no implementation. An abstract class can provide default implementations and state but cannot be instantiated. A class can implement many interfaces but inherit from only one class.
mediumOOP ABAP

12. Method call raises CX_SY_REF_IS_INITIAL. What happened?

The object reference variable was not instantiated (missing CREATE OBJECT / NEW). Add a defensive check or a factory that guarantees a non-null instance; use ASSIGN or DATA(lo) = NEW cl_foo( ) inline creation to avoid orphans.
mediumOOP ABAP

13. A report has customer, material and pricing validation all inside one START-OF-SELECTION block. How would you restructure it using classes?

I would identify the responsibilities: reading data, three separate validations, and output. Each validation becomes its own class (or method of a validator class) with a clear public method, e.g. zcl_customer_validator->validate( ) raising a class-based exception or returning messages. The report gets a local application class lcl_report with methods get_data, validate and display; START-OF-SELECTION only does CREATE OBJECT go_report and go_report->run( ). Validators that other programs might need become global classes; report-specific output stays local. I move one block at a time and compare output with the same variants, then add ABAP Unit tests for the validators.
mediumOOP ABAP

14. A service catches CX_ROOT and raises a generic "Save failed" error, so support cannot see whether it was a locking or SQL problem. How should exceptions be handled instead?

Catching CX_ROOT and replacing it loses the root cause. I would catch only the exceptions this layer can handle or translate — for example CX_SY_OPEN_SQL_DB or a lock exception — and raise a meaningful business exception such as ZCX_ORDER_SAVE_ERROR with a specific T100 text and PREVIOUS = the caught exception. The caller or log can then walk the previous chain and show the original message. Expected business errors use CX_STATIC_CHECK subclasses declared with RAISING. Unexpected errors should not be silently converted; if a top-level handler catches CX_ROOT (e.g. in a background job), it logs the full chain in the application log (BAL) before reporting a generic message.
mediumOOP ABAP

15. Country tax rules are implemented as a long CASE statement in several programs. How would you introduce a factory, and how would you make it extensible without code changes?

I would create the interface ZIF_TAX_CALCULATOR and one class per country, then a factory ZCL_TAX_FACTORY=>CREATE( iv_country ) returning the interface. Programs call only the factory and the interface method, so the CASE moves into one place. For extensibility without changing the factory, a customizing table maps country → class name. The factory reads it and uses CREATE OBJECT ro_tax TYPE (lv_classname), catching CX_SY_CREATE_OBJECT_ERROR and falling back to a default. New countries need a new class and a table entry. For tests, the factory can return a double through an injector.
mediumOOP ABAP

16. Country-specific tax logic was written as IF/CASE blocks in several programs. How would you use interfaces and polymorphism to redesign it?

I would define an interface ZIF_TAX_CALCULATOR with a method CALCULATE( iv_net ) returning the tax, and implement one class per country (ZCL_TAX_IN, ZCL_TAX_DE, a default). The programs hold a reference of type ZIF_TAX_CALCULATOR and call calculate( ) — which implementation runs depends on the object: that is polymorphism. Objects are created in one factory (by country or customizing), so the CASE exists only there or disappears into a table. Adding a country means one new class, not changes in every program. Each class can be tested separately. Shared logic can go into an abstract base class if the countries have common steps.
mediumOOP ABAP

17. You need to send notifications through Email, SMS, and Teams. How would you design this in ABAP OOP?

Define an interface ZIF_NOTIFIER with SEND( iv_to, iv_message ). Implement ZCL_EMAIL_NOTIFIER, ZCL_SMS_NOTIFIER, ZCL_TEAMS_NOTIFIER. A factory ZCL_NOTIFIER_FACTORY=>GET( iv_channel ) returns the correct instance; caller depends on the interface, not concrete classes. Adding a new channel means one new class + one factory entry – no change to callers (Open/Closed principle).
mediumOOP ABAP

18. A pricing class used static attributes for sales organization and configuration, and results mixed up when two sales orgs were processed in one run. What went wrong and how do you fix it?

Static attributes exist once per internal session and are shared by all users of the class in that session. Processing sales org 1000 set them, then 2000 overwrote them, and any object still working for 1000 used the wrong values. The fix is to make the data instance-specific: the constructor takes the sales org (and dependencies such as a configuration reader), stores them in private instance attributes, and each sales org gets its own object. Static components are fine for truly session-wide data such as a read-only customizing cache filled in CLASS_CONSTRUCTOR, keyed by sales org — never for per-document state.
mediumOOP ABAP

19. A delivery service reads customer-risk data directly from the database inside its methods, so it cannot be unit tested. How do you make it testable?

I would move the database access into a DAO behind an interface, e.g. ZIF_CUSTOMER_RISK_DAO with GET_RISK( iv_kunnr ). The service receives it through its constructor — optional, defaulting to the real DAO so existing callers stay unchanged. In ABAP Unit I write a test double implementing the interface that returns fixed risk values (and records calls if needed). setup creates the double and the service with it; test methods cover high, low and missing risk. For global interfaces I can use CL_ABAP_TESTDOUBLE instead of a hand-written class. Tests are then independent of system data and run in ATC.
mediumOOP ABAP

20. What are static-check and dynamic-check exceptions?

Static-check exceptions (subclass of CX_STATIC_CHECK) must be caught or declared with RAISING; the compiler enforces it. Dynamic-check (CX_DYNAMIC_CHECK) are checked at runtime only. CX_NO_CHECK need no declaration and represent framework errors.
hardOOP ABAP

21. Explain RTTI (Runtime Type Information) and RTTS (Runtime Type Services) in ABAP. Design a generic data validation and serialization class using RTTI.

RTTI is runtime type information; RTTS is the ABAP framework used to inspect and dynamically construct type descriptions at runtime. The CL_ABAP_*DESCR hierarchy includes CL_ABAP_TYPEDESCR, CL_ABAP_STRUCTDESCR, CL_ABAP_TABLEDESCR, CL_ABAP_CLASSDESCR and related descriptors. For data objects, CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA or DESCRIBE_BY_DATA_REF can return a descriptor. For object references, CL_ABAP_CLASSDESCR=>DESCRIBE_BY_OBJECT_REF can inspect the runtime class. A generic validator or serializer can inspect components of a structure, recursively process nested structures and internal tables, and cache descriptors by absolute type name to avoid repeated introspection overhead. RTTI/RTTS is appropriate for generic frameworks such as serializers, mapping utilities and dynamic UI generation, but ordinary business logic should prefer static typing because it is clearer and checked earlier.
hardOOP ABAP

22. Explain exception handling in OO ABAP. Design a custom exception hierarchy for a material master API that handles validation errors, not-found errors, and database errors gracefully.

Exception handling in OO ABAP uses TRY-CATCH blocks and custom exception classes inheriting from CX_ROOT. Design hierarchy: CLASS lcx_material_error DEFINITION INHERITING FROM cx_static_check. PUBLIC SECTION. INTERFACES if_t100_message. METHODS constructor IMPORTING textid LIKE if_t100_message=>t100key OPTIONAL previous TYPE REF TO cx_root OPTIONAL. ENDCLASS. CLASS lcx_material_not_found DEFINITION INHERITING FROM lcx_material_error. ENDCLASS. CLASS lcx_validation_error DEFINITION INHERITING FROM lcx_material_error. ENDCLASS. API usage: METHOD get_material. TRY. DATA lo_mat TYPE REF TO lcl_material. lo_mat = NEW lcl_material( id ). CATCH lcx_validation_error INTO DATA(ex). 'Handle validation error' RAISE EXCEPTION TYPE lcx_validation_error EXPORTING previous = ex. CATCH lcx_material_not_found. 'Handle not-found' CATCH cx_sy_sql_error INTO DATA(sql_ex). 'Handle database error' RAISE EXCEPTION TYPE lcx_material_error. ENDTRY. ENDMETHOD. Benefits: (1) Specific exceptions for different error types. (2) Exception chain preserves original cause (PREVIOUS). (3) Uniform error handling via common base class. (4) Caller can catch specific or general exceptions. Real project: API layer catching domain exceptions, translating to HTTP status codes or user messages. When NOT: avoid exceptions for control flow (e.g., loop termination); use only for exceptional conditions. Best practice: custom exceptions include message text and parameter passing (IMPORTING textid).
hardOOP ABAP

23. How do you evolve an ABAP monolith toward clean OO without a rewrite?

Introduce a domain package with pure classes, wrap legacy FMs in adapters, cover with ABAP Unit tests before refactoring, move logic incrementally out of reports into services, and use ATC + Code Inspector variants to enforce OO rules on new code only.
hardOOP ABAP

24. A billing engine created a subclass for every provider and country combination and now has dozens of subclasses. How would you redesign it?

This is inheritance used for combinations, which explodes because ABAP has single inheritance. I would split the varying dimensions into separate interfaces — e.g. ZIF_PROVIDER_FORMAT and ZIF_COUNTRY_TAX — each with small FINAL implementations. The billing class receives one object of each through its constructor (composition) and delegates to them. A factory selects the implementations from customizing. New providers or countries become one new class each, not one per combination. Inheritance remains only where there is a true is-a relationship or a stable shared frame (an abstract base with template steps). Each strategy is tested separately.
hardOOP ABAP

25. A sales-order rule exists separately in a user exit, an OData service and a background job. How would you consolidate it in an S/4HANA clean core approach?

I would implement the rule once in a reusable global class (e.g. ZCL_SO_CREDIT_RULE) with a clear interface and class-based exceptions, using released APIs/CDS views for data where possible; unreleased access goes into a wrapper class. Then each channel calls it: the classic user exit (or preferably a released BAdI) calls it with the order data, the RAP/OData layer calls it from a validation handler and maps exceptions to messages, and the background job calls it and logs results. I agree the correct rule with the business first, add ABAP Unit tests, and run ATC with clean core checks. Moving from the user exit to a released BAdI or RAP extension can follow later without touching the rule.
hardOOP ABAP

26. When is inheritance the right choice over composition in ABAP?

When there is a genuine is-a relationship and shared invariants that all subclasses must preserve (e.g. persistent object base classes, RAP behavior implementations extending framework hooks). For strategy or utility reuse, prefer composition to avoid fragile hierarchies.

Related lesson

OOP ABAP Part 5: Instance Methods, Static Methods and Constructors

Related topics

Next practice step

Go deeper on this topic