chapter 01_fundamentals of abap object
TRANSCRIPT
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 1/37
© Copyright IBM Corporation 2007
IBM Global Business Services
Fundamentals of ABAP Objects
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 2/37
IBM Global Services
© 2007 IBM Corporation2 Jan-2007Fundamentals of ABAP Objects
Objectives
Upon completion of this chapter, the participants will be able to: Recognize the concept of Object Oriented Programming (OOP)
Identify the features of Object Oriented Programming & its Advantages
Recall the history of ABAP Object Oriented Programming
Identify the need to learn ABAP Objects
Analyze the basic building blocks of ABAP Objects
Create a local Class with Attributes, Methods, Constructors.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 3/37
IBM Global Services
© 2007 IBM Corporation3 Jan-2007Fundamentals of ABAP Objects
Features of Procedural Programming Model
Data and Functions are kept separate. Global variables of program contains data,while subroutine contains functions.
Usually non-encapsulated access to data. (exception: Global data of Function
Group is only accessible by Function Modules within that group).
Program maintenance as well as management becomes difficult as program size
increases. Very difficult to model real word entity.
Not possible to create several runtime instances easily.
Data
Data
Data
Function
Function
Function
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 4/37
IBM Global Services
© 2007 IBM Corporation4 Jan-2007Fundamentals of ABAP Objects
What is Object Oriented Programming (OOP) ?
The fundamental idea behind Object Oriented Programming (OOP) is to combine both data and the functions (methods) those operate on that data into a single
unit. Such an unit is called Object.
Possibility of creating several runtime instances is one of the key characteristics
of Object Oriented Programming. This allows you to create a direct abstraction of
a real world object.
Data
Function
Object
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 5/37
IBM Global Services
© 2007 IBM Corporation5 Jan-2007Fundamentals of ABAP Objects
Basic building blocks of OOP
Classes and Objects are the basic building blocks of Object OrientedProgramming. When a real world entity is modeled into OOP world then it is
known as Class, characteristics as attributes and functionality as methods.
Objects are instances of a Class.
Example :
What are the
characteristics of the
box? (Attributes)
Inside color is blue
(Private)
Outside color is
white (Public)
What is the status of the box ? (Events)
The box is semi open
Functions of the box? (Methods)
It can store things
It can occupy space
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 6/37
IBM Global Services
© 2007 IBM Corporation6 Jan-2007Fundamentals of ABAP Objects
Client/Server Relationship & Delegation
Objects behave like Client/Server systems.
When an objects sends a message to another object, telling it to behave in a
particular way, the first object can be seen as a Client and the second as a Server
In OOP services are distributed among objects to avoid redundancy and each
object offers only those services that are within its area of responsibility.
If an object needs any other services, it requests these from other objects. This isknown as principle of delegation.
Data
Object 1
Data
Object 2
Sends Message toRetrieve Details
Function:
GET_DETAILS
Function:
RETRIEVE_DETAILS
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 7/37
IBM Global Services
© 2007 IBM Corporation7 Jan-2007Fundamentals of ABAP Objects
Features of Object Oriented Programming
Abstraction Modeling real world entities and processes in a more natural way.
Ecapsulation
Hiding data and its related logic behind well defined interfaces.
Inheritance
Reusing attributes and methods while allowing for specialization.
Polymorphism
Simplifying by hiding varying implementations behind the same interface.
Code Reuse
Same code can be reused multiple times by using inheritance.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 8/37
IBM Global Services
© 2007 IBM Corporation8 Jan-2007Fundamentals of ABAP Objects
Advantages of Object Oriented Programming
Real world entity can be modeled very well.
Provides advance level of data encapsulation that improves the maintainability
and stability of ABAP programs.
Better programming structure, reduced maintenance effort & less susceptibility to
errors.
Software extension is simpler & more secure.
Stress on data security and access.
Data encapsulation and abstraction.
Once a base class is written and tested, it need not be touched again. Reusing
existing code through “Inheritance” saves time, money and increase a programs
reliability.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 9/37
IBM Global Services
© 2007 IBM Corporation9 Jan-2007Fundamentals of ABAP Objects
History of ABAP Object Oriented Programming
Object Oriented Programming (OOP) in general was developed at approximatelythe same time as procedural programming models.
In SAP:
SAP Basis Release 4.5 delivered the first version of ABAP Objects.
SAP Basis Release 4.6 delivered complete version of ABAP Objects by introducing
‘Inheritance’. SAP Web Application Server 6.10/6.20 enhanced ABAP Objects with Friendship and
Object Services.
The object-oriented concept in ABAP is same as other modern object-oriented
languages such as C++ or Java.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 10/37
IBM Global Services
© 2007 IBM Corporation10 Jan-2007Fundamentals of ABAP Objects
ABAP as Hybrid Language
The ABAP runtimesupport for both theprocedural and ABAPObjects programmingmodels
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 11/37
IBM Global Services
© 2007 IBM Corporation11 Jan-2007Fundamentals of ABAP Objects
ABAP as Hybrid Language (Contd.)
ABAP Objects is not a new language, but a systematic extension of ABAP.
Type checks in ABAP Object context is stricter.
Cleaner Syntax: Obsolete statements lead to syntax errors.
ABAP object statements can be used in procedural ABAP programs.
Object (Classes) can also contain procedural ABAP statements.
Although a pure OO world is technically possible, most real-worldimplementations use a mixture of procedural ABAP and ABAP Objects.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 12/37
IBM Global Services
© 2007 IBM Corporation12 Jan-2007Fundamentals of ABAP Objects
Why do we need to learn ABAP Objects ?
To understand the recent concepts of ABAP e.g. BAPI, BAdi, Workflow.
ABAP Objects is the only way you can use new ABAP technology. For example
all new GUI concepts, such as the SAP Control Framework (CFW) and Business
Server Pages (BSP), are encapsulated in ABAP Objects classes.
For interfacing ABAP with Microsoft technologies or Java as all these are built on
the OOP concept. To take advantage of cleaner syntax and semantic rules.
To exploit the object resource that has been provided by SAP.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 13/37
IBM Global Services
© 2007 IBM Corporation13 Jan-2007Fundamentals of ABAP Objects
Classes ( Global + Local )
A class is a template/blueprint based on which all objects of the class arecreated. Class does not occupies any memory space during program
execution only the instance of an class (objects) occupies memory space. In ABAP, classes can be of two types:
Global Class (Created using class builder (SE24) and stored in class repository
as Class pool) Local Class (Created in any ABAP program in global declarations section and
only accessible to the programs within the main program.)
Global vs. Local Classes Global Classes Local Classes
Accessed from ? Any Program Only with in the Program where itis defined
Where store ? In the class repository Locally in the program where it isdefined
Tools required to create ? Class builder (SE24) With ABAP editor (SE38)
Namespace ? Must begin with ‘Y’ or ‘Z’ Any
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 14/37
IBM Global Services
© 2007 IBM Corporation14 Jan-2007Fundamentals of ABAP Objects
Declaring a Class: Local
Classes are template for Objects.
This example declares and defines a
local class “test ”.
The class DEFINITION belongs in
the global declarations section at the
beginning of the program. Class definition cannot be nested.
Classes cannot be defined inside
subroutines or function modules.
A class definition declares :
Its components :
Attributes, Methods, Events.
The visibility of its components :
Public, Protected and Private.
A class declaration has two parts.
Definition
Implementation
CLASS test DEFINITION.
PUBLIC SECTION.{ Attributes, Methods, Events }
PROTECTED SECTION.
{ Attributes, Methods, Events }
PRIVATE SECTION.
{ Attributes, Methods, Events }
ENDCLASS.
CLASS test IMPLEMENTATION.
<class body>
{Method implementation is done here}
ENDCLASS.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 15/37
IBM Global Services
© 2007 IBM Corporation15 Jan-2007Fundamentals of ABAP Objects
Components of Class ( Instance + Static )
Instance components: DATA
For instance attributes
METHODS
For instance methods
EVENTS For instance events
Static components:
CLASS-DATA
For static attributes
CLASS-METHODS For static methods
CLASS-EVENTS
For static events
CONSTANTS
For constants
Instance components exist separately in eachinstance (object) of the class.
Static components only exist one per class and
are valid for all instances of the class.
Static attributes of a class are retained
throughout the entire runtime. Static components are declared with the
CLASS- * keywords.
To access instance components, instance
component selector (->) is used.
To access static components, static componentselector (=>) is used.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 16/37
IBM Global Services
© 2007 IBM Corporation16 Jan-2007Fundamentals of ABAP Objects
Instance vs. Static components: Elaborated
The class components that share a common memory area for all the classinstance are static components.
The class components that have separate memory area for separate instance are
instance components.
Object 1 of Class Object 2 of Class Object 1 of Class Object 2 of Class
Memory for
Object 1
Memory for
Object 2
Memory for Object 1
and
Object 2
Instance Static
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 17/37
IBM Global Services
© 2007 IBM Corporation17 Jan-2007Fundamentals of ABAP Objects
Visibility sections in a Class
All components of a class must belong to a visibility section. Components canbe public, protected or private.
Public components form the external interface of the class – they are visible toall users of the class as well as to methods within the class and to methods of subclasses.
Protected components form the interface of the class to its subclasses they are
visible to methods of the heirs of the class as well as to methods within the class. Private components can only be used in the methods of the class itself. Using
private visibility section is known as Encapsulation or Information hiding.
Notes:
There is no default visibility section in a class.
You should not make attributes public unless absolutely necessary.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 18/37
IBM Global Services
© 2007 IBM Corporation18 Jan-2007Fundamentals of ABAP Objects
Attributes
Attributes contains data that can bestored in the objects of a class.
Attributes can be of 3 types:
elementary, structured or table-type.
In classes you can only use TYPE
addition to refer to data types and useLIKE reference only for local data
objects.
The READ ONLY addition can be
used for data declared in PUBLIC
SECTION, which means the data can
be read from outside, but can bechanged only by methods of the same
class.
CLASS c1 DEFINITION.PUBLIC SECTION.
METHODS: do_something…
PRIVATE SECTION.
TYPES: ……
CONSTANTS: ……DATA:
var1 TYPE local_type,
var2 TYPE global_type,
var3 LIKE var1,
var4 TYPE built_in_type VALUE val,var5 TYPE local_type READ-ONLY,
var6 TYPE REF TO class_name.
ENDCLASS.
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 19/37
IBM Global Services
© 2007 IBM Corporation19 Jan-2007Fundamentals of ABAP Objects
Methods
CLASS c1 DEFINITION.PUBLIC SECTION.
METHODS: do_something
IMPORTING ...i1 TYPE…
EXPORTING…e1 TYPE…
RETURNING VALUE (P)
.. R1 TYPE…CHANGING …c1 TYPE…
EXCEPTIONS …en.
PRIVATE SECTION.
DATA: …
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD do_something.
…
ENDMETHOD.
ENDCLASS.
Methods are the functionality of aclass , ABAP code is written within a
method to incorporate the
functionality.
Methods are processing blocks with a
parameter interface very similar to
function modules.
Methods are of two types:
Standard Methods.
e.g. METHODS meth.
Event handler methods:
METHODS meth FOR EVENT evt OF
class.This type of methods are written to
trap events.
Methods are called with a CALL
METHOD statement.
IBM Gl b l S i
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 20/37
IBM Global Services
© 2007 IBM Corporation20 Jan-2007Fundamentals of ABAP Objects
Methods (Contd.)
Methods have a signature. With function modules, you should type eachparameter but are not forced to do so; with methods, you must type each
parameter.
Standard methods are declared, with their parameter interface, in the class
definition part and implemented in the class implementation part.
All input parameters (IMPORTING & CHANGING) can have OPTIONAL or DEFAULT addition and then these parameters need not be transferred when the
method is called.
IBM Gl b l S i
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 21/37
IBM Global Services
© 2007 IBM Corporation21 Jan-2007Fundamentals of ABAP Objects
Constructors
METHODS constructor IMPORTING im_par TYPE string.
CREATE OBJECT obj
EXPORTING im_par = val_ex.
CLASS-METHOD class_constructor
Constructor is a special method that iscalled by the runtime system as soon as
the object is created with the CREATE
OBJECT statement.
Useful for:
Initializing data structures or setting
default values to attributes dynamically.
Sending message about object creation.
Each class has one constructor. It is a
predefined with the name
CONSTRUCTOR (or
CLASS_CONSTRUCTOR for static
constructor).
Constructors should be defined in the
public area.
Instanceconstructor
Static
Constructor
IBM Gl b l S i
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 22/37
IBM Global Services
© 2007 IBM Corporation22 Jan-2007Fundamentals of ABAP Objects
Constructors (Contd.)
Instance constructor can only have IMPORTING PARAMETERS &EXCEPTIONS. It has no EXPORTING parameters because its sole purpose is toinitializing the object.
The Static constructor method has no interface parameters.
The Static constructor is called automatically when the class is first accessed:
Creating an instance of the class (CREATE OBJECT)
Accessing a static attribute or Method of the class.
Registering an event handler method for an event in this class.
A static constructor can’t be called explicitly
When exception is raised in an instance constructor, instances are not created,
thus no memory space is occupied.
Notes:
There is no Destructor in ABAP Objects. I.e. there is no instance method
automatically called immediately before the object is deleted.
IBM Gl b l S i
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 23/37
IBM Global Services
© 2007 IBM Corporation23 Jan-2007Fundamentals of ABAP Objects
Some more features of Class
CLASS class_name DEFINITION DEFERRED. This is used in forward referencing.
CLASS class_name DEFINITION LOAD.
If the first access to a global class in a program is to its static components then explicit
loading of the class definition is necessary. In release 6.40 this statement is not
required. CLASS class_name DEFINITION CREATE PUBLIC| PROTECTED | PRIVATE.
‘CREATE PUBLIC’ addition is provided automatically by compiler if no create
addition is used.
The additions CREATE PROTECTED and CREATE PRIVATE allow you to
control the instantiation of your class.
IBM Global Ser ices
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 24/37
IBM Global Services
© 2007 IBM Corporation24 Jan-2007Fundamentals of ABAP Objects
CLASS c1 DEFINITION.PUBLIC SECTION.
DATA: int TYPE I VALUE ’10’.
METHODS display_int.
ENDCLASS.
CLASS c1 IMPLEMENTATION.METHOD display_int.
WRITE / int.
ENDMETHOD.
ENDCLASS.
DATA : oref TYPE REF TO c1.START-OF-SELECTION.
CREATE OBJECT oref.
WRITE / oref-> int.
CALL METHOD oref-> display_int.
Objects and Object references
Objects are real runtime replica of classes.
Objects can only be created and
addressed using reference variables.
To use objects:
Declare reference variables with typeof the class.
Create objects, assigning their
references. (This is called
Instantiation)
Use the object components.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 25/37
IBM Global Services
© 2007 IBM Corporation25 Jan-2007Fundamentals of ABAP Objects
Self- Reference
CLASS c1 DEFINITION.PUBLIC SECTION.
DATA: int TYPE I VALUE ’10’.
METHODS display_int.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD display_int.
DATA : int TYPE I VALUE ’20’.
WRITE:/ int,
ME->int.
ENDMETHOD.ENDCLASS.
DATA : oref TYPE REF TO c1.
CREATE OBJECT oref.
CALL METHOD oref-> display_int.
If an objects internally needs toprovide its own reference, it can use
the local reference variable “ME”.
“ME” is predefined and always
contains a reference to the address
of its own object.
Notes:
“ME” is equivalent to “THIS” pointer
in C++.
Local variable of the Method
Variable of the Class
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 26/37
IBM Global Services
© 2007 IBM Corporation26 Jan-2007Fundamentals of ABAP Objects
Multiple instantiation
CLASS c1 DEFINITION.PUBLIC SECTION.
METHODS meth.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
…ENDCLASS.
DATA: oref1 TYPE REF TO c1,
oref2 TYPE REF TO c1.
START-OF-SELECTION.CREATE OBJECT: oref1, oref2.
…
Programs can instantiate multipleobjects of the same class.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 27/37
IBM Global Services
© 2007 IBM Corporation27 Jan-2007Fundamentals of ABAP Objects
Deleting Objects
…
DATA: oref1 TYPE REF TO c1,
oref2 TYPE REF TO c2.
...
CREATE OBJECT: oref1, oref2.
…
oref1 = oref2.
CLEAR oref1.
CLEAR oref2.
oref2
oref1
9999oref2
oref1
8888Object of C2
Object of C1
8888oref2
oref1
8888
oref2
oref1
8888
9999
8888
Object of C2
Object of C19999
Object of C2
Object of C19999
8888
8888
Object of C2
Object of C19999
8888
oref1
oref2
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 28/37
IBM Global Services
© 2007 IBM Corporation28 Jan-2007Fundamentals of ABAP Objects
Calling Methods
CALL METHOD oref->methEXPORTING im_par1 = val_ex1…. im_par(n)= val_ex(n)…
IMPORTING ex_par = val_im…
CHANGING ch_par = val_chg…
RECEIVING ret_par = val_res...
EXCEPTIONS exception = val_rc…
Shorter Syntax available from SAP Web AS 6.10
oref->meth(
EXPORTING im_par1 = val_ex1…. im_par(n)= val_ex(n)…
IMPORTING ex_par = val_im…
CHANGING ch_par = val_chg…RECEIVING ret_par = val_res...
EXCEPTIONS exception = val_rc…)
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 29/37
IBM Global Services
© 2007 IBM Corporation29 Jan-2007Fundamentals of ABAP Objects
Functional Methods
METHODS methIMPORTING…
RETURNING VALUE (r)…
CALL METHOD oref->meth
EXPORTING i1 = a1….in = anRECEIVING r = a.
Example:
var = oref->meth().
or var = oref->meth(a).
or
var = oref->meth( i1 = a1….in = an).
Instead of CALL METHOD,functional methods can be
performed in expressions.
A Functional method can have
zero to many IMPORTING
parameters, EXCEPTIONS
and exactly one RETURNING
parameter, that must be
passed by value.
A Functional method can be
instance or static method.
Operands can be replaced byfunctional methods
Conventional
Method call
Method callspecific to
Functionalmethod
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 30/37
IBM Global Services
© 2007 IBM Corporation30 Jan-2007Fundamentals of ABAP Objects
Pointer tables
DATA: oref1 TYPE REF TO c1,oref2 TYPE REF TO c1,
oref3 TYPE REF TO c1.
DATA: oref TYPE REF TO c1,
oref_tab TYPE TABLE OF REF TO c1.
START-OF-SELECTION.
…
DO 3 TIMES.
CREATE OBJECT oref.
APPEND oref TO oref_tab.
ENDDO.
…
LOOP AT oref_tab INTO oref.
CALL METHOD oref->meth.
ENDLOOP.
Pointer tables are used to storemultiple instances/objects of
same class. This method
reduces coding and more
elegant against creating
separate, separate object
reference variables for storingevery objects of the same class.
Reference variables are
handled like any other data
object with an elementary data
type.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 31/37
IBM Global Services
© 2007 IBM Corporation31 Jan-2007Fundamentals of ABAP Objects
Dynamic Method calls
CLASS c1 DEFINITION.PUBLIC SECTION.
METHODS: meth1, meth2.
…
DATA fld TYPE …
DATA oref TYPE REF TO c1.…
CREATE OBJECT oref.
…
Do something to assign meth1
or meth2 to fld at runtime.
fld = ‘METH1’ or ‘METH2’.
CALL METHOD oref->(fld).
Instance, self-reference, and static methodcan all be called dynamically; the class
name for static methods can also be
determined dynamically:
Variants:
- oref->(method)- me->(method)
- class=>(method)
- (class)=>method
- (class)=>(method)
A method’s parameters can be passed
dynamically using PARAMETER-TABLE
and EXCEPTION-TABLE additions to the
CALL METHOD statement.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 32/37
IBM Global Services
© 2007 IBM Corporation32 Jan-2007Fundamentals of ABAP Objects
Demonstration
Creating a local class with different components in different visibility sections andshowing how to instantiate the class as well as how to access the instance and
static components.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 33/37
IBM Global Services
© 2007 IBM Corporation33 Jan-2007Fundamentals of ABAP Objects
Practice
Creating a local class with different components in different visibility sections andshowing how to instantiate the class as well as how to access the instance and
static components.
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 34/37
IBM Global Services
© 2007 IBM Corporation34 Jan-2007Fundamentals of ABAP Objects
Summary
Features of Object oriented programming are: Abstraction
Ecapsulation
Inheritance
Polymorphism
Code Reuse
Classes and Objects are the basic building blocks of Object Oriented
Programming When a real world entity is modeled into OOP world then it is known as Class,
characteristics as attributes and functionality as methods. Objects is an instance of a Class. Classes can be of two types:
Global Class (Created using class builder (SE24) and stored in class repository as
Class pool) Local Class (Created in any ABAP program)
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 35/37
© 2007 IBM Corporation35 Jan-2007Fundamentals of ABAP Objects
Questions
What kind of Programming language is ABAP ?
What version of SAP first released ABAP Objects ?
Can class definition be nested ?
Can you define a local class within a subroutine or function module ?
What is the default visibility section in a class ?
Can you call a constructor with the CALL METHOD statement ?
What Interface parameters does a Static Constructor have ?
When is CLASS class_name DEFINITION DEFERRED statement required ?
What parameters does a Functional method have ?
Which transaction we use to maintain global class? What are the various visibility sections present in a ABAP class?
What is the basic difference between static component and instance
component ?
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 36/37
© 2007 IBM Corporation36 Jan-2007Fundamentals of ABAP Objects
Questions
Can we access the static component of a class by the object name instead of theclass name?
What are the main advantages of Object Oriented Programming over Procedural
Programming ?
IBM Global Services
8/4/2019 Chapter 01_Fundamentals of ABAP Object
http://slidepdf.com/reader/full/chapter-01fundamentals-of-abap-object 37/37
Hands-on Exercises
Exercise 1:
Exercise 2: