Introduction to ABAP Objects1
-
Upload
jyotsana-sharma -
Category
Documents
-
view
225 -
download
1
Transcript of Introduction to ABAP Objects1
-
8/22/2019 Introduction to ABAP Objects1
1/68
Copyright Siemens Business Services
Global network
of innovation
Date
ABAP OBJECTS
-
8/22/2019 Introduction to ABAP Objects1
2/68
Global network
of innovation Agenda
Day 1 Introduction to OOPS
OOPS Principles
ABAP Objects
Inheritance
Exercise Programs
Day 2
Event Handling
Global classes
Advanced Concepts
Exercise Programs
-
8/22/2019 Introduction to ABAP Objects1
3/68
Global network
of innovation
Procedural programming
Object-oriented programming
Aims of the ABAP Objects programming language
Contents:
Introduction
-
8/22/2019 Introduction to ABAP Objects1
4/68
Global network
of innovation
Machine language
Assembler
Java
C++
ABAP Objects
ABAP
History of Programming Languages
-
8/22/2019 Introduction to ABAP Objects1
5/68
Global network
of innovation
Object-Oriented ProgrammingObject-Oriented Programming
Procedural ProgrammingProcedural Programming
Introduction : Overview
-
8/22/2019 Introduction to ABAP Objects1
6/68
Global network
of innovation
DataData DataData
DataData DataData
DataData Functions are defined independently
of data structures
Direct access to data
FunctionFunction
FunctionFunctionFunctionFunctionFunctionFunction
FunctionFunctionFunctionFunctionFunctionFunctionFunctionFunction
Procedural Programming
-
8/22/2019 Introduction to ABAP Objects1
7/68
Global network
of innovation
TYPES: ...
DATA: ...
...
PERFORM f1 ...
CALL FUNCTION ...
...
FORM f1 ...
...
ENDFORM.
Data declaration
Main program
Call subroutines
Call function modules
Define subroutines
Structure of ABAP Program
-
8/22/2019 Introduction to ABAP Objects1
8/68
Global network
of innovation
...
CALL FUNCTION A2 ...
...
CALL FUNCTION B1 ...
...
ABAP Program Function groups
Function group A
Function module A1
Function module A2
Function module A3
Data
Function group B
Function module B1
Function module B2Data
Working with Function Groups
-
8/22/2019 Introduction to ABAP Objects1
9/68
Global network
of innovation
FUNCTION-POOL counter.
DATA: count TYPE I.
FUNCTION SET_COUNTER.
* Local interface IMPORTING VALUE(set_value)
count = set_value
ENDFUNCTION.
FUNCTION INCREMENT_COUNTER.
ADD 1 TO count.
ENDFUNCTION.
FUNCTION GET_COUNTER.
* Local interface EXPORTING VALUE(get_value)
get_value = count.
ENDFUNCTION.
Function Group as Counter : Example
-
8/22/2019 Introduction to ABAP Objects1
10/68
Global network
of innovation
DATA: number TYPE I VALUE 3.
CALL FUNCTION SET_COUNTER EXPORTING set_value = number.
DO 4 TIMES.CALL FUNCTION INCREMENT_COUNTER.
ENDDO.
CALL FUNCTION GET_COUNTER IMPORTING get_value = number.
RITE: ..., number, ...
Function Group as Counter : Example
-
8/22/2019 Introduction to ABAP Objects1
11/68
Global network
of innovation
Function group COUNTER
SET_COUNTER
INCREMENT_COUNTER
GET_COUNTER
COUNTER
1 counter Any number of counters
Several Instances of Function Group?
-
8/22/2019 Introduction to ABAP Objects1
12/68
Global network
of innovation
Procedural ProgrammingProcedural Programming
Object-Oriented ProgrammingObject-Oriented Programming
Introduction : Overview
-
8/22/2019 Introduction to ABAP Objects1
13/68
Copyright Siemens Business Services
Global network
of innovation
Date
Why OOPs
-
8/22/2019 Introduction to ABAP Objects1
14/68
Global network
of innovation
Quality
of asoftware product
Correctness Robustness
Extensibility Re-usability
Overall Aims of Software Development
D t
-
8/22/2019 Introduction to ABAP Objects1
15/68
Copyright Siemens Business Services
Global network
of innovation
Date
OBJECTS
-
8/22/2019 Introduction to ABAP Objects1
16/68
Global network
of innovation
Tree
House
Crane
Objects are an abstraction of the real world
Objects are units made up of data and of the
functions belonging to that data
Real worldModel
DataMethodMethod
Method
DataMethodMethod
MethodData
MethodMethod
Method
Boat
DataMethodMethod
Method
What are Objects?
-
8/22/2019 Introduction to ABAP Objects1
17/68
Global network
of innovation Object-Oriented Programming Model
Classes
Classes describe objects. From a technical point of view, objects are
runtime instances of a class.
In other words Class is nothing but a template which carries DATA
and METHODS to access the DATA
Objects
Objects are instances of classes. They contain data and provides
services. The data forms the attributes of the object. The services
are known as methods (also known as operations or functions)
-
8/22/2019 Introduction to ABAP Objects1
18/68
Global network
of innovation
Extensibility
Re-usability
The following aims are better supported:
Extensibility through
Polymorphism
Inheritance
Re-usability through
Classes Encapsulation
Inheritance
Strengths of Object-Oriented Approach
-
8/22/2019 Introduction to ABAP Objects1
19/68
Global network
of innovation
Uniform language throughout thedevelopment process
All participants
In all phases
Reality is reflected in appropriate software concepts
Objects -> objects
Their state -> attributes
Their functions -> methods
Strengths of Object-Oriented Approach
-
8/22/2019 Introduction to ABAP Objects1
20/68
Global network
of innovation
Longer development phase before first results ready
Paradigm break between object-oriented programs andProcedural Programming
Weaknesses of Object-Oriented Approach
-
8/22/2019 Introduction to ABAP Objects1
21/68
Global network
of innovation
BOR
ABAP Objects
Class library
OO application OO application
Outlook
-
8/22/2019 Introduction to ABAP Objects1
22/68
Global network
of innovation
As simple as possible
Only object-oriented concepts, that have provedthemselves in other object-oriented programminglanguages
More frequent use of type checks
ABAP Objects : Design Aims
-
8/22/2019 Introduction to ABAP Objects1
23/68
Global network
of innovation
* ABAP Program
CLASS lcl airplane DEFINITION.
...
ENDCLASS.
...
TYPES: ...
DATA: ...
...
* ABAP Objects Program
DATA: counter TYPE i.
...
CREATE OBJECT ...
counter = counter + 1.
...
True, compatible extension of ABAP
ABAP Objects statements can be used in conventional
ABAP programs
ABAP statements can be used in ABAP Objects programs
ABAP Objects
Date
-
8/22/2019 Introduction to ABAP Objects1
24/68
Copyright Siemens Business Services
Global network
of innovation
Questions ?
-
8/22/2019 Introduction to ABAP Objects1
25/68
Global network
of innovation OOPS Principles
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
-
8/22/2019 Introduction to ABAP Objects1
26/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-1
-
8/22/2019 Introduction to ABAP Objects1
27/68
Global network
of innovation
Private accessEncapsulation
As a rule, attributes
Attributes
Events
Attributes
Methods
Events
Plane ID: ID0057231
Length: 70 m
Weight: 30,000 kg
landed
Methods
flyland
Example: airplane
Public accessInterfaceAs a rule,methods, events
Name: LH Berlin
Object-1
-
8/22/2019 Introduction to ABAP Objects1
28/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-2
-
8/22/2019 Introduction to ABAP Objects1
29/68
Global network
of innovation
CLASS DEFINITION.
ENDCLASS.
CLASS IMPLEMENTATION.
ENDCLASS.
Definition part
The class components (for
example, attributes and methods)
are defined in this part.
Definition partThe class components (for
example, attributes and methods)
are defined in this part.
Implementation part
This part only contains the method
implementations.
Implementation part
This part only contains the methodimplementations.
Class : Blueprint of Object
-
8/22/2019 Introduction to ABAP Objects1
30/68
Global network
of innovation Important Components in a Class
1. Attributes or Data
Determine the state of the object
2. Methods
Determine the Behavior of the Object
Used to access the Attribute
3. Events
Determines the Actions you can perform
-
8/22/2019 Introduction to ABAP Objects1
31/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-3
-
8/22/2019 Introduction to ABAP Objects1
32/68
Global network
of innovation
lcl_airplane
name: LHweight: 30 000tank:
lcl_tank
Attribute types can have any kind of data type:
Elementary types:
C, I, P, STRING
TYPE REF TO (References to objects/interfaces)
Define your own types
Attributes
-
8/22/2019 Introduction to ABAP Objects1
33/68
Global network
of innovation
CLASS DEFINITION.
...
TYPES: .
CONSTANTS: constant TYPE VALUE .
DATA: variable1 TYPE ,
variable2 TYPE,variable3 LIKE variable1,variable4 TYPE VALUE,
variable5 TYPE READ-ONLY,variable6 TYPE REF TO,variable7 TYPE REF TO .
CLASS-DATA: ...
ENDCLASS.
CLASS DEFINITION....
TYPES: .CONSTANTS: constant TYPE VALUE .
DATA: variable1 TYPE ,variable2 TYPE,
variable3 LIKE variable1,variable4 TYPE VALUE,
variable5 TYPE READ-ONLY,
variable6 TYPE REF TO,variable7 TYPE REF TO .
CLASS-DATA: ...
ENDCLASS.
Attributes : Syntax
-
8/22/2019 Introduction to ABAP Objects1
34/68
Global network
of innovation
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
...
PRIVATE SECTION.
DATA: weight TYPE saplane-weight,
name TYPE string.
ENDCLASS.
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
...
PRIVATE SECTION.
DATA: weight TYPE saplane-weight,
name TYPE string.
ENDCLASS.
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
DATA: name TYPE string.
PRIVATE SECTION.
DATA: weight TYPE saplane-weight.
ENDCLASS.
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
DATA: name TYPE string.
PRIVATE SECTION.
DATA: weight TYPE saplane-weight.
ENDCLASS.
better
Public attributes
Can be viewed andchanged by all users andin all methods
Direct access
Private attributes
Can only be viewed andchanged from within theclass
No direct access
from outside the class
Attributes : Visibility
-
8/22/2019 Introduction to ABAP Objects1
35/68
Global network
of innovation
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
PRIVATE SECTION.
DATA: weight TYPE saplane-weight,
name TYPE string.
CLASS-DATA: count TYPE I.
ENDCLASS.
Instance attributes
One per instance
Statement: DATA
Static attributes
Only one per class Statement: CLASS-DATA
Also known as class attributes
Attributes : Instance and Static-1
-
8/22/2019 Introduction to ABAP Objects1
36/68
Global network
of innovation
Main
name: LH Berlin
weight: 30,000 kg
name: AA Boston
weight: 45,000 kg
count:
Static attributes for class LCL_AIRPLANE
Attributes : Instance and Static-2
-
8/22/2019 Introduction to ABAP Objects1
37/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-4
-
8/22/2019 Introduction to ABAP Objects1
38/68
Global network
of innovation
lcl_airplane
...
flyland
Contain coding
Have an interface
Methods
-
8/22/2019 Introduction to ABAP Objects1
39/68
Global network
of innovation
CLASS IMPLEMENTATION.
ETHOD.
...
ENDMETHOD.
ENDCLASS.
CLASS DEFINITION.
...ETHODS:
[ IMPORTING TYPE EXPORTING TYPE
CHANGING TYPE RETURNING VALUE() TYPE EXCEPTIONS ].
ENDCLASS.
Methods : Syntax
-
8/22/2019 Introduction to ABAP Objects1
40/68
Global network
of innovation
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.ETHODS: set_name importing
im name TYPE string.
PRIVATE SECTION.
ETHODS: init name.
DATA: name TYPE string.
ENDCLASS.
CLASS lcl airplane IMPLEMENTATION.
ETHOD init name.
name = No Name.
ENDMETHOD.
ETHOD set_name.
IF im name IS INITIAL.
* Calling init name
...
ELSE. name = im name. ENDIF.
ENDMETHOD.ENDCLASS.
Public methods
Can be called fromoutside the class
Private methods
Can only be calledwithin the class
Methods : Visibility
-
8/22/2019 Introduction to ABAP Objects1
41/68
Global network
of innovation
Instance methods
Can use both static and instance components in the implementation part
Can be called using the instance name
Static methods
Can only use static components in the implementation part
Can be called using the class name
Methods : Instance and Static
-
8/22/2019 Introduction to ABAP Objects1
42/68
Global network
of innovation
CLASS lcl airplane DEFINITION.
PUBLIC SECTION.
ETHODS: set_name IMPORTING im name TYPE string.
CLASS-METHODS: get_count RETURNING VALUE(re_count) TYPE I.
PRIVATE SECTION.
DATA: name TYPE string.
CLASS-DATA: count TYPE I.
ENDCLASS.
CLASS lcl airplane IMPLEMENTATION.
...
METHOD get_count.
re_count = count.
ENDMETHOD
ENDCLASS.
Methods Instance and Static : Example
Gl b l t k
-
8/22/2019 Introduction to ABAP Objects1
43/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-5
Gl b l t k
-
8/22/2019 Introduction to ABAP Objects1
44/68
Global network
of innovation
lcl_airplane
name
weight
... CREATE OBJECT
name: LH Berlinweight: 30,000 kg
Objects can only be created and addressed usingreference variables
Creating Objects
Global network
-
8/22/2019 Introduction to ABAP Objects1
45/68
Global network
of innovation
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
...
PRIVATE SECTION.
...
ENDCLASS.
CLASS lcl_airplane IMPLEMENTATION.
...
ENDCLASS.
DATA: airplane1 TYPE REF TO cl_airplane,
airplane2 TYPE REF TO cl_airplane.
Main memory
airplane2
airplane1
Reference Variables
Global networkC ti Obj t S t
-
8/22/2019 Introduction to ABAP Objects1
46/68
Global network
of innovation
DATA: airplane1 TYPE REF TO lcl_airplane,
airplane2 TYPE REF TO lcl_airplane.
CREATE OBJECT airplane1.
CREATE OBJECT airplane2.
CREATE OBJECT .
Main memory
airplane1
airplane2
name:
weight: 0
name:weight: 0
Creating Objects : Syntax
Global networkA i i R f
-
8/22/2019 Introduction to ABAP Objects1
47/68
Global network
of innovation
...DATA: airplane1 TYPE REF TO lcl airplane,
airplane2 TYPE REF TO lcl airplane.
CREATE OBJECT airplane1.CREATE OBJECT airplane2.
airplane1 = airplane2.
Main memory
airplane1
airplane2
name:weight: 0
name:weight: 0
Assigning References
Global networkG b C ll t
-
8/22/2019 Introduction to ABAP Objects1
48/68
Global network
of innovation
...
DATA: airplane1 TYPE REF TO lcl_airplane,
airplane2 TYPE REF TO lcl_airplane.
CREATE OBJECT airplane1 EXPORTING ... .
CREATE OBJECT airplane2 EXPORTING ... .
airplane1 = airplane2.
Main memory
airplane1
airplane2
name: LH B
weight: 30,000 kg
name: AA Bost
weight: 45,000 kg
Garbage Collector
Global networkP i i l O i 6
-
8/22/2019 Introduction to ABAP Objects1
49/68
Global network
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
Principles : Overview-6
Global networkReferences : Comparison
-
8/22/2019 Introduction to ABAP Objects1
50/68
Global network
of innovation
DATA: airplane1 TYPE REF TO lcl airplane,
airplane2 TYPE REF TO lcl airplane.
CREATE OBJECT airplane1 EXPORTING im name = LH Berlin ...
CREATE OBJECT airplane2 EXPORTING im name = LH Berlin ...
IF airplane1 = airplane2. not equal to
...
ENDIF.
Main memory
airplane1
airplane2
n: LH Berlin
w: 30,000 kg
n: LH Berlin
w: 30,000 kg
References : Comparison
Global networkBuffering References 1
-
8/22/2019 Introduction to ABAP Objects1
51/68
of innovation
DATA: airplane TYPE REF TO cl_airplane,
airplane_table TYPE TABLE OF REF TO cl_airplane.
CREATE OBJECT airplane.
APPEND airplane TO airplane_table.
CREATE OBJECT airplane.
APPEND airplane TO airplane_table.
Main memory
airplane_table
airplane
Main memory
airplane_table
airplane
Buffering References -1
Global networkBuffering References 2
-
8/22/2019 Introduction to ABAP Objects1
52/68
of innovation
LOOP AT TO airplane_table INTO airplane.
* work with the current instance
ENDLOOP.
Main memory
airplane_table
airplane1
2
Buffering References -2
Global networkObject Reference as Attributes
-
8/22/2019 Introduction to ABAP Objects1
53/68
of innovation
lcl_airplane lcl_wings
orientat
name: LH Berlin
weight: 30,000 kg
left_wing:
right_wing:
orientat .: rightlength: 15 m
.: left
length: 15 m
Object Reference as Attributes
Global networkExternal Access to Public Attributes
-
8/22/2019 Introduction to ABAP Objects1
54/68
of innovation
Instance attribute:
->
Class attribute:
=>
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
DATA: name TYPE string READ-ONLY.
CLASS-DATA: count TYPE I READ-ONLY.
...
ENDCLASS.
...
DATA: airplane1 TYPE REF TO lcl_airplane.
DATA: airplane_name TYPE STRING,
n_o_airplanes TYPE i.
...
airplane_name = airplane1->name.
n_o_airplanes = lcl_airplane=>count.
name: LH Berlin
External Access to Public Attributes
Global network
f i i Calling Methods
-
8/22/2019 Introduction to ABAP Objects1
55/68
of innovation
O2
DataDo_itData Run
O1
call method O2->Do_it
Calling Methods
Global network
f i ti Calling Methods : Syntax
-
8/22/2019 Introduction to ABAP Objects1
56/68
of innovation
Instance methods: CALL METHOD->
EXPORTING =
IMPORTING =
CHANGING =
RECEIVING =
EXCEPTIONS = .
Static methods: CALL METHOD=>
EXPORTING ... .
DATA: airplane TYPE REF TO lcl_airplane.
DATA: name TYPE string.
DATA: count_planes TYPE I.
CREATE OBJECT airplane.
CALL METHOD airplane->set_name EXPORTING im_name = name.
CALL METHOD lcl_airplane=>get_count RECEIVING re_count = count_planes.
Calling Methods : Syntax
Global network
of inno ation
Constructor
-
8/22/2019 Introduction to ABAP Objects1
57/68
of innovation
CREATE OBJECT
lcl_airplane
name
weight
count
constructor
ETHODS CONSTRUCTOR IMPORTINGEXCEPTIONS.ETHODS CONSTRUCTOR IMPORTINGEXCEPTIONS.
name: LH Berlin
weight: 30,000 kg
Special method for creatingobjects with defined initialstate
Only has IMPORTING
parameters andEXCEPTIONS
Exactly one constructor isdefined per class (explicitlyor implicitly)
Is executed exactly once perinstance
Constructor
Global network
of innovation
Constructor : Example
-
8/22/2019 Introduction to ABAP Objects1
58/68
of innovation
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
METHODS CONSTRUCTOR IMPORTING im_name TYPE stringim_weight TYPE I.
PRIVATE SECTION.
DATA: name TYPE string, weight TYPE I.
CLASS-DATA count TYPE I.
ENDCLASS.
CLASS lcl_airplane IMPLEMENTATION.
METHOD CONSTRUCTOR.
name = im_name.weight = im_weight.
count = count + 1.
ENDMETHOD.
ENDCLASS.
DATA airplane TYPE REF TO lcl_airplane.
...
CREATE OBJECT airplaneEXPORTING im_name = `LH Berlin`
im_weight = 30000.
name: LH Berlin
weight: 30,000 kg
Constructor : Example
Global network
of innovation
Static Constructor
-
8/22/2019 Introduction to ABAP Objects1
59/68
of innovation
CLASSlcl airplane DEFINITION.PUBLIC SECTION.CLASS-METHODS:CLASS_CONSTRUCTOR,get_count RETURNING
VALUE(re_count) TYPE I.CLASS-DATA: count TYPE I.
ENDCLASS.
CLASSlcl airplane IMPLEMENTATION.METHOD CLASS_CONSTRUCTOR.
...ENDMETHOD....
ENDCLASS.
CLASS DEFINITION.PUBLIC SECTION.CLASS-METHODSCLASS_CONSTRUCTOR.
ENDCLASS.
CLASS IMPLEMENTATION.ETHODCLASS_CONSTRUCTOR....
ENDMETHOD.ENDCLASS.
CLASS DEFINITION.PUBLIC SECTION.CLASS-METHODSCLASS_CONSTRUCTOR.
ENDCLASS.
CLASS IMPLEMENTATION.ETHODCLASS_CONSTRUCTOR....
ENDMETHOD.ENDCLASS.
Static Constructor
Global network
of innovation Call To Static Constructor
-
8/22/2019 Introduction to ABAP Objects1
60/68
of innovation
* Example 1:
DATA airplane TYPE REF TOcl airplane.
CREATE OBJECT airplane.
* Example 2:
DATA class_id TYPE string.
class_id =lcl airplane=>count.
* Example 3:
DATA count_airplane TYPE I.
CALL METHODlcl airplane=>get_count
RECEIVING re_count = count_airplane.
Special static method
Automatically called
before the class is first
accessed
Only executed once per
program
Call To Static Constructor
Global network
of innovation Principles Overview -7
-
8/22/2019 Introduction to ABAP Objects1
61/68
of innovation
ObjectsObjects
ClassesClasses
AttributesAttributes
MethodsMethods
Instantiation, Garbage CollectorInstantiation, Garbage Collector
Working with ObjectsWorking with Objects
Further PrinciplesFurther Principles
p
Global network
of innovation Encapsulation
-
8/22/2019 Introduction to ABAP Objects1
62/68
of innovation
Class as capsule for functions
Defined responsibilities within a capsule (class)
Defined interfaces using
Public components of class (PUBLIC SECTION)
Interfaces
Implementation of component remains hidden through
limited visibility (PRIVATE SECTION)
p
Global network
of innovation Client Server Behavior
-
8/22/2019 Introduction to ABAP Objects1
63/68
Server
DataDo_itDataRun
Client
CALL METHOD server->Do_it
Classes behave toward each other as client/serversystems.
Classes normally play both roles.
Responsibilities between the classes must be established.
Global network
of innovation The Delegation Principle
-
8/22/2019 Introduction to ABAP Objects1
64/68
lcl _tank
fuel : i
fuel_max : i
get_fuel_level () : re_level
lcl _client
lcl _airplane
tank : lcl _tank
get_fuel_level () : re_level
re_level = fuel / fuel_max * 100.re_level = tank->get_fuel_level ( ).
g p
Global network
of innovation
Delegation : Sequence Diagram
-
8/22/2019 Introduction to ABAP Objects1
65/68
pilot : lcl _client airbus : lcl _airplane tank : lcl _tank
1: get_fuel_level ( )
2: get_fuel_level ( )
re_level
re_level
Global network
of innovation Namespaces within a Class
-
8/22/2019 Introduction to ABAP Objects1
66/68
The same namespace for
Attribute names
Method names
Event names
Type names
Constant names
ALIAS names
There is a local namespace within methods
Global network
of innovation Namespace : Example
-
8/22/2019 Introduction to ABAP Objects1
67/68
CLASS lcl airplane DEFINITION.PUBLIC SECTION.METHODS CONSTRUCTOR
IMPORTING im name TYPE stringimweight TYPE I.
PRIVATE SECTION.DATA name TYPE string.DATA weight TYPE I.
ENDCLASS.CLASS cl airplane IMPLEMENTATION.METHOD CONSTRUCTOR.
DATA name TYPE string VALUE `-airplane`.CONCATENATE im name name INTO E->name.
weight = imweight.ENDMETHOD.
ENDCLASS.
Global network
of innovation
Date
-
8/22/2019 Introduction to ABAP Objects1
68/68
Copyright Siemens Business Services
Questions ?