Object Introduction
ABAP Objects Objects should enable programmers to map a real problem and its proposed software solution on a one-to-one basis. Typical objects in a business environment are, for example, �Customer�, �Order�, or �Invoice�.
A D V E R T I S E M E N T
What is ABAP Objects
ABAP Objects stands for Object oriented ABAP. Compared to the traditional
ABAP programming language, ABAP Objects represents an extension of ABAP that
provides the language with the tools to support the object oriented programming
paradigm.
What is object oriented programming?
To anyone who doesn�t know what object oriented programming is, the object
orientation terminology might sound like it is yet another fancy concept that
doesn�t serve any real purpose nor provide any real added value just like too
many other concepts in computer sciences. More recent than the traditional
procedural programming model in which the source code is arranged in procedures
to help achieve some level of modularity, the object oriented programming builds
on the basics of the existing procedural programming model to propose a
radically more sophisticated and comprehensive programming model.
This model lets the analyst-programmer implement complex
systems made up of numerous objects linked together or not and control the
interactions between these objects. This characteristic of the object
programming language constitutes a definitive advantage other traditional
programming techniques as it becomes much easier to solve complex problems. As
you have already understood, the notion of Object is at the center of the model.
It is voluntarily a very general notion as its aim is to describe anything that
has properties and functions. In this sense, the terminology object is not yet
abstract enough because it bears some idea of concreteness while an object in
the sense of object oriented programming might very well represent abstract
things. In fact the notion of Object could have been advantageously replaced
with the notion of Concept as the programming model we are going to see is able
to manipulate any kinds of concepts and to make actual representations of them.
The object oriented programming model has three major characteristics. It
assumes support for:
Encapsulation
Inheritence
Polymorphism
1. Encapsulation
Encapsulation is the ability that an object has to contain and restrict the
access to its members. We will see later that objects members may be either
properties (data) or methods (functions) of the objects. Encapsulation is a key
concept of object programming that ensures the autonomy and integrity of the
objects.
2. Inheritance
Inheritance is the ability of an object to inherit the properties and methods of
an other object. We will come back to this later as you need to have a good
understanding of what an object really is if you want to apprehend this concept.
Keep in mind for the moment that inheritence is the ability offered to objects
to inherit properties from other objects and to form hierarchies. This
characteristic leads to the creation of families of objects (just like families
exist for humans) with parent objects and child objects. In this configuration,
it is clear that child objects inherit some characteristics from their parent
object.
3. Polymorphism
This somewhat barbaric term designates the ability of objects to redefine
properties inherited from their parents. In other words, a method of an object
may have different implementations (behaviours or forms) depending on the object
that implements it. This characteristic of the object oriented languages is an
important asset to implement abstract concepts which often make sense only in
specific contexts.
Classes are templates for objects. Conversely, you can say that the type of
an object is the same as its class. A class is an abstract description of an
object. You could say that it is a set of instructions for building an object.
The attributes of objects are defined by the components of the class, which
describe the state and behavior of objects.
The main difference between real object orientation and function groups is that although a program can work with the instances of several function groups at the same time, it cannot work with several instances of a single function group. Suppose a program wanted to use several independent counters, or process several orders at the same time. In this case, you would have to adapt the function group to include instance administration, for example, by using numbers to differentiate between the instances.
Object Declaring and Calling Methods
This section contains
explains how to work with methods in ABAP Objects. For precise details of the
relevant ABAP statements, refer to the corresponding keyword documentation in
the ABAP Editor.
Declaring Methods
You can declare methods in
the declaration part of a class or in an interface. To declare instance methods,
use the following statement:
METHODS meth
IMPORTING [VALUE(]i1
i2 � [)] TYPE type [OPTIONAL]�
EXPORTING [VALUE(]e1
e2 � [)] TYPE type �
CHANGING [VALUE(]c1
c2 � [)] TYPE type [OPTIONAL]�
RETURNING VALUE(r)
EXCEPTIONS exc1
exc2 � .
and the appropriate additions.
To declare static methods, use the
following statement:
CLASS-METHODS meth�
Both statements have the
same syntax.
|