Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Thursday, November 8,
2018
Classes Methods
Components of a Class • Syntax and Visibility
• Instance Methods and Static Methods
• Constructor
Inheritance
Super classes and Subclasses
Visibility
Inheritance and the (Instance) Constructor
Parameters
Redefining Methods in OOABAP
Compatibility
Principles of the Narrowing Cast
Static and Dynamic Components
Final Classes and Methods
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
Compound Interfaces
Course Contents
Events
Define and Trigger Events
Handle Events
Register and deregister Events
Receive a reference from Sender
Object – Oriented Concepts
• Encapsulation
• Inheritance
• Polymorphism
• Instantiation
• Interfacing
• Events
Advantages
• Simplicity
• Explicitness
• Maintainability
• Future Orientation
Classes
• 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.
Components in a class
Classes
• If you declare methods in the declaration part of a class, you must also write an
implementation part for it.
CLASS c1 IMPLEMENTATION.
….
ENDCLASS.
Attributes
Classes
Composing Interfaces
INTERFACE i1.
...
INTERFACES i2, i3, ...
...
...
ENDINTERFACE.
INTERFACE i2.
INTERFACES i1.
ENDINTERFACE.
INTERFACE i3.
INTERFACES i1, i2.
ENDINTERFACE.
INTERFACE i1.
METHODS meth.
ENDINTERFACE.
INTERFACE i4.
INTERFACES i2, i3.
ENDINTERFACE.
Problem?
Composing Interfaces – Implementation
No Problem! CLASS c1 DEFINITION.
PUBLIC SECTION.
INTERFACES i4.
Each interface is implemented ENDCLASS.
once.
CLASS c1 IMPLEMENTATION.
All interfaces are implemented METHOD i1~meth.
at the same level. ...
ENDMETHOD.
Each interface component is METHOD i2~meth.
unique. ...
ENDMETHOD.
METHOD i3~meth.
...
ENDMETHOD.
ENDCLASS.
Composing Interfaces – Aliases
INTERFACE i1.
METHODS m1. Inside: Access to deep components
ENDINTERFACE. of compound interfaces via aliases
INTERFACE i2. only.
INTERFACES i1. Outside: Narrowing cast.
ALIASES m2 FOR i1~m1.
ENDINTERFACE.
INTERFACE i3.
INTERFACES i2.
ALIASES m3 FOR i2~m2. FOR i2~i1~m1.
ENDINTERFACE.
• 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.
• 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>~”.
Polymorphism and Interface
Events
• Objects or Classes use events to trigger Event Handler methods in other objects or
classes.
• When an event is triggered any number of Event Handler Methods can be called.
• The events of a class can be raised in the same class using the RAISE EVENT Statement.
• Events have only output parameters which are accepted by the Event Handler
Methods as input parameters.
• The link between the trigger and the handler is established dynamically at runtime
using the statement SET HANDLER.
Events Overview
Triggering and handling Events : Overview
Defining and Triggering Events
Handling and Registering Events
Handling Events
Registering for an Event : Syntax
Deregistration
Registration/Deregistration : Handler Table
Event handling : Characteristics
Events and Visibility
Thank you for you attention
78