• No results found

OOPS-ABAP

N/A
N/A
Protected

Academic year: 2021

Share "OOPS-ABAP"

Copied!
69
0
0

Loading.... (view fulltext now)

Full text

(1)

Hyderabad February 24-26th 2009

Hyderabad February 24-26th 2009

Instructor: Subhas Katikala.

Instructor: Subhas Katikala.

Object Oriented ABAP

(2)

Workshop Goals

Workshop Goals

Th

Th

is works

is works

hh

op will enable you to:

op will enable you to:

 LLearn earn objeobject ±ct ± orieoriented cnted conceoncepts.pts.

 LLearn tearn thhe prie principnciple of ole of objecbject -t - orienorientedted

programming. programming.

 LLearn tearn thhe application of objecte application of object

(3)

Workshop Goals

Workshop Goals

Th

Th

is works

is works

hh

op will enable you to:

op will enable you to:

 LLearn earn objeobject ±ct ± orieoriented cnted conceoncepts.pts.

 LLearn tearn thhe prie principnciple of ole of objecbject -t - orienorientedted

programming. programming.

 LLearn tearn thhe application of objecte application of object

(4)

C

Course

ourse C

Contents

ontents

O

Objectbject OOriented Conceptsriented Concepts O

Objectbject OOriented Programming.riented Programming.

 Advantages of the

 Advantages of the OObject-bject-OOriented Approachriented Approach

M

Metethhodsods

 Syntax and VisibilitySyntax and Visibility

 Instance Methods and Static MethodsInstance Methods and Static Methods  Constructor Constructor 

Reference

Reference VariVariablesables

 Creating ReferencesCreating References  Assigning References Assigning References

Classes Classes Components of a Class Components of a Class Attributes Attributes

 Syntax and VisibilitySyntax and Visibility

(5)

Course Contents

Inheritance

 Super classes and Subclasses

 Visibility

 Inheritance and the (Instance) Constructor 

 Parameters

 Redefining Methods in OO ABAP

 Compatibility

 Principles of the Narrowing Cast

 Static and Dynamic Components

(6)

Course Contents

Polymorphism

 Advantages Compared to Procedural Programming

 Abstract Classes and Methods

 Component Namespaces in Classes

Interfaces

 Defining and Implementing an Interface

 Working with Interface Components

 Interface References

Narrowing Cast

Widening Cast

 Using Several Interfaces

 Polymorphism and Interfaces

 Polymorphism and Inheritance

(7)

Course Contents

Events

 Define and Trigger Events

 Handle Events

 Register and deregister Events

(8)

Object ² Oriented Concepts

Wh

at are Objects ?

¥ SAP AG 1999 What Are Objects? 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 world Model Data MMetethhodod Method Data MMetethhodod Method Data MMetethhodod Method Boat Data MMetethhodod Method

(9)

Object Oriented Programming

EncapsulationInheritancePolymorphismInstantiationInterfacingEvents

OOPS

(10)

Ad

v

antages

SimplicityExplicitnessMaintainability

(11)

Classes are the central element of object-orientation.

 A Class is an abstract description of an object.

Classes are templates for objects.

The attributes of objects are defined by the components of 

the class, which describe the state and behavior of objects.

(12)

 You define global classes and interfaces in the Class

Builder (Transaction SE24) in the ABAP Workbench.

They are stored centrally in class pools in the class library

in the R/3 Repository.

 All of the ABAP programs in an R/3 System can access the

global classes.

(13)
(14)

Defining

L

ocal Classes

 A complete class definition consists of a declaration part and, if required, an

implementation part.

The declaration part of a class <class> is a statement block: CLASS c1 DEFINITION.

«.

ENDCLASS.

If you declare methods in the declaration part of a class, you must also write an

implementation part for it.

CLASS c1 IMPLEMENTATION.

«.

ENDCLASS.

(15)
(16)

Defining

L

ocal Classes

(17)
(18)
(19)
(20)
(21)
(22)
(23)
(24)
(25)
(26)
(27)
(28)
(29)
(30)
(31)
(32)
(33)

Inheritance allows you to derive a new class from an existing class.  You do this using the INHERITING FROM addition in the

CLASS <subclass> DEFINITION INHERITING FROM <superclass>

statement.

The new class <subclass> inherits all of the components of the existing

class <superclass>.

The new class is called the subclass of the class from which it is

derived.

The original class is called the superclass of the new class.

(34)
(35)
(36)

Relationships between super classes and subclasses

Relationships between super classes and

(37)
(38)
(39)
(40)
(41)
(42)
(43)
(44)
(45)
(46)

W

idening t

h

e Cast

(47)
(48)
(49)
(50)
(51)

Interfaces exclusively describe the external point

of contact of a class, but they do not contain their 

own implementation part.

(52)
(53)
(54)
(55)

The assignment of an object reference to an interface

reference is known as a narrowing cast since, as with

inheritance, only a part of the object interface is visible once you have assigned the reference.

With an interface reference, you can no longer address all

components in the class carrying out the implementation, but only the components defined in the interface.

(56)
(57)

The widening cast is, as with inheritance, the opposite of the

narrowing cast: here it is used to retrieve an object reference from an interface reference. Obviously it cannot be statically

checked, since an interface can be implemented by more than one class.

 An object reference cannot be assigned to an interface

reference if it has itself not implemented the corresponding interface.

(58)

In the above example, one class is implementing several

interfaces.Even if these interfaces contain components with the

same name, they are differentiated in the class carrying out the

implementation by the prefix ³<interfacename>~´.

(59)

P

(60)

 OObjects or Classes use events to bjects or Classes use events to trigger Event Handler methods intrigger Event Handler methods in

other objects or classes.

other objects or classes.

When an event is triggered any When an event is triggered any number of Event Handler Methods cannumber of Event Handler Methods can

be called.

be called.

The events of a class can be raised in the The events of a class can be raised in the same class using thesame class using the RAISERAISE EVENT

EVENT Statement.Statement.

Events have only output parameters which are accepted by Events have only output parameters which are accepted by the Eventthe Event

Handler Methods as input parameters.

Handler Methods as input parameters.

The link between the trigger and the handler is established dynamicallyThe link between the trigger and the handler is established dynamically

at runtime using the statement

at runtime using the statement SET HANDLERSET HANDLER..

Events

Events

(61)

Events

(62)

Triggering and handling Events : Overview

(63)
(64)
(65)
(66)
(67)
(68)

Registration/Deregistration : Handler

(69)

References

Related documents

Partial Mode DISPOFF NORON Image Data DISPON (Optional) To prevent Tearing Effect Image displayed.. of lines from top of the Frame Memory and Display). The first line read from

Motivations based on compliance are not relevant when it comes to participation in online citizen science, however, extrinsic motivation based on ego involvement (e.g. a desire

In the Snowpeople world, we wrote program code where the snowman tried to get the attention of a snowwoman?. All the program code was written in this one method, see

As the administrator can use the event handler Counter Handler Module to record any arbitrary event under any condition, this task module can be used to graph any metrics

With the simulation study and various examples thereafter, we illustrated the following: (1) Effects confounded with block effects are not estimable, but do not bias the estimate of

For the income-poor population groups, progress was higher in relative terms and, in the case of sanitation, the increases are furthermore in line with the strong absolute

At this point, the Initiation Dispatcher combines the Handle from each registered Event Handler and uses the Synchronous Event Demultiplexer to wait for events to occur on

The Event Handler base class specifies a uniform interface consisting of virtual methods that handle (1) synchronous input, output, and exceptions and (2) timer- based