Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

events

Former Member
0 Likes
640

hi frds plz give me response

How to declare & register events?

to my mail id sudhakarbabu786@rediffmail.com

4 REPLIES 4
Read only

Former Member
0 Likes
568

Hi

Events enable objects or classes to trigger Event Handler Methods in other objects or Classes

Events are of two types : Instance and Static

Instance Events

Declared using the statement EVENTS.

Instance events can only be triggered in Instance Methods.

Static Events

Declared using statement CLASS-EVENTS

Static events can be triggered both by Instance Methods and Static Methods

Events can be triggered from the Objects/Class of the same class where the events have been defined.

Event handler methods can be defined in the same class or other classes.

The EVENTS statement has addition EXPORTING parameter to pass attributes if required

The following statements are used to declare event e1 in class c1. Event e1 exports integer variable var. Here object o1 is created of class type c1. Event handler method handle_e1 has been declared. Also, when raising e1 the integer temp_var is exported.

EVENTS e1 EXPORTING value(var) TYPE i.

The syntax for declaration of Event Handler Methods is as follows :

METHODS handle_e1 FOR EVENT e1 OF c1

IMPORTING var.

Set the Event Handler methods, before triggering the events, using the following statement

SET HANDLER o1->handle_e1 FOR ALL INSTANCES.

To trigger the event, use the statement RAISE EVENT.

RAISE EVENT e1 EXPORTING var = temp_var.

SET HANDLER

Registers and deregisters Event Handler Methods dynamically at Runtime

This statement can be used in three ways

SET HANDLER h1 ….hn FOR ref

This form is used for instance events and registers the Event Handler Methods for only one instance (i.e one object )

ref stands for Class Reference Variable or Interface Reference Variable

SET HANDLER h1…..hn FOR ALL INSTANCES

This form is used for instance events and registers the Event Handler Methods for all Instances

ref stands for Class Reference Variable or Interface Reference Variable

SET HANDLER h1…..hn.

This form is used for static events.

In case of Class Reference : It registers Event Handler Methods for triggering from class where the event has been declared.

In case of Interface Reference : It registers the event handler methods for all triggering classes that implement the interface intf.

RAISE EVENT

It triggers the Event Handler Methods that have been registered for that event with the SET HANDLER statement

The event must be the component of the class from where it is triggered

After the RAISE EVENT statement, all of the registered handler methods

are executed before the next statement is processed (Synchronous Event Handling)

Event handler methods can in turn trigger events

It is currently only possible to nest RAISE EVENT statements to a depth of 64 calls.

Read only

Former Member
0 Likes
568

EVENTS

ABAP program

INITIALIZATION.

pa_date = pa_date - 7.

START-OF-SELECTION.

WRITE pa_date.

The easiest events to understand are those for an executable program (type 1).

The ABAP runtime system calls event blocks in a sequence designed for generating and processing

lists:

First, the INITIALIZATION event block is called

Then a selection screen is sent to the presentation server

After the user leaves the selection screen, START-OF-SELECTION is called

If the START-OF-SELECTION event block contains the ABAP statements WRITE, SKIP or ULINE,

a list buffer is filled.

Event Blocks in Executable Programs

INITIALIZATION.

START-OF-SELECTION.

Default event block:

START-OF-SELECTION

Event blocks are processing blocks that are called by the ABAP runtime system. The sequence if which

they are processed is determined by the runtime system.

In executable programs, there are different event blocks for the various tasks involved in creating lists.

Syntax: Event Blocks

REPORT ...

PARAMETERS: pa_date LIKE sy-datum DEFAULT sy-datum.

INITIALIZATION. " Default values for selection screen

pa_date = pa_date - 7.

START-OF-SELECTION.

" Start of data processing

WRITE pa_date.

The sequence of event blocks in the

source code has no effect on the sequence in

which they are called by the ABAP runtime system.

call

initialization

STARTOFSELECTION..

In an ABAP program, an event block is introduced with an event key word. It ends when the next

processing block starts. There is no ABAP statement that explicitly concludes an event block.

Event blocks are called by the ABAP runtime system. The order in which you arrange the event blocks in

your program is irrelevant - the system always calls them in a particular order.

START-OF-SELECTION is the first event for processing data and generating a list. It is called by the

ABAP runtime system as soon as you have left the standard selection screen.

INITIALIZATION is an event that you can use if you need to set a large number of default values. This

event block allows you to set default values that can only be determined at runtime. In the above

example, the date 'A week ago' is calculated and placed in data object pa_date. The ABAP runtime

system then sends a selection screen to the presentation server containing the calculated value as a

default. The value can, of course, still be changed.

Selection screen processing is event-driven. Events are ABAP processing blocks that are called by the

runtime system in a particular order and processed sequentially. In the program, each event is

introduced by an event keyword. The processing block ends when the next event block starts, or the

definition of a subroutine or dialog module occurs.

AT SELECTION-SCREEN OUTPUT is processed before the selection screen is displayed on the

screen. You can use this event to modify the selection screen dynamically.

AT SELECTION-SCREEN ON HELP-REQUEST FOR <sel_field> and

AT SELECTION-SCREEN ON VALUE-REQUEST FOR <sel_field> allow you to define your own F1

