17
© Copyright IBM Corporation 2007 IBM Global Business Services © IBM Corporation 2013 IBM Global Business Services Defining and Registering Events in Object Oriented ABAP

05 ABAP Objects - Events Handling

Embed Size (px)

DESCRIPTION

05 ABAP Objects - Events Handling

Citation preview

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013

IBM Global Business Services

Defining and Registering Events in Object Oriented ABAP

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 2

Agenda

Define and trigger events

Register and handle events

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 3

Unit Objectives

Define and trigger events

Handle events

Register and deregister events

Receive a reference from the sender

Explain the conceptual differences between methods and events

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 4

Overview

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 5

Characteristics and Uses

Looser linkage than for a method call

Different communication model

Trigger does not know the user

Important for GUI implementation

Conformity to other object models COM

ActiveX Controls

OpenDoc

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 6

Triggering and Handling Events: Overview

Triggering events Class defines event (EVENTS, CLASS-EVENTS)

Object or class triggers event (RAISE EVENT)

Handling events Event handler class defines and implements event handler method

([CLASS-]METHODS... FOR EVENT ... OF ...)

Event handler object” or handler class registers itself to specific object/class events at runtime (SET HANDLER)

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 7

Defining and Triggering Events: Syntax

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 8

Handling and Registering Events

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 9

Handling Events: Syntax

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 10

Registering for an Event: Syntax

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 11

Deregistration and the Implicit Reference SENDER

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 12

Registration/Deregistration: Handler Table

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 13

Defining View Layout

Event handling is sequential.

Sequence in which event handler methods are called is not defined.

As far as the Garbage Collector is concerned, registration has the same effect as a reference to the object registered.

Registered objects are never deleted.

Immediate effects of SET HANDLER on event handler

methods:

Newly registered event handlers are also executed.

Deregistered handlers may already have been executed.

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 14

Events and Visibility

The visibility of an event establishes authorization for event handling.

The visibility in an event handler method establishes authorization for SET-HANDLER statements.

An event handler method must have either the same or more restricted visibility than the event it refers to :

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 15

Events: Unit summary

You are now able to: Define and trigger events

Handle events

Register and deregister events

Explain the conceptual differences between

methods and events

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 16

Hands-on Exercise 8

Objectives: Define and trigger events

Handle events

Register for events

IBM Global Business Services

© Copyright IBM Corporation 2007

IBM Global Business Services

© IBM Corporation 2013Developing User Interfaces with Web Dynpro for ABAP | Jan-2011 17

Thank You

Questions?