Chapter 02_ABAP Events

23
IBM Global Services ABAP Events | 4.02 March-2005 © 2005 IBM Corporation ABAP Events

description

Abap events

Transcript of Chapter 02_ABAP Events

Page 1: Chapter 02_ABAP Events

IBM Global Services

ABAP Events | 4.02 March-2005 © 2005 IBM Corporation

ABAP Events

Page 2: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation2 March-2005ABAP Events | 4.02

Objectives

The participants will be able to: Interpret ABAP Event-Driven Programming. Identify the System Triggered events that are executed during runtime of a Report

program Identify the User Invoked List Display events, that are triggered after the report has

generated the basic list.

Page 3: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation3 March-2005ABAP Events | 4.02

REPORT ZPB001.

TABLES: BSIK.DATA: VAR1(4) VALUE ‘0001’.

GET BSIK. IF SY-LINNO < 5. WRITE: / BSIK-LIFNR, VAR1. ENDIF.

END-OF-SELECTION. WRITE: / ‘END-OF-SELECTION’, ‘has occurred’.

START-OF-SELECTION. WRITE: / ‘START-OF-SELECTION’, ‘has occurred’.

Program Code Program List Flow Produced

1

3

2

Program Header

START-OF-SELECTION has occurred100000 0001END-OF-SELECTION has occurred

ABAP Event-Driven Programming

Page 4: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation4 March-2005ABAP Events | 4.02

Runtime Event : INITIALIZATION

Execute a processing block before the selection screen

Page 5: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation5 March-2005ABAP Events | 4.02

Runtime Event : AT SELECTION-SCREEN

Trigger a function codeon the selection screen

Page 6: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation6 March-2005ABAP Events | 4.02

Runtime Event: START-OF-SELECTION

Can be coded explicitly, but need not be.

Page 7: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation7 March-2005ABAP Events | 4.02

Runtime Events : GET and GET LATE

Select recordsfrom logical

database tables

Page 8: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation8 March-2005ABAP Events | 4.02

Runtime Event : END-OF-SELECTION

Last system event to occur.Occurs only once

Page 9: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation9 March-2005ABAP Events | 4.02

Output Event : TOP-OF-PAGE

Used for page headersfor the basic list only

Page 10: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation10 March-2005ABAP Events | 4.02

Output Event : TOP-OF-PAGE DURING LINE-SELECTION

Used for page headerson detail lists

Page 11: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation11 March-2005ABAP Events | 4.02

Output Event : END-OF-PAGE

Used for page footers

Page 12: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation12 March-2005ABAP Events | 4.02

Demonstration

Observe the following system-triggered events during execution of a Report program.

INITIALIZATION. AT SELECTION-SCREEN. START-OF-SELECTION. GET <table>. GET <table> LATE. END-OF-SELECTION. TOP-OF-PAGE. END-OF-PAGE.

Page 13: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation13 March-2005ABAP Events | 4.02

Practice

Observe the following system-triggered events during execution of a Report program.

INITIALIZATION. AT SELECTION-SCREEN. START-OF-SELECTION. GET <table>. GET <table> LATE. END-OF-SELECTION. TOP-OF-PAGE. END-OF-PAGE.

Page 14: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation14 March-2005ABAP Events | 4.02

List Display (User) Events

Order of execution determined by user

Page 15: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation15 March-2005ABAP Events | 4.02

List Display Event : AT PF##

Triggered by function code

PF##PF##

Page 16: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation16 March-2005ABAP Events | 4.02

List Display Event : AT LINE-SELECTION

Triggered by function code

PICKPICK

Page 17: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation17 March-2005ABAP Events | 4.02

List Display Event : AT USER-COMMAND

Triggered by function code

All Others All Others besidesbesides

PICK or PF##PICK or PF##

Page 18: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation18 March-2005ABAP Events | 4.02

Demonstration

Observe the following user-invoked List Display events after the Basic List has been generated by a Report Program.

AT PF##. AT LINE-SELECTION. AT USER-COMMAND.

Page 19: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation19 March-2005ABAP Events | 4.02

Practice

Observe the following user-invoked List Display events after the Basic List has been generated by a Report Program.

AT PF##. AT LINE-SELECTION. AT USER-COMMAND.

Page 20: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation20 March-2005ABAP Events | 4.02

List Display Events (“User” Events) - Typical Usage

Event Triggered byFunction Code

Typical UserAction Assigned

AT PF## PF## Function keypressed

AT LINE-SELECTION PICK Mouse double-click, Or single click + F2

AT USER-COMMAND ALL OTHER CODES Click on a push- button, or select a menu item

Page 21: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation21 March-2005ABAP Events | 4.02

When Is a List Displayed?

Page 22: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation22 March-2005ABAP Events | 4.02

Summary

Flow of an ABAP program is controlled by events. Execution order of events does not depend on the order in which they are coded in the program.

All ABAP statements that are not coded as part of an event, are part of the event START-OF-SELECTION. This event does not need to be coded explicitly in an ABAP program. It gets triggered automatically.

END-OF-SELECTION is the last system triggered event to be processed during the runtime of a program. It occurs after all database retrievals has finished and before any User-invoked events. It occurs only once during the execution of an ABAP program.

AT PF## (when any Function key is pressed), AT LINE-SELECTION (when the user double-clicks on a line) and AT USER-COMMAND (Clicking on a pushbutton or selecting a menu item) are three different user-invoked events that are handled from an ABAP program.

Page 23: Chapter 02_ABAP Events

IBM Global Services

© 2005 IBM Corporation23 March-2005ABAP Events | 4.02

Questions

What are the different events in an ABAP program that can be triggered before user interaction ? When do they get triggered ?

What are the user-invoked events for a list display ? What are the events used for displaying Headers and Footers in a list ? When

are these events invoked ? Which part of a code in a program are executed for an event ?