and F4 help.

AT SELECTION-SCREEN is processed when the user presses ENTER or chooses another function on

the selection screen.

-


An ABAP program consists of a sequence of processing blocks (events) that are processed by the

runtime system in a particular order.

LOAD-OF-PROGRAM is triggered directly after the system has loaded a program with type 1, M, F, or S

into an internal session. The processing block is executed once only for each program in each internal

session.

INITIALIZATION is processed in executable (type 1) programs, directly before the selection screen is

displayed. You can use the corresponding processing block to pre-assign values to the parameters and

selection options on the selection screen.

START-OF-SELECTION is processed after the selection screen has been processed. If you are

working with a logical database, the corresponding GET events are triggered after START-OFSELECTION.

END-OF-SELECTION is processed after all of the data has been read, and before the list is displayed.

TOP-OF-PAGE is an event in list processing. The associated processing block is always executed when

you start a new page in the list.

-


module pool

GET GET ...

You can only assign a report transaction to an executable (type 1) program. In a report transaction,

the system calls particular events in a fixed sequence, and calls a series of standard screens. The

following steps occur when you run a report transaction:

First, the LOAD-OF-PROGRAM event is triggered.

Then the INITIALIZATION event is triggered.

Next, the standard selection screen is called (if you have declared one), and its corresponding events

are triggered: AT SELECTION-SCREEN OUTPUT and AT SELECTION-SCREEN.

Next, the START-OF-SELECTION event is triggered. (This is the default event block. If you omit this

event keyword, all statements that are not assigned to another processing block are treated as though

they belong to it.)

If you have attached a logical database to your program, the system triggers the GET <node> and GET

<node> LATE events.

Then the END-OF-SELECTION event is triggered.

You can also include screen processing (as in module pools) by using the CALL SCREEN statement.

You can start executable (type 1) programs without using a transaction code. You can also run them in

the background.

(C) SAP AG BC402 2-11

SAP AG 1999

WRITE ...

SKIP ...

ULINE.

List Processing Events

TOP TOP-OF-PAGE.

EOP END-OF-PAGE.

AT LINE-SELECTION.

WRITE ...

SKIP ...

ULINE.

ALS

List buffer for basic list

AUC AT USER-COMMAND.

List buffer for detail list

If you fill the list buffer of the basic list (using the WRITE, SKIP, and ULINE statements), two further

events are triggered: At the beginning of each new page, the TOP-OF-PAGE event is triggered, and the

END-OF-PAGE event is triggered at the end of each page.

Once the END-OF-SELECTION event block has been processed, interactive list processing starts.

The system displays the formatted basic list . The user can now trigger further events.

If the user double-clicks a line or triggers the function code PICK in some other way, the AT LINESELECTION

event is triggered. In the standard list status, this function code is always assigned to

function key <F2>. In turn, <F2> is always assigned for a mouse double-click.

If you fill the list buffer of the detail list (of which you may have up to twenty) using the WRITE, SKIP,

and ULINE statements, two further events are triggered:

At the beginning of each new page, the TOP-OF-PAGE DURING LINE-SELECTION event is triggered,

and the END-OF-PAGE DURING LINE-SELECTION event is triggered at the end of each page. (These

events are not displayed in the graphic.) Interactive list processing is started again. The system

displays the formatted detail list (screen 120).

Any other function codes that have not been "trapped" by the system trigger the event AT USERCOMMAND.

do reward if useful

Read only

Former Member
0 Likes
568

Hi,

This section describes in more detail the events that occur when you run an executable program.

The following events occur when you run a typical executable program that is linked with a logical database:

Event

Time

INITIALIZATION

Before the standard selection screen is displayed

AT SELECTION-SCREEN

After user input on a selection screen has been processed, but while the selection screen is still active

START-OF-SELECTION

After the standard selection screen has been processed, before data is read from the logical database

GET node

After the logical database has read a data record from the node node

GET node LATE

After all of the nodes of the logical database have been processed that are hierarchically subordinate to the node node in the structure of the logical database

END-OF-SELECTION

After all data has been read by the logical database

List processor events:

Event

Time

TOP-OF-PAGE

In list processing when a new page starts

END-OF-PAGE

In list processing when a page ends

AT LINE-SELECTION

When the user triggers the predefined function code PICK

AT PFnn

When the user triggers the predefined function code PFnn

AT USER-COMMAND

When the user triggers a function code defined in the program

Cheers,

vasavi.

kindly reward if helpful.

Read only

Former Member
0 Likes
568

Hi,

events of module pool are

PBO: process before output.the code under this triggered before displaying the screen.

PAI: process after input:the code under this is triggered after giving input.for eg:validating the field.

POH: process on help request(f1).this event is for HELP functionality

POV: process on value request(f4).This event is for getting possible values

Events of interactive report

I. At PF(nn)

II. At line-selection

III. At user-command

IV.TOP-OF-PAGE DURING LINE SELECTION.

Events of Classical reporting:

1)initialization.

2)start-of-selection.

3)top-of-page

4)end-of-page.

5)end-of-selection.

6)at selection-screen

i) at selection-screen on <field>

ii) at selection-screen output.

Regards,

Vineela