23
IBM Global Business Services © IBM Corporation 2013 The AT PF ## Event | Dec-2008 The AT PF ## Event

Chapter 03_The at PF ## Event

Embed Size (px)

DESCRIPTION

Chapter 03_The at PF ## Event

Citation preview

Page 1: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 2013The AT PF ## Event | Dec-2008

The AT PF ## Event

Page 2: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20132 Dec-2008The AT PF ## Event |

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.

Page 3: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20133 Dec-2008The AT PF ## Event |

Starts at the beginning of the code

Completes at the end of the code

Event-driven Language

The events can execute in any order. Some may never even execute at all.

1st

3rd

2nd

VSVSProcedural Language

Event zEvent z

Event y

Event x

Event w

ABAP is an Event-Driven Language

Page 4: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20134 Dec-2008The AT PF ## Event |

List Display Event : AT PF##

Triggered by function code:

PF##PF##

Page 5: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20135 Dec-2008The AT PF ## Event |

REPORT Y190XX01.

DATA: WA_LFA1 TYPE LFA1.

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<##>.

PF## Coding Example

A New ABAPEvent

.

SELECT *SY-SUBRC

CHECK

Page 6: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20136 Dec-2008The AT PF ## Event |

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 togo 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.

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.

Function Keys Reserved by SAP

Page 7: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20137 Dec-2008The AT PF ## Event |

Demonstration

Invoking AT PF## Events from a basic list.

Page 8: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20138 Dec-2008The AT PF ## Event |

Practice

Invoking AT PF## Events from a basic list.

Page 9: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 20139 Dec-2008The AT PF ## Event |

Coding Example : AT PF## with Multiple Events

.

.

REPORT Y190XX01.

DATA:WA_LFA1 TYPE LFA1.

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’.

When the user presses the F6 key only the code

between the two arrows will execute.

Page 10: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201310 Dec-2008The AT PF ## Event |

*--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 Events in ABAP

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

Page 11: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201311 Dec-2008The AT PF ## Event |

Coding Example : Opening a Window

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

.

.

REPORT Y190XX01.

DATA:WA_LFA1 TYPE LFA1.

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’.

A New ABAP

ReservedWordSELECT * SY-SUBRC

CHECK

Page 12: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201312 Dec-2008The AT PF ## Event |

TITLE

COLUMN 10 COLUMN 77

TITLEROW 4

ROW 12

WINDOW STARTING AT… ENDING AT...

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

Page 13: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201313 Dec-2008The AT PF ## Event |

Potential Problems with Creating Additional Screens

Hey!?! What’s

up here???

1.

2.

3.

Page 14: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201314 Dec-2008The AT PF ## Event |

The SY-LSIND System Field

Basic ListSY-LSIND = 0

1st Detail ListSY-LSIND = 1

2nd Detail ListSY-LSIND = 2

A New ABAP

System FieldSYSTEM FIELD: SY-LSIND

F6 F6

Page 15: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201315 Dec-2008The AT PF ## Event |

AT PF06.CHECK SY-LSIND = 1.

WINDOW STARTING AT 10 4 ENDING AT 77 12.

WRITE: / ‘SY-LSIND =’, SY-LSIND.WRITE: / ‘The user just pressed the F6 key’.

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

Coding Example : SY-LSIND System Field

Check that SY-LSIND is equal to 1.

If SY-LSIND is not equal to one, then the rest of the AT PF06

event block does not execute..

Page 16: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201316 Dec-2008The AT PF ## Event |

Here SY-LSIND is equal to 0. The user attempts to create another list.

The user attempts to create another list, but cannot because CHECK SY-LSIND = 1 returns false. The contents of the initial list remain unchanged.

Now SY-LSIND is equal to 1.

Strategies for Dealing with Detail Lists using the SY-LSIND System Field

Page 17: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201317 Dec-2008The AT PF ## Event |

Here SY-LSIND is equal to 0. The user attempts to create another list.

The user attempts to create another list, but cannot because CHECK SY-LSIND = 1 returns false. The contents of the initial list remain unchanged.

Now SY-LSIND is equal to 1.

Strategies for Dealing with Detail Lists using the SY-LSIND System Field (Contd.)

Page 18: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201318 Dec-2008The AT PF ## Event |

Demonstration

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

Page 19: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201319 Dec-2008The AT PF ## Event |

Practice

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

Page 20: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201320 Dec-2008The AT PF ## Event |

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’.

A New ABAPEvent

SYNTAX: TOP-OF-PAGE.SYNTAX: TOP-OF-PAGE.

Prior to the TOP-OF-PAGE event, column headings were managed via text elements. The TOP-OF-PAGE event allows you to manage your column headings through code.

SELECT * SY-

SUBRC

CHECK

Programmatically Managing Column Headings for Your Report

Page 21: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201321 Dec-2008The AT PF ## Event |

*-------------------BEGINNING OF TOP-OF-PAGE----------------------*TOP-OF-PAGE.

WRITE: / ‘This is the header of the basic list’.*-------------------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’.

The TOP-OF-PAGE DURING LINE-SELECTION event allows you to manage the column headings of the detail lists through code.

SYNTAX: TOP-OF-PAGE DURING LINE-SELECTION.SYNTAX: TOP-OF-PAGE DURING LINE-SELECTION.

A New ABAPEvent

Coding Example : Programmatically Managing the Column Headings for Your Drill-Down Windows

Page 22: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201322 Dec-2008The AT PF ## Event |

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.

Page 23: Chapter 03_The at PF ## Event

IBM Global Business Services

© IBM Corporation 201323 Dec-2008The AT PF ## Event |

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 ?