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.

In ABAP Objects, methods can have IMPORTING, EXPORTING, CHANGING and RETURNING parameters as well as EXCEPTIONS. All parameters can be passed by value or reference.

You can define a return code for methods using RETURNING. You can only do this for a single parameter, which additionally must be passed as a value. Also, you cannot then define EXPORTING and CHANGING parameters. You can define functional methods using the RETURNING parameter (explained in more detail below).

All input parameters (IMPORTING, CHANGING parameters) can be defined as optional parameters in the declaration using the OPTIONAL or DEFAULT additions. These parameters then do not necessarily have to be passed when the object is called. If you use the OPTIONAL addition, the parameter remains initialized according to type, whereas the DEFAULT addition allows you to enter a start value.

Methods, like attributes, must be assigned to a visibility area. This determines whether the methods can be called from outside the class or only from within the class.

Static methods are defined on the class level. They are similar to instance methods, but with the restriction that they can only use static components (such as static attributes) in the implementation part. This means that static methods do not need instances and can therefore be called from anywhere. They are defined using the CLASS-METHODS statement, and they are bound by the same syntax and parameter rules as instance methods.

The term “class method” is common, but the official term in ABAP Objects (as in C++, Java) is “static method”. This course uses the term “static method”.

A UML class diagram shows firstly the class name and, underneath that, the class attributes and methods.

The visibility of components in a class is shown in UML using the characters “+” and “-”:
+ public components
- private components
Alternatively, public and private can be prefixed to the methods. The third option for providers of modeling tools in UML is to introduce their own symbols for visibility.

Representation of visibility characteristics is optional and is normally only used for models that are close to implementation.

Static components are marked with an underscore.

The method signature is represented as follows (optional):
­ The input and output parameters and the parameters to be changed are shown in brackets.

­ The return code is separated from the type name by a colon.

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.


The object LH Berlin is created during runtime in the main memory by instantiation from the lcl_airplane class.
The lcl_airplane class itself does not exist as an independent runtime object in ABAP Objects.

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

DATA: airplane1 TYPE REF TO lcl_airplane declares the reference variable airplane1. This acts as a pointer to an object.

The CREATE OBJECT statement creates an object in the main memory. The attribute values of this object are either initial values or correspond to the VALUE entry.

Reference variables can also be assigned to each other. The above example shows that once it has been assigned, airplane1 points to the same object as reference airplane2.

As soon as no more references point to an object, the Garbage Collector removes it from the memory.

The Garbage Collector is a system routine that automatically deletes objects that are no longer be addressed from the main memory and releases the memory space they occupied.

Independent references are references that have not been defined within a class.



CRM Middle ware Data Load and Monitoring

No comments :

Post a Comment