ABAPIntermediate
OOP ABAP
Master Object-Oriented ABAP with classes, objects, methods, constructors, encapsulation, interfaces, factory methods, testing and S/4HANA-ready design.
Overview
Master Object-Oriented ABAP with classes, objects, methods, constructors, encapsulation, interfaces, factory methods, testing and S/4HANA-ready design.
Lessons in this topic
- Local Classes vs Global ClassesLearn when to use local classes inside a report and when to create reusable global classes.
- Encapsulation and Visibility: PUBLIC, PROTECTED and PRIVATELearn how visibility sections protect data and keep ABAP classes maintainable.
- Interfaces and Factory Methods in Practical ABAPLearn how interfaces and factory methods make ABAP code flexible and testable.
- Classes, Interfaces and PolymorphismComposition over inheritance, interface segregation in ABAP.
- Class-based ExceptionsCX_STATIC_CHECK, CX_DYNAMIC_CHECK, CX_NO_CHECK and TRY/CATCH.
- OOP ABAP in S/4HANA, RAP and Clean CoreUnderstand why OOP ABAP is essential for S/4HANA, RAP, ABAP Cloud and clean core development.
- OOP ABAP Basics: Class, Object, Method and AttributeUnderstand the basic building blocks of OOP ABAP with a simple runnable local class example.
- Instance Methods, Static Methods and ConstructorsUnderstand object creation, constructor logic, instance methods and static methods.
- Composition vs Inheritance in ABAP DesignUnderstand why composition is often safer than inheritance in real ABAP projects.
- Testable OOP ABAP: Dependency Injection and ABAP UnitDesign ABAP classes so business logic can be tested safely with ABAP Unit.
Interview questions covered
- Explain the difference between an interface and an abstract class in ABAP Objects.
- Explain visibility modifiers (PUBLIC, PROTECTED, PRIVATE) in ABAP OO. How do they enforce encapsulation, and what is the impact on inheritance hierarchies?
- Explain RTTI (Runtime Type Information) and RTTS (Runtime Type Services) in ABAP. Design a generic data validation and serialization class using RTTI.
- Explain the difference between the instance constructor and the static constructor in ABAP OO. When is each executed, and when would you use each?
- 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?
- Compare static methods and instance methods. When should you use each, and what are the implications for state management and testability?
- Explain object references and object lifetime in ABAP OO. When are objects automatically garbage collected, and how does this differ from function module data?
- 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.
- How do you evolve an ABAP monolith toward clean OO without a rewrite?
- What is the difference between an interface and an abstract class?
- Method call raises CX_SY_REF_IS_INITIAL. What happened?
- What is polymorphism in ABAP?
- 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?
- You need to send notifications through Email, SMS, and Teams. How would you design this in ABAP OOP?
- When is inheritance the right choice over composition in ABAP?
- Explain the CREATE OBJECT and NEW operator for instantiating objects. What are the differences, and when would you use each in modern ABAP?
- How do you apply Dependency Injection in ABAP?
- What are static-check and dynamic-check exceptions?
- How do you implement a factory pattern in ABAP?