If you want to keep several objects from the same class in your program, you can define an internal table, which might, for example, only consist of one column with the object references for this class.You can work with the objects using the internal table within the loop.If a class defines object references to a second class as attributes (in the above example: left_wing, right_wing), then only these object references will be stored in the objects belonging to that class. The objects in the second class have their own identity.

Public attributes can be accessed from outside the class in various ways:

Static attributes are accessed using =>.

Instance attributes are accessed using ->.

Every object behaves in a certain way. This behavior is determined by its methods. 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

An object that requires services from another object sends a message to the object providing the services. This message names the operation to be executed. The implementation of this operation is known as a method.

For the sake of simplicity, method is used below as a synonym for operation and message.

Public methods can be called from outside the class in a number of ways:

Instance methods are called using CALL METHOD ->.

Static methods are called using CALL METHOD =>.
Static methods are addressed by class name, since they do not need instances.

If you are calling a static method from within the class, you can omit the class name.

When calling an instance method from within another instance method, you can omit the instance name. The method is automatically executed for the current object.

Methods that have a RETURNING parameter are described as functional methods. These methods cannot have EXPORTING or CHANGING parameters, but has many (or as few) IMPORTING parameters and EXCEPTIONS as required.

Functional methods can be used directly in various expressions (although EXCEPTIONS are not catchable at the moment - you must use the long form of the method call):
­ in logical expressions (IF, ELSEIF, WHILE, CHECK, WAIT)
­ in the CASE statement (CASE, WHEN)
­ in the LOOP statement
­ in arithmetic expressions (COMPUTE)
­ in Bit expressions (COMPUTE)
­ in the MOVE statement.

The syntax for instance methods (analogous to static methods) is as follows, depending on the number of IMPORTING parameters :
­ no IMPORTING parameters: ref->func_method( )
­ exactly 1 IMPORTING parameter : ref->func_method( p1 ) oder
ref->func_method( im_1 = p1 )
­ several IMPORTING parameters : ref->func_method( im_1 = p1 im_2 = p2 )

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.
­ If you need to implement the constructor, then you must define and implement it in the PUBLIC SECTION.

When EXCEPTIONS are triggered in the constructor, instances are not created (as of 4.6a), so no main memory space is taken up.

You need to implement the constructor when, for example
­ You need to allocate (external) resources
­ You need to initialize attributes that cannot be covered by the VALUE supplement to the DATA statement

­ You need to modify static attributes
You cannot normally call the constructor explicitly.

The static constructor is a special static method in a class and is always named CLASS_CONSTRUCTOR. It is executed precisely once per program. The static constructor of class is called automatically before the class is first accessed, that is, before any of the following actions are executed:

­ Creating an instance in the class using CREATE OBJECT obj, where obj has the data type

­ Addressing a static attribute using =>.
­ Calling a static attribute using CALL METHOD =>.
­ Registering a static event handler method using SET HANDLER => for obj.

­ Registering an event handler method for a static event in class .
The static constructor cannot be called explicitly.


The principle of encapsulation is to hide the implementation of a class from other components in the system, so that these components cannot make assumptions about the internal state of the objects in that class or of the class itself. This prevents dependencies on specific implementations from arising.

The class is the capsule surrounding related functions.

The principle of visibility ensures that the implementation of the functions and the information administered within a class is hidden.

Classes behave like client/server systems: When a class is called by a method of another class, it automatically becomes the client of the other (server) class.

This creates two requirements :
The client class must observe the protocol of the server class.
The server class protocol must be clear and detailed enough that a potential client has no trouble in orienting by it.

Classes normally play both roles. Every class is a potential server class, and when it is called by a method of another class it then becomes a client class too.

Establishing logical business and software responsibilities between classes results in a true client/server software system in which redundancy is avoided.

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

The pilot (lcl_client) calls the method get_fuel_level from the airplane class (lcl_airplane). The airplane cannot carry out this task itself. Therefore the airplane calls the get_fuel_level method from the tank class (lcl_tank), that is, the airplane delegates the execution of the method to the tank.

The main advantage of delegation (as a re-use mechanism) lies in the option of changing the behavior of the recipient by substituting the delegate (at runtime). For example, delegation enables the airplane to be equipped with a new tank, without the call changing for the client or for the airplane class.

Good capsulation often forces you to use delegation: if tank in the above example were a private attribute in class lcl_airplane, then the user cannot address the tank directly, but only through the airplane!

Within a class, attribute names, method names, event names, constant names, type names and alias names all share the same namespace.

There is a local namespace within methods. Definitions of variables can cover components in one class.

You can address the object itself within object methods using the implicitly available reference variable ME.

Description of the example:
In the CONSTRUCTOR, the instance attribute name is covered by the locally defined variable name. In order to still be able to address the instance attribute, you need to use ME.



CRM Part Two

SAP CRM Organizational management
SAP CRM Territory Management 
CRM Product manager
CRM Business Transactions

No comments :

Post a Comment