ABAP Old vs New Syntax Cheat Sheet Assigning Value to a Variable *--Old Syntax DATA var1 TYPE char5. var1 = 'ABC'. *--New Syntax DATA(var1) = 'ABC'. 2. SELECT SINGLE INTO Work Area *--Old Syntax DATA wa TYPE ... SELECT SINGLE fld1 ...
SAP EWM Help Latest Questions
While ABAP classes can’t inherit from multiple classes, they can implement multiple interfaces, achieving interface-based multiple inheritance. INTERFACE if1. METHODS: method1. ENDINTERFACE. INTERFACE if2. METHODS: method2. ENDINTERFACE. CLASS my_class DEFINITION. PUBLIC SECTION. INTERFACES: if1, if2. ENDCLASS. CLASS my_class IMPLEMENTATION. METHOD if1~method1. WRITE: 'Method1 from IF1'. ENDMETHOD. METHOD if2~method2. WRITE: 'Method2 from IF2'. ENDMETHOD. ENDCLASS.
1. Single Inheritance (Supported in ABAP) Definition: One subclass inherits from one superclass. Use: Most common form of inheritance. CLASS parent_class DEFINITION. PUBLIC SECTION. METHODS: display.ENDCLASS.CLASS parent_class IMPLEMENTATION. METHOD display. WRITE: 'Parent class method'. ENDMETHOD.ENDCLASS.CLASS child_class DEFINITION INHERITING FROM parent_class.ENDCLASS.CLASS child_class IMPLEMENTATION.ENDCLASS.
Access specifiers define the visibility and accessibility of class components such as attributes, methods, and events. They help in implementing encapsulation, a core concept of object-oriented programming (OOP), by controlling which parts of a class can be accessed from outside ...
An interface in ABAP defines a contract that any implementing class must follow. It contains only declarations of: Methods (without implementation) Constants Types Attributes Interfaces do not contain implementation. Any class that implements an interface must provide the logic for all its methods. Feature Description No implementation Only method ...
A constructor is a special method automatically called when an object is created using CREATE OBJECT or NEW. Types of Constructors in ABAP Type Method Name Called On Purpose Instance Constructor CONSTRUCTOR When an ...
A Singleton class is a design pattern that restricts the instantiation of a class to one single object throughout the lifecycle of a program. This is useful when exactly one object is needed to coordinate actions across the system — such as logging, configuration ...
Polymorphism allows different classes to be treated through a common parent reference, while still calling their own version of a method at runtime. When to use it: When you want to treat multiple objects generically, but still get their specific behavior. In ...
Instance Members (Methods & Data) Belong to individual objects (instances). Created using DATA and METHODS. Each object has its own copy of the data. Accessed using the object reference: lo_obj->method_name. Useful when each object should maintain its own state. Destroyed when the object goes out of ...
Method overriding allows a subclass to provide a new implementation of a method that is already defined in the superclass. The method in the subclass must use the REDEFINITION keyword. When to use it: When a general method in a ...