You are on page 1of 23

IBM Global Business Services

The AT PF ## Event

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Objectives

The participants will be able to:

Define the AT PF ## EVENT.

Identify Function Keys reserved by ABAP.

View and experiment coding examples.

Apply the SY-LSIND system field.

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

ABAP is an Event-Driven Language

Procedural Language

VS
Starts at the
beginning
of the code

Completes
at the end
of the code

The AT PF ## Event |

Event-driven Language

Event z
Event y

3rd

Event x

1st

Event w

2nd

The events can execute in any


order. Some may never even
execute at all.
Dec-2008

IBM Corporation 2013

IBM Global Business Services

List Display Event : AT PF##

Triggered by function code:

PF##
4

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

PF## Coding Example

REPORT Y190XX01.
DATA: WA_LFA1 TYPE LFA1.

SELECT *

CHECK

A New
ABAP
Event

SY-SUBRC
START-OF-SELECTION.
SELECT * FROM LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR, WA_LFA1-NAME1, WA_LFA1-ORT01.
ENDSELECT.
AT PF06.
WRITE: / The user has just pressed the F6 key.
.

SYNTAX: AT PF<##>.

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Function Keys Reserved by SAP


F1

Reserved for the Help function

F2

The user will press the F2 key to


select a specific line of interest
in your report.

F3

The user will press the F3 key to


go back one screen in your
report.
Just as a test, place your mouse
on the green back arrow on the
ABAP Editor toolbar. What
does the little yellow flag say?

F4

The user will press the F4 key to


see possible values that can be
entered into a field.

F10 The user will press the F10 key


to switch into menu select mode.
Try it. Go to the ABAP Editor and
press F10.

The AT PF ## Event |

F12 The user will press the F12 key to


quit. Its the same as clicking on
the red X that is located on the
ABAP Editor toolbar.
F15 (Shift + F3) The user will press the
F15 key to End. Its the same as
clicking on the yellow up arrow that
is located on the ABAP Editor
toolbar.
F21 (Shift + F9) The user will press the
F21 key to scroll to the beginning.
F22 (Shift + F10) The user will press
the F22 key to scroll back one
page.
F23 (Shift + F11) The user will press the
F23 key to scroll forward one page.
F24 (Shift + F12) F24 -> scroll to the
end.
Dec-2008

IBM Corporation 2013

IBM Global Business Services

Demonstration
Invoking AT PF## Events from a basic list.

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Practice
Invoking AT PF## Events from a basic list.

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Coding Example : AT PF## with Multiple Events

REPORT Y190XX01.
DATA:WA_LFA1 TYPE LFA1.

When the user presses the


F6 key only the code
between the two arrows will
execute.

START-OF-SELECTION.
SELECT * FROM LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR, WA_LFA1-NAME1, WA_LFA1-ORT01.
ENDSELECT.
AT PF06.
WRITE: / The user just pressed the F6 key.
AT PF07.
WRITE: / The user just pressed the F7 key.

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Commenting Events in ABAP

*--BEGIN OF AT PF06 EVENT MODULE.----------------------------------------AT PF06.


WRITE: / The user just pressed the F6 key.
*--END OF AT PF06 EVENT MODULE.-------------------------------------------*--BEGIN OF AT PF07 EVENT MODULE.----------------------------------------AT PF07.
WRITE: / The user just pressed the F7 key.
*--END OF AT PF07 EVENT MODULE.--------------------------------------------

Commenting in this manner helps to make the start and end of an event
more apparent.

10

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Coding Example : Opening a Window


REPORT Y190XX01.
DATA:WA_LFA1 TYPE LFA1.
SELECT *

A New
ABAP
Reserved
Word

CHECK
SY-SUBRC

START-OF-SELECTION.
SELECT * FROM LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR, WA_LFA1-NAME1, WA_LFA1-ORT01.
ENDSELECT.
AT PF06.
WINDOW

STARTING AT 10 4
ENDING AT 77 12.
WRITE: / The user just pressed the F6 key.

AT PF07.
WRITE: / The user just pressed the F7 key.
.

SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>.

11

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

WINDOW STARTING AT ENDING AT...


COLUMN 10

COLUMN 77

TITLE
ROW 4

TITLE

ROW 12

SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>.

12

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Potential Problems with Creating Additional Screens

Hey!?!
Whats
up here???

3.

2.

1.

13

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

The SY-LSIND System Field

1st Detail List


SY-LSIND = 1

