SAP Tutorials Blog

Class : A class can contain very different objects depending on the abstraction.
A class is a description of a number of objects that have the same structure and the same behavior. A class is therefore like a blueprint, in accordance with which all objects in that class are created. The components of the class are defined in the definition part. The components are attributes, methods, events, constants, types and implemented interfaces. Only methods are implemented in the implementation part.
The CLASS statement cannot be nested, that is, you cannot define a class within a class.

Methods : Methods are internal procedures in classes that determine the behavior of an object. They can access all attributes in their class and can therefore change the state of an object. Methods have a parameter interface that enables them to receive values when they are called and pass values back to the calling program.
There are three types of method:
1. Methods that cause behavior and do not pass values
2. Methods that pass a value
3. Methods that pass or change several values
 Public methods can be called from outside the class in a number of ways:
Instance methods are called using CALL METHOD <reference>-><instance_method>.
Static methods are called using CALL METHOD <classname>=><class_method>.
Instantiation: A class contains the generic description of an object. It describes all the characteristics that are common to all the objects in that class. During the program runtime, the class is used to create specific objects (instances). This process is called instantiation.

Realization: Objects are instantiated using the statement: CREATE OBJECT.
During instantiation, the runtime environment dynamically requests main memory space and assigns it to the object.

Garbage Collector: Concept :
All independent references in the global main memory are checked. The
references point to active objects, which are marked internally. If class or instance attribute references point to other objects, these are also marked. Objects that are not marked are deleted from the main memory.

Encapsulation : Encapsulation means that the implementation of an object is hidden from other components in the system, so that they cannot make assumptions about the internal status of the object and therefore dependencies on specific implementations do not arise.

Constructor: The constructor is a special (instance) method in a class and is always named CONSTRUCTOR. The following rules apply:
  • Each class has exactly one constructor.
  • The constructor does not need to be defined if no implementation is defined.
  • The constructor is automatically called during runtime within the CREATE OBJECT statement.

The Delegation Principle : In delegation, two objects are involved in handling a request: the recipient of the request delegates the execution of the request to a delegate.

Inheritance
 : Inheritance defines the implementation relationship between classes, in which one class (the subclass) shares the structure and the behavior defined in one or more other classes (superclasses).
Note: ABAP Objects only allows single inheritance.

Inheritance should be used to implement generalization and specialization relationships. A superclass is a generalization of its subclasses. The subclass in turn is a specialization of its superclasses. In ABAP Objects, you can not only add new components, but also provide inherited methods with new implementations. This is known as redefinition. The REDEFINITION statement for the inherited method must be in the same SECTION as the definition of  the original method. To implement a redefined method in a subclass, you often need to call the method of the same name in the immediate superclass. In ABAP Objects you can call the method from the superclass using the pseudoreference super: CALL METHOD super->method_name.

Polymorphism: Polymorphism (ability to have multiple forms) in the context of object technology signifies that objects in different classes have different reactions to the same message.
Polymorphism is one of the main strengths of inheritance: the user can work in the same way with different classes, regardless of their implementation. The search for the right implementation of a method is carried out by the runtime system.

Final class  : A final class cannot have subclasses, and can protect itself in this way against (uncontrolled) specialization. A final method in a class cannot be redefined in a subclass, and can protect itself in this way against (uncontrolled) redefinition. Some characteristics: A final class implicitly only contains final methods. You cannot enter FINAL explicitly for these methods in this case. Methods cannot be both final and abstract.
Classes, on the other hand, can usefully be both abstract and final: only static components can be used there.

Interfaces : interfaces are implemented in addition to and independently of classes. Interfaces exclusively describe the external point of contact of a class, but they do not contain their own implementation part. Interfaces are usually defined by a user. The user describes in the interface which services  it needs in order to carry out a task. A class can implement any number of interfaces and an interface can be implemented by any number of classes.



Serkan AKKAVAK
Computer Engineer BSc
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com