Basic List
SY-LSIND = 0

2nd Detail List


SY-LSIND = 2

F6

F6

A New
ABAP
System Field

SYSTEM FIELD: SY-LSIND

14

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Coding Example : SY-LSIND System Field

Check that SY-LSIND is equal to 1.


AT PF06.
CHECK SY-LSIND = 1.
WINDOW STARTING AT 10 4
ENDING AT 77 12.

If SY-LSIND is not equal to one,


then the rest of the AT PF06 event
block does not execute.

WRITE: / SY-LSIND =, SY-LSIND.


WRITE: / The user just pressed the F6 key.
AT PF07.
WRITE: / The user just pressed the F7 key.

15

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Strategies for Dealing with Detail Lists using the SY-LSIND


System Field

Here SY-LSIND is equal to 0. The


user attempts to create
another list.

Now SY-LSIND is equal to 1.

The user attempts to create another list,


but cannot because CHECK SY-LSIND = 1
returns false. The contents of the initial
list remain unchanged.

16

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Strategies for Dealing with Detail Lists using the SY-LSIND


System Field (Contd.)

Here SY-LSIND is equal to 0. The


user attempts to create
another list.

Now SY-LSIND is equal to 1.

The user attempts to create another list,


but cannot because CHECK SY-LSIND = 1
returns false. The contents of the initial
list remain unchanged.

17

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Demonstration
Creation of additional screens from a list and restricting the user from creating
redundant screens.

18

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Practice
Creation of additional screens from a list and restricting the user from creating
redundant screens.

19

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Programmatically Managing Column Headings for Your Report


SELECT
*

Prior to the TOP-OF-PAGE event,


column headings were managed
via text elements. The TOP-OFPAGE event allows you to
manage your column headings
through code.

A New
ABAP
Event

SYNTAX: TOP-OF-PAGE.
20

The AT PF ## Event |

CHECK
SY-SUBRC

START-OF-SELECTION.
SELECT * FROM LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR,
WA_LFA1-NAME1, WA_LFA1-ORT01.
ENDSELECT.
*-----BEGINNING OF TOP-OF-PAGE EVENT
-----*
TOP-OF-PAGE.
WRITE: / This is the header of the basic
list.
*-----END OF TOP-OF-PAGE
EVENT-----------------*
AT PF06.
CHECK SY-LSIND = 1.
WRITE: / The user just pressed the F6
key.
Dec-2008

IBM Corporation 2013

IBM Global Business Services

Coding Example : Programmatically Managing the Column


Headings for Your Drill-Down Windows
A New
ABAP
Event

The TOP-OF-PAGE DURING LINESELECTION event allows you to


*-------------------BEGINNING OF TOP-OF-PAGE----------------------*
manage the column headings of the
TOP-OF-PAGE.
detail
WRITE: / This is the header of the basic
list.lists through code.
*-------------------END OF TOP-OF-PAGE
*BEG. OF TOP-OF-PAGE DURING LINE-SELECTION EVENT-*
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: / This is the header of the detail list.
*END OF TOP-OF-PAGE DURING LINE-SELECTION EVENT--*
*------------------- BEGINNING OF AT PF06 EVENT-------------------*
AT PF06.
CHECK SY-LSIND = 1.
WRITE: / The user just pressed the F6 key.
SYNTAX: TOP-OF-PAGE DURING LINE-SELECTION.

21

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Summary
In an ABAP program, user events are recognized by the Function codes. Which
event has been triggered by the user is determined by the Function code.
At a time 20 detail lists can be opened.
Some Function keys are reserved for ABAP Functions. Though, ABAP program
can be written to override these, but typically, reserved keys are not used unless
required.
System field SY-LSIND contains the number of additional lists the user has
created. This field can be used to restrict the user from creating additional
windows.
TOP-OF-PAGE event triggers when the first statement for the basic list, i.e.
WRITE, SKIP etc. Similarly, TOP-OF-PAGE DURING LINE-SELECTION is
triggered when first list statements are encountered in a detail list.

22

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

IBM Global Business Services

Questions
How does the order of execution depends on the way the events are coded inside
the program ?
What is a detailed list ?
How the user can be restricted from creating unnecessary windows by pressing
the same Function key or pushbutton ?
How will you create new windows with specific size ?
How can you programmatically manage the heading of basic and detail lists ?

23

The AT PF ## Event |

Dec-2008

IBM Corporation 2013

You might also like