View
96
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Introduction to Interactive Reporting | 4.01 March-2005
Introduction to Interactive Reporting
Introduction to Interactive Reporting | 4.01
2March-2005
Objectives
• The participants will be able to:– Identify why sometimes is necessary to have
Interactive nature for a report.– Relate how ABAP has provided a solution by
means of Interactive Reporting.
Introduction to Interactive Reporting | 4.01
3March-2005
The Requirement
Introduction to Interactive Reporting | 4.01
4March-2005
The Solution in ABAP
Introduction to Interactive Reporting | 4.01
5March-2005
Summary
• Interactive Reports first provide a basic list and then a detail list depending on the user interaction for one or more records.
• User Interaction invokes an event that helps an ABAP programmer to design his program to respond to the user action.
Introduction to Interactive Reporting | 4.01
6March-2005
Questions• Why do we need Interactive Reporting ?• How does the programmer recognize a user
action ?
ABAP Events | 4.02 March-2005
ABAP Events
ABAP Events | 4.02 8March-2005
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.
ABAP Events | 4.02 9March-2005
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
ABAP Events | 4.02 10March-2005
Runtime Event : INITIALIZATION
Execute a processing block before the selection screen
ABAP Events | 4.02 11March-2005
Runtime Event : AT SELECTION-SCREEN
Trigger a function codeon the selection screen
ABAP Events | 4.02 12March-2005
Runtime Event: START-OF-SELECTION
Can be coded explicitly, but need not be.
ABAP Events | 4.02 13March-2005
Runtime Events : GET and GET LATE
Select recordsfrom logicaldatabase tables
ABAP Events | 4.02 14March-2005
Runtime Event : END-OF-SELECTION
Last system event to occur.Occurs only once
ABAP Events | 4.02 15March-2005
Output Event : TOP-OF-PAGE
Used for page headersfor the basic list only
ABAP Events | 4.02 16March-2005
Output Event : TOP-OF-PAGE DURING LINE-SELECTION
Used for page headerson detail lists
ABAP Events | 4.02 17March-2005
Output Event : END-OF-PAGE
Used for page footers
ABAP Events | 4.02 18March-2005
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.
ABAP Events | 4.02 19March-2005
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.
ABAP Events | 4.02 20March-2005
List Display (User) Events
Order of execution determined by user
ABAP Events | 4.02 21March-2005
List Display Event : AT PF##
Triggered by function code
PF##
ABAP Events | 4.02 22March-2005
List Display Event : AT LINE-SELECTION
Triggered by function code
PICK
ABAP Events | 4.02 23March-2005
List Display Event : AT USER-COMMAND
Triggered by function code
All Others besidesPICK or PF##
ABAP Events | 4.02 24March-2005
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.
ABAP Events | 4.02 25March-2005
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.
26 ABAP Events | 4.02 March-2005
List Display Events (“User” Events) - Typical Usage
Event Triggered by
Function Code
Typical User
Action 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
ABAP Events | 4.02 27March-2005
When Is a List Displayed?
ABAP Events | 4.02 28March-2005
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.
ABAP Events | 4.02 29March-2005
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 ?
The AT PF ## Event | 4.03 March-2005
The AT PF ## Event
The AT PF ## Event | 4.03 31March-2005
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 | 4.03 32March-2005
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
VSProcedural Language
Event z
Event y
Event x
Event w
ABAP is an Event-Driven Language
The AT PF ## Event | 4.03 33March-2005
List Display Event : AT PF##
Triggered by function code:
PF##
The AT PF ## Event | 4.03 34March-2005
REPORT Y190XX01.
TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, 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
The AT PF ## Event | 4.03 35March-2005
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
The AT PF ## Event | 4.03 36March-2005
Demonstration
• Invoking AT PF## Events from a basic list.
The AT PF ## Event | 4.03 37March-2005
Practice
• Invoking AT PF## Events from a basic list.
The AT PF ## Event | 4.03 38March-2005
Coding Example : AT PF## with Multiple Events
.
.
REPORT Y190XX01.
TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, 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.
The AT PF ## Event | 4.03 39March-2005
*--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.
The AT PF ## Event | 4.03 40March-2005
Coding Example : Opening a Window
SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>.
.
.
REPORT Y190XX01.TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, 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 ABAPReservedWordSELECT * SY-SUBRC
CHECK
The AT PF ## Event | 4.03 41March-2005
TITLE
COLUMN 10 COLUMN 77
TITLEROW 4
ROW 12
WINDOW STARTING AT… ENDING AT...
SYNTAX: WINDOW STARTING AT <# #> ENDING AT <# #>.
The AT PF ## Event | 4.03 42March-2005
Potential Problems with Creating Additional Screens
Hey!?! What’sup here???
1.
2.
3.
The AT PF ## Event | 4.03 43March-2005
The SY-LSIND System Field
Basic ListSY-LSIND = 0
1st Detail ListSY-LSIND = 1
2nd Detail ListSY-LSIND = 2
A New ABAPSystem FieldSYSTEM FIELD: SY-LSIND
F6 F6
The AT PF ## Event | 4.03 44March-2005
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.
The AT PF ## Event | 4.03 45March-2005
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
The AT PF ## Event | 4.03 46March-2005
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.)
The AT PF ## Event | 4.03 47March-2005
Demonstration
• Creation of additional screens from a list and restricting the user from creating redundant screens.
The AT PF ## Event | 4.03 48March-2005
Practice
• Creation of additional screens from a list and restricting the user from creating redundant screens.
The AT PF ## Event | 4.03 49March-2005
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, 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.
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
The AT PF ## Event | 4.03 50March-2005
*-------------------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.
A New ABAPEvent
Coding Example : Programmatically Managing the Column Headings for Your Drill-Down Windows
The AT PF ## Event | 4.03 51March-2005
Summary• In an ABAP program, 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.
The AT PF ## Event | 4.03 52March-2005
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 ?
The AT USER-COMMAND Event and Menu Painter | 4.04 March-2005
The AT USER-COMMAND Event and Menu Painter
The AT USER-COMMAND Event and Menu Painter | 4.04
54March-2005
Objectives The participants will be able to:
Apply the AT USER-COMMAND syntax. Use the Graphical User Interface. Use the SY-UCOMM system field.
The AT USER-COMMAND Event and Menu Painter | 4.04
55March-2005
Graphical User Interface (GUI)
Titlebar Menubar
StandardToolbar
ApplicationToolbar
The AT USER-COMMAND Event and Menu Painter | 4.04
56March-2005
Menu Painter
Menu PainterMenu Painter
Creates Function Codes
Function KeyAssignments
StandardToolbar
ApplicationToolbar
Menubar
The AT USER-COMMAND Event and Menu Painter | 4.04
57March-2005
GUI StatusThe GUI Status (Graphical User Interface Status)
Programmer Defined Buttons and Menus : In this sample GUI Status, the programmer decided to create a “DOCUMENTS” button, and a “LIST” menu.
The AT USER-COMMAND Event and Menu Painter | 4.04
58March-2005
GUI TitleThe GUI Title (Graphical User Interface Title)
Programmer defined titlebar
The AT USER-COMMAND Event and Menu Painter | 4.04
59March-2005
ABAP CodeThe ABAP code
TABLES: LFA1.
START-OF-SELECTION.SET PF-STATUS ‘TEST1’.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, 30 LFA1-NAME1.ENDSELECT.
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.SET PF-STATUS ‘TEST2’.SET TITLEBAR ‘TB2’.
WHEN ‘RUNY’.. . . .
ENDCASE.
SELECT *
SY-SUBRCCHECK
The AT USER-COMMAND Event and Menu Painter | 4.04
60March-2005
Activating the AT USER-COMMAND Event
3rd. Behind the scenes, the ABAP processor reacts and triggers the AT USER-COMMAND event.
1st. The user clicks on a button that the programmer created on the GUI Status.
2nd. The system detects that ‘RUNY’ has been assigned as the function code behind this button.
The AT USER-COMMAND Event and Menu Painter | 4.04
61March-2005
The AT USER-COMMAND Event
*--begin of AT USER-COMMAND event--------------------------------AT USER-COMMAND.
WRITE: / ‘The user just clicked on a pushbutton, selected’,/ ‘a menu path, or pressed a function key’.
*--end of AT USER-COMMAND event-----------------------------------
Do not write this code, we will learn the complete syntax momentarily.
A New ABAPEvent
SYNTAX: AT USER-COMMAND.SYNTAX: AT USER-COMMAND.
The AT USER-COMMAND Event and Menu Painter | 4.04
62March-2005
3rd. Behind the scenes, the ABAP processor reacts and triggers the AT USER-COMMAND event.
1st. The user clicks on a buttonthat the programmer createdon the GUI Status.
2nd. The SY-UCOMMsystem field isupdated with the four byte “tag” RUNY
A New ABAPSystem Field
SYSTEM FIELD: SY-UCOMMSYSTEM FIELD: SY-UCOMM
The SY-UCOMM System Field
The AT USER-COMMAND Event and Menu Painter | 4.04
63March-2005
*--BEGIN OF AT USER-COMMAND EVENT MODULE.--------------
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.WRITE: / ‘The user just pressed button X’.
WHEN ‘RUNY’. WRITE: / ‘The user just pressed button Y’.
ENDCASE.
*--END OF AT USER-COMMAND EVENT MODULE.----------------
Using AT USER-COMMAND with the SY-UCOMM System Field
Must be in all caps and single quotes
The AT USER-COMMAND Event and Menu Painter | 4.04
64March-2005
Two programmer defined buttons, BUTTON X, and BUTTON Y.
This is what our first interactive report, that utilises a GUI status, will look like.
A programmer defined a menu containing two menu items,(menu Item X, and menu Item Y), will duplicate the functionality of our buttons.
Interactive Report that Utilizes a GUI Status
The AT USER-COMMAND Event and Menu Painter | 4.04
65March-2005
Demonstration
•Use of AT USER-COMMAND event, system field SY-UCOMM and creation and usage of GUI components.
•Create a program generating a basic list and create different kind of detail lists from the basic list depending on User Interaction.
The AT USER-COMMAND Event and Menu Painter | 4.04
66March-2005
Practice
• Use of AT USER-COMMAND event, system field SY-UCOMM and creation and usage of GUI components.
• Create a program generating a basic list and create different kind of detail lists from the basic list depending on User Interaction.
The AT USER-COMMAND Event and Menu Painter | 4.04
67March-2005
Summary• System assigns a default GUI status to all report programs.• GUI status for a program is created through ‘Menu Painter’ transaction
‘SE41’. • GUI for a program contains the following :
– Function Key Assignment– Standard Toolbar– Application Toolbar– Menubar– Titlebar
• Three components of interactive reporting are : – GUI status– GUI Title– ABAP Code
• AT USER-COMMAND event is triggered when the user clicks on a pushbutton or selects a menu item. Which button has been clicked or which Menu item has been selected is determined by the system field SY-UCOMM.
The AT USER-COMMAND Event and Menu Painter | 4.04
68March-2005
Questions
•What are the components of a GUI ?•What can be managed through the GUI status ?•How will you manage the title of your list ?•Which event is used to recognize the user action on the list ?
•How do the programmer recognize which pushbutton has been clicked or which Menu item has been selected ?
Step-by-Step Instructions for Making a GUI |4.05 March-2005
Step-by-Step Instructions for Making a GUI
Step-by-Step Instructions for Making a GUI |4.05
70March-2005
Objectives The participants will be able to:
Use SET PF-STATUS syntax and be able to create a GUI Status. Assign Function Codes to Function Keys. Add an Icon to a Function Code. Create Pushbuttons on the Application Toolbar. Use The SY-PFKEY System Field.
Step-by-Step Instructions for Making a GUI |4.05
71March-2005
TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, 30 LFA1-NAME1.ENDSELECT.
SET PF-STATUS ‘TEST1’.
A New ABAPReserved Word
SELECT *SY-SUBRC
CHECK
Using SET PF-STATUS and Creating a GUI Status
SYNTAX: SET PF-STATUS <status name>.
Coding Example
Step-by-Step Instructions for Making a GUI |4.05
72March-2005
REPORT YGUI1-XX.
TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, 30 LFA1-NAME1.ENDSELECT.
SET PF-STATUS ‘TEST1’.
Double-click on the word ‘TEST1’.
Double Clicking GUI Status Name
SELECT *SY-SUBRC
CHECK
Step-by-Step Instructions for Making a GUI |4.05
73March-2005
Letting the System Create the GUI Status for You
Choose YES
Step-by-Step Instructions for Making a GUI |4.05
74March-2005
Entering Administrative Information
Enter Some Descriptive text
Choose “Normal Screen” as Status Type
Step-by-Step Instructions for Making a GUI |4.05
75March-2005
Menu Painter Initial DisplayYou will create that will appear on the Menu Bar of your GUI status by using these white text boxes
You create the buttons that will appear on the Application Toolbar of your GUI status by using these white text boxesFunction Key
assignments for all buttons are shown here
Use the Drop-down button to get the Function Code
Step-by-Step Instructions for Making a GUI |4.05
76March-2005
Expanding Menu Painter Display
Application Toolbar in the Menu Painter
Standard Toolbar in the Menu Painter
Standard Toolbar of your program
Application Toolbar of your program
Step-by-Step Instructions for Making a GUI |4.05
77March-2005
Assigning Function Codes to Function Keys
To create a function code with an icon associated to it, double-click on the function code, then choose an icon.
Click once here. This is where we will define our first function code.
1st.
2nd.
Step-by-Step Instructions for Making a GUI |4.05
78March-2005
Choose any icon.
Adding an Icon to a Function Code
Step-by-Step Instructions for Making a GUI |4.05
79March-2005
Function Code Attributes
Step-by-Step Instructions for Making a GUI |4.05
80March-2005
Creating Pushbuttons on the Application Toolbar
Type the function codes (RUNX and RUNY) of your buttons into the next available white text boxes on the application toolbar. Click SAVE to see the icons appear below the white boxes.
Step-by-Step Instructions for Making a GUI |4.05
81March-2005
Adding a Menu
Select the first available white text box for the menu bar, now populated with <List> and type “Test Menu”. Double-click on this menu title to open it up (see next slide).
Step-by-Step Instructions for Making a GUI |4.05
82March-2005
Adding a Menu Path
TIP: If you wish to create a menu item with a breakout (submenu), leave the entry in the Func. column blank, and type a menu item name in the Name column. Then type a function code in the breakout menu which appears.
Type RUNX and RUNY here.
Step-by-Step Instructions for Making a GUI |4.05
83March-2005
Automatic Recognition of Function Codes
The GUI must be activated
Step-by-Step Instructions for Making a GUI |4.05
84March-2005
Demonstration
• Creation of a GUI status with pushbuttons on application toolbar and customized menu.
Step-by-Step Instructions for Making a GUI |4.05
85March-2005
Practice
• Creation of a GUI status with pushbuttons on application toolbar and customized menu.
Step-by-Step Instructions for Making a GUI |4.05
86March-2005
Using AT USER-COMMAND to Detect Function Codes
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose X’.
WHEN ‘RUNY’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose Y’.
ENDCASE.
Enter this code for the “AT USER-COMMAND” event.
Step-by-Step Instructions for Making a GUI |4.05
87March-2005
GUI Status for Detail Lists
Do you notice the problem with this GUI Status?
Step-by-Step Instructions for Making a GUI |4.05
88March-2005
For now just use the control menu box to close this window.
Problem:How does the user exit this window? There should be a button on the bottom of this window that allows the user to go back.
Problem with Detail List GUI Status
Step-by-Step Instructions for Making a GUI |4.05
89March-2005
Using a Different GUI Status Type for Dialog Boxes
NEW AND IMPROVED: TEST2Dialog box GUI Statuses automatically contain a red cancel button.
Step-by-Step Instructions for Making a GUI |4.05
90March-2005
Demonstration
• Creation of Dialog boxes with Exit button.
Step-by-Step Instructions for Making a GUI |4.05
91March-2005
Practice
• Creation of Dialog boxes with Exit button.
Step-by-Step Instructions for Making a GUI |4.05
92March-2005
A Report that Uses more than One GUI Status - Code
Add this line of code. Then double-click on the word ‘TEST2’.
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.SET PF-STATUS ‘TEST2’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose X’.
WHEN ‘RUNY’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose Y’.
ENDCASE.
Step-by-Step Instructions for Making a GUI |4.05
93March-2005
A Report that Uses More than One GUI Status - Administrative
Add some descriptive text, then choose “Dialog box” as the Status Type.
Step-by-Step Instructions for Making a GUI |4.05
94March-2005
Notice that “Dialog Box” statuses do not have menus or standard toolbars.
A Report that Uses More than One GUI Status - Menu Painter
Step-by-Step Instructions for Making a GUI |4.05
95March-2005
Function Codes Automatically Recognized by ABAPFunction Code Functionality Associated
function keyButton on
Toolbar
BACK Back F3
RW Cancel F12
%EX End F15
P-- Scroll to beginning F21
P- Scroll back one page F22
P+ Scroll forward one page
F23
P++ Scroll to end F24
Step-by-Step Instructions for Making a GUI |4.05
96March-2005
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.SET PF-STATUS ‘TEST2’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose X’.
WHEN ‘RUNY’.SET PF-STATUS ‘TEST3’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose Y’.
ENDCASE.
Add this line of code.
Coding Example : A Report that Uses More Than One GUI Status
Step-by-Step Instructions for Making a GUI |4.05
97March-2005
SY-PFKEY = ‘TEST1’
SY-PFKEY = ‘TEST3’
A New ABAPSystem Field
Which status is currently being used?
SYSTEM FIELD: SY-PFKEY
The SY-PFKEY System Field
Step-by-Step Instructions for Making a GUI |4.05
98March-2005
Demonstration
• Use of more than one GUI Status in a program.
Step-by-Step Instructions for Making a GUI |4.05
99March-2005
Practice
• Use of more than one GUI Status in a program.
Step-by-Step Instructions for Making a GUI |4.05
100March-2005
SYNTAX: SET TITLEBAR <titlebar name>.
AT USER-COMMAND.CASE SY-UCOMM.
WHEN ‘RUNX’.SET PF-STATUS ‘TEST2’.SET TITLEBAR ‘TB2’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose X’.
WHEN ‘RUNY’.SET PF-STATUS ‘TEST3’.WINDOW STARTING AT 10 4
ENDING AT 77 12.WRITE: / ‘The user chose Y’.
ENDCASE.
A New ABAPReserved Word
Coding Example: Adding a GUI Title
Step-by-Step Instructions for Making a GUI |4.05
101March-2005
First
Choose Yes.
Second
Type in the text that youwant to appear in the titlebarof your GUI Status. Use ampersands (&) if you want to use variables. Then choose Save.
Adding A GUI Title - Administration
Step-by-Step Instructions for Making a GUI |4.05
102March-2005
Program’s GUI
Status 1RUNXRUNYRUNZ
Status 2RUNXRUNA
Status 3RUNCRUNY
Status 4RUNB
Function Codesfor Entire GUI
RUNARUNBRUNCRUNXRUNYRUNZ
Graphical User Interface
Step-by-Step Instructions for Making a GUI |4.05
103March-2005
Summary• GUI status name can be up to 20 characters and must be in Capital
letters.• SY-PFKEY contains the name of current GUI status. • ‘Dialog Box’ status does not have Menu or a Standard Toolbar.• GUI Title names can be up to 20 characters and must be in Capital
letters.• Whenever we create a new window or dialog box, the exit button
from the controlmenu must be used. Options to exit must be provided to the user.
• A program can have any number of GUI statuses defined. • Function Codes can be defined with a maximum four characters
long.
Step-by-Step Instructions for Making a GUI |4.05
104March-2005
Questions
• What are the naming restrictions for a PF status ?• What are the naming restrictions for a GUI title ?• What is the difference between a ‘Normal Screen’
and a ‘Dialog Box’ status ?• What is the problem if the no buttons or Function
codes are not included from thecontrol menu in a dialog box ?
• How many GUI status can be defined for a program ?• Can we pass parameters to GUI title ?
Review of Concepts: Work Areas & Internal Tables | 4.06 March-2005
Review of Concepts: Work Areas & Internal Tables
Review of Concepts: Work Areas & Internal Tables | 4.06
106March-2005
Objectives The participants will be able to:
Recall the concept of work area. Recall the concept of Internal tables.
Review of Concepts: Work Areas & Internal Tables | 4.06
107March-2005
LFA1 WORK AREA
BSIK WORK AREA
The ABAP TABLES statement creates a work area for each of the tables mentioned.
Review of Concepts : Table Work Areas
Review of Concepts: Work Areas & Internal Tables | 4.06
108March-2005
DATASOURCE
LFA1 WORK AREA
The ABAP SELECT statement takes data from the specified table (data source) and places it, one record at a time, into the work area.
RECORD # 1
SELECT * SY-SUBRCCHECK
Review of Concepts : Retrieving Data from Database Into Table Work Area
Review of Concepts: Work Areas & Internal Tables | 4.06
109March-2005
DATASOURCE
LFA1 WORK AREA
RECORD # 1
RECORD # 2
No Longer Available
SELECT * SY-SUBRCCHECK
Review of Concepts : Replacement of Table Work Area Contents
Review of Concepts: Work Areas & Internal Tables | 4.06
110March-2005
DATASOURCE
LFA1 WORK AREA
RECORD # 6
INTERNAL TABLE
RECORD # 1
RECORD # 2
RECORD # 3
RECORD # 4
RECORD # 5
When an ABAP programmer creates an internal table the data is not lost. It remains available to the programmer.
APPEND ITAB
Review of Concepts : Using Internal Tables to Capture Incoming Data
Review of Concepts: Work Areas & Internal Tables | 4.06
111March-2005
INTERNAL TABLE
RECORD # 1
RECORD # 2
RECORD # 3
LFA1 WORK AREA
RECORD # 3
CLEAR LFA1.
LFA1 WORK AREA
REFRESH ITAB.
BEFORE AFTER
INTERNAL TABLE
Review of Concepts : Keywords in Emptying Work Areas
Review of Concepts: Work Areas & Internal Tables | 4.06
112March-2005
Demonstration
• Using Workareas and Internal tables.
Review of Concepts: Work Areas & Internal Tables | 4.06
113March-2005
Practice
• Using Workareas and Internal tables.
Review of Concepts: Work Areas & Internal Tables | 4.06
114March-2005
Summary• TABLES statement in ABAP creates a workarea for the database
table specified.• Workareas can hold only one record during the program execution
whereas, an Internal table can hold multiple records at a time. • For the above reason, when we have to retrieve multiple entries
from the database, we should be using internal tables instead of an workarea. Because use of workarea will mean we have get the data from database multiple times.
• CLEAR statement deletes the content of workarea. It can be used to initialize the header line of an internal table as well.
• REFRESH statement wipes off the contents of the internal table.
Review of Concepts: Work Areas & Internal Tables | 4.06
115March-2005
Questions
• What is the difference between a workarea and an internal table ?
• Which of these (workarea vs. Internal table) is better to use in our program when we need to retrieve multiple records ?
• What are the statements to initialize workareas and internal tables ?
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07 March-2005
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE)
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
117March-2005
Objectives
The participants will be able to : Create drill-down screen. Use AT LINE-SELECTION Event. Apply SY-LISEL system field. Apply the HIDE statement. Interpret the HIDE memory.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
118March-2005
A “Drill Down” ScreenFirst the user double-clicks on a record.
Then a “drill down” list is created showing data relevant to the record initially selected by the user.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
119March-2005
The Challenges
Second Challenge:
How is this record sent back as criteria to an ABAP SELECT statement?
First Challenge:
How did the ABAP code “know” when and which record the user has selected?
SELECT * FROM BSIK WHERE LIFNR = <selected vendor number>.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
120March-2005
Illustration : (The AT LINE-SELECTION Event)
A New ABAPEvent
SYNTAX: AT LINE-SELECTION.
•Determining When the User Is Requesting Additional InformationWhen the user double-clicks a line in the report, the “AT
LINE-SELECTION” event occurs (because the PICK function code is invoked).
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
121March-2005
The SY-LISEL System Field
A New ABAPSystem Field
The Contents of SY-LISEL: 222 Express Vendor Inc CHICAGO
SYSTEM FIELD: SY-LISEL
When the user selects a line in the report, SY-LISEL is updated with the text from that line.
• Determining Which Records the User Is Requesting Additional Information Upon
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
122March-2005
TABLES: LFA1.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.ENDSELECT.
SELECT * SY-SUBRCCHECK
Coding Example : AT LINE-SELECTION and SY-LISEL
This code is continued on the next page.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
123March-2005
*--------begin of AT LINE-SELECTION event------------------------*
AT LINE-SELECTION.CHECK SY-LSIND = 1.WINDOW STARTING AT 10 4 ENDING AT 77 12.WRITE: / ‘The user double-clicked on a line in the report’.WRITE: / SY-LISEL.
*---------end of AT LINE-SELECTION event--------------------------*
Coding Example : AT LINE-SELECTION and SY-LISEL
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
124March-2005
AT LINE-SELECTION and SY-LISELFirst double-click on a record. Then a second “drill down” list is created
showing data relevant to the record you had initially selected.
If you double-click here, will another drill window appear? Why or why not?
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
125March-2005
Limitations of the SY-LISEL System Field
The contents of SY-LISEL:
“100141 A B Anders Heidelberg”
We can’t send an entire string to an ABAP SELECT statement.
SELECT * FROM BSIK WHERE LIFNR = 100141
However, if we could somehow send only individual fields from the selected record, we would then process that data with an ABAP SELECT statement.100141
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
126March-2005
Demonstration
• Use of AT LINE-SELECTION event and SY-LISEL system field.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
127March-2005
Practice
• Use of AT LINE-SELECTION event and SY-LISEL system field.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
128March-2005
The HIDE ABAP Reserved Word
SYNTAX: HIDE <program field>.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.HIDE: LFA1-LIFNR.
ENDSELECT.
A New ABAPReservedWord
Extracting Individual Fields from the Record Chosen by the User
SELECT * SY-SUBRCCHECK
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
129March-2005
LFA1 WORK AREA
RECORD # 2WRITE: / HIDE
LIST MEMORY
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.HIDE: LFA1-LIFNR.
ENDSELECT.
SELECT * SY-SUBRCCHECK
The HIDE Memory Area
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
130March-2005
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, . . . HIDE: LFA1-LIFNR.
ENDSELECT.
MEMORY
LFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
This is what the HIDE memory area and LFA1 work area look like after the SELECT statement above has finished processing.
LFA1 WORK AREA
RECORD # 3
SELECT *
SY-SUBRCCHECK
The HIDE Memory Area : (Showing the Index)
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
131March-2005
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-LIFNR, LFA1-TELF1.
ENDSELECT.
HIDE MEMORY
LFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
LFA1-TELF1 ---- ----555-1111555-2222555-3333If we used the HIDE
statement to hide both LIFNR and TELF1, our HIDE memory area would look like this.
SELECT *
SY-SUBRCCHECK
The HIDE Memory Area : (with More than One Field Stored)
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
132March-2005
The HIDE Index Numbers
VEND012
INDEX1234
MEMORY
LFA1 WORK AREA
LINE 4 from the screen corresponds with INDEX 4 from the HIDE memory area.
The Correlation between the HIDE Memory Area and Line Numbers
LFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
133March-2005
REPORT Y190XX02.TABLES: LFA1, BSIK.
START-OF-SELECTION.SELECT * FROM LFA1.
WRITE: / LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.HIDE: LFA1-LIFNR, LFA1-TELF1.
ENDSELECT.
SELECT * SY-SUBRCCHECK
Coding Example : Using the HIDE ABAP Reserved Word
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
134March-2005
What Happens When the System Hides Values?
DATASOURCE
field string
TABLE WORK AREA
HIDE MEMORYLFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
BASIC LIST
1 (header)2 (uline)3 VEND011 Star Craft Metal4 VEND012 Quality Fabr.5 VEND013 Euro Output SA
LFA1-TELF1 ---- ----555-1111555-2222555-3333
SELECT
WRITE
HIDE
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
135March-2005
What Happens When the User Selects a Valid Line?
data available for further processing
TABLE WORK AREA(Field String)
HIDE MEMORYLFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
BASIC LIST
LFA1-TELF1 ---- ----555-1111555-2222555-3333
VEND 011
555-1111
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
1 (header)2 (uline)3 VEND011 Star Craft Metal4 VEND012 Quality Fabr.5 VEND013 Euro Output SA
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
136March-2005
LFA1 WORK AREALFA1 WORK AREA
?
AT LINE-SELECTION.CHECK SY-LSIND = 1.WINDOW STARTING AT 10 4
ENDING AT 77 12.SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR.
WRITE: / LFA1-LIFNR, BSIK-BELNR.ENDSELECT.IF SY-SUBRC <> 0.
WRITE: / ‘No invoices for vendor’, LFA1-LIFNR.ENDIF.
Remember... This is referencing the program field! The value of this field is dependent upon which line you double-clicked in the on-screen report.
Remember... This is referencing the program field! The value of this field is dependent upon which line you double-clicked in the on-screen report.
SELECT *
Coding Example : Using the HIDE Memory Area
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
137March-2005
Demonstration
• Usage of HIDE command in Interactive Reporting.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
138March-2005
Practice
• Usage of HIDE command in Interactive Reporting.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
139March-2005
Challenges Revisited
Second Challenge:
How is this record sent back as criteria to an ABAP SELECT statement?
METHOD: HIDE memory area.
First Challenge:
How did the ABAP code “know” which record the user has selected?
METHOD: When a user event is triggered, the system automatically records the line selected (via SY-LISEL and other system fields).
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
140March-2005
Restart the program and double-click on the header.
Is the User Selecting a Valid Line in the Report?
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
141March-2005
Restart the program and double-click on the header. What happens?
Where does this data come from?
Is the User Selecting a Valid Line in the Report?
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
142March-2005
What Happens When the User Clicks on an Invalid Line First?
No values are restored from HIDE into program fields.The last record selected by the “SELECT” statement is still in work area and still available for further processing.
HIDE MEMORYLFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
BASIC LIST
LFA1-TELF1 ---- ----555-1111555-2222555-3333
VEND- OR2
555-9898 PA USA 19103
Mr. Jones $100
NET 30Phila.
123Main
Bacon Inc.
1 (header)2 (uline)3 VEND011 Star Craft Metal4 VEND012 Quality Fabr.5 VEND013 Euro Output SA
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
143March-2005
SYNTAX: END-OF-SELECTION.
A New ABAPEvent
After all of the other system events have been executed . . .
INITIALIZATION.AT SELECTION-SCREEN.START-OF-SELECTION.GET <table>.GET <table> LATE.
. . . before the basic list is displayed.
. . . the END-OF-SELECTION event occurs . . .
The END-OF-SELECTION Event
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
144March-2005
END-OF-SELECTION.CLEAR LFA1-LIFNR.
AT LINE-SELECTION.CHECK SY-LSIND = 1.CHECK NOT LFA1-LIFNR IS INITIAL.WINDOW STARTING AT 10 4
ENDING AT 77 12.SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR.
WRITE: / LFA1-LIFNR, BSIK-BELNR.ENDSELECT.IF SY-SUBRC <> 0.
WRITE: / ‘No invoices for vendor’, LFA1-LIFNR.ENDIF.
2
First: Initialise the LFA1-LIFNR program field just before the basic list is displayed.
Second: Make sure the LFA1-LIFNR program field is not initial before processing the rest of the user event (i.e. make sure the user selected a valid line).
SELECT *
1
Part I - Initializing Fields before Basic List Displayed
Handling Invalid Line Selection
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
145March-2005
Click on a Valid Line First
data available for further processing
TABLE WORK AREA(Field String)
HIDE MEMORY
LFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
LFA1-TELF1 ---- ----555-1111555-2222555-3333
VEND 012
555-2222
1 (header)2 (uline)3 VEND011 Star Craft Metal4 VEND012 Quality Fabr.5 VEND013 Euro Output SA
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
BASIC LIST
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
146March-2005
… Then Click on an Invalid Line
TABLE WORK AREA(Field String)
No values restored from HIDE into program fields. Values restored from last valid line selected by the user are still in the work area.
HIDE MEMORY
LFA1-LIFNR ---- ----VEND011VEND012VEND013
INDEX12345
LFA1-TELF1 ---- ----
555-1111555-2222555-3333
VEND 012
555-2222
1 (header)2 (uline)3 VEND011 Star Craft Metal4 VEND012 Quality Fabr.5 VEND013 Euro Output SA
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
OldData
BASIC LIST
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
147March-2005
Handling Invalid Line Selection
END-OF-SELECTION.CLEAR LFA1-LIFNR.
AT LINE-SELECTION.CHECK SY-LSIND = 1.CHECK NOT LFA1-LIFNR IS INITIAL.WINDOW STARTING AT 10 4
ENDING AT 77 12.SELECT * FROM BSIK WHERE LIFNR = LFA1-LIFNR.
WRITE: / LFA1-LIFNR, BSIK-BELNR.ENDSELECT.IF SY-SUBRC <> 0.
WRITE: / ‘No invoices for vendor’, LFA1-LIFNR.ENDIF.CLEAR LFA1-LIFNR.
2
1
First: Initialise the LFA1-LIFNR program field just before the detail list is displayed.
Second: Make sure the LFA1-LIFNR program field is not initial before processing the rest of the user event (i.e. make sure the user selected a valid line).
SELECT *
Part II - Initializing Fields after Each Use
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
148March-2005
Flow of Data
DATASOURCE
BASICLIST
HIDEMEMORY
WORK AREA
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
149March-2005
Summary
• AT LINE-SELECTION event is triggered when a user double-clicks on a line in the list (or single-clicks on a line and clicks on CHOOSE button or presses F2).
• System field SY-LISEL contains the contents of the line selected by the user and SY-LILLI contains the number of line selected.
• HIDE memory area exists for each lists in a report. This area gets populated with the program fields when the system encounters the HIDE statement.
• Specific fields can be stored in the memory using HIDE statement. HIDE command can be used to place multiple fields in HIDE memory area.
• HIDE memory area cannot be directly accessed using an ABAP statement. Information is fetched from this area depending on the line the user selects.
The AT LINE-SELECTION Event (SY-LISEL vs. HIDE) | 4.07
150March-2005
Question
• Which system field contains the content of the selected line ?
• What does a HIDE statement do ?• How is the HIDE statement used for producing
detail lists ?• What is an invalid line in the context of drill
down reporting ?• How do you determine if the user has clicked
on a valid line ? • What records are stored in a HIDE memory
area ? How do the system get the value for a particular field for the selected line from HIDE memory area ?
Multiple Line Selection | 4.08 March-2005
Multiple Line Selection
Multiple Line Selection | 4.08 152March-2005
The participants will be able to : Write check boxes in the screen. Providing additional information on single record on the screen. Use READ-LINE statement with SY-INDEX.
Objectives
Multiple Line Selection | 4.08 153March-2005
First the user double-clicks on a record.
Then a “drill down” list is created showing data relevant to the record initially selected by the user.
Providing Additional Information on a Single Record Only
Multiple Line Selection | 4.08 154March-2005
First, the user clicks inside of the checkboxes for the vendors that the user is interested in.
Then a drill down windowappears that contains the telephone numbers for each of the previously selected vendors.
Providing Additional Information on Multiple Records
Multiple Line Selection | 4.08 155March-2005
READ LINE 1.. checked? YES or NO
READ LINE 2.. checked? YES or NO
READ LINE 3 .. checked? YES or NO
READ LINE n .. checked? YES or NO
First we must learn techniques to “draw” checkboxes on the screen.
Then we must learn techniques to loop through each of the lines on the report and determine whether or not they were checked.
Challenges
Multiple Line Selection | 4.08 156March-2005
REPORT Y190XX03 LINE-SIZE 255.
TABLES: LFA1.DATA: CHK1.
START-OF-SELECTION.SELECT * FROM LFA1 WHERE TELF1 <> SPACE.
WRITE: / CHK1 AS CHECKBOX,LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.
SKIP.ENDSELECT.
Create a single-character variable.
Then WRITE it to the report as a checkbox.
SELECT *
SY-SUBRCCHECK
Coding Example : Writing Checkboxes to the Screen
Multiple Line Selection | 4.08 157March-2005
SYNTAX: READ LINE <#>.
A New ABAPReserved Word
READ LINE 11 FIELD VALUE LFA1-LIFNR INTO VAR1.
MEMORY VAR1 = VEND021
Programmatically Reading a Line in a Report
The READ LINE Statement
Multiple Line Selection | 4.08 158March-2005
READ LINE 1
READ LINE 2
READ LINE 3
READ LINE n
SYSTEM FIELD: SY-INDEX
A New ABAPSystem Field
READ LINE SY-INDEX FIELD VALUE LFA1-LIFNR INTO VAR1.
Looping through Each of the Lines in the Report
The SY-INDEX System Field
Multiple Line Selection | 4.08 159March-2005
This code continues on the next page.
REPORT Y190XX03 LINE-SIZE 255.
TABLES: LFA1.DATA: CHK1.
START-OF-SELECTION.SELECT * FROM LFA1 WHERE TELF1 <> SPACE.
WRITE: / CHK1 AS CHECKBOX,LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01.
HIDE: LFA1-NAME1, LFA1-TELF1.SKIP.
ENDSELECT.
Write this code.SELECT * SY-SUBRC
CHECK
The READ LINE Statement
Multiple Line Selection | 4.08 160March-2005
READ LINE 1
READ LINE 2
READ LINE 3
READ LINE n
..checked? YES or NO
.. checked? YES or NO
.. checked? YES or NO
.. checked? YES or NO
AT PF06. WINDOW STARTING AT 10 4 ENDING AT 77 12. DO. CLEAR CHK1. READ LINE SY-INDEX FIELD VALUE CHK1. IF SY-SUBRC <> 0. EXIT. ELSE. CHECK CHK1 = ‘X’. WRITE: / LFA1-NAME1, LFA1-TELF1. ENDIF. ENDDO.
Coding Example : The READ LINE Statement
Multiple Line Selection | 4.08 161March-2005
When the user has finished reading the data in the drill down window, he/shereturns to the initial screen to find that it has been modified to show the recordsthat have already been selected.
First the user clicks on the vendorsof interest.
Then the user presses the F6 key on the keyboard.
The MODIFY LINE Statement
Multiple Line Selection | 4.08 162March-2005
REPORT Y190XX03 LINE-SIZE 255.TABLES: LFA1.DATA: CHK1.DATA: WAS_USED.
SELECT * FROM LFA1 WHERE TELF1 <> SPACE. WRITE: / CHK1 AS CHECKBOX, WAS_USED, LFA1-LIFNR, LFA1-NAME1, LFA1-ORT01. HIDE: LFA1-NAME1, LFA1-TELF1. SKIP.ENDSELECT.
Add new code here and here.
SELECT * SY-SUBRCCHECK
Coding Example : The MODIFY LINE Statement
Multiple Line Selection | 4.08 163March-2005
AT PF06. WINDOW STARTING AT 10 4 ENDING AT 77 12.
DO. CLEAR CHK1. READ LINE SY-INDEX FIELD VALUE CHK1. IF SY-SUBRC <> 0. EXIT. ELSE. CHECK CHK1 = ‘X’. MODIFY CURRENT LINE: FIELD VALUE WAS_USED FROM ‘*’
CHK1 FROM SPACE FIELD FORMAT CHK1 INPUT OFF. WRITE: / LFA1-NAME1, LFA1-TELF1. ENDIF.
ENDDO.
Add new code here.
Coding Example : The MODIFY LINE Statement
Multiple Line Selection | 4.08 164March-2005
Demonstration
• Writing checkboxes, use of READ LINE and MODIFY LINE statement
Multiple Line Selection | 4.08 165March-2005
Practice
• Writing checkboxes, use of READ LINE and MODIFY LINE statement
Multiple Line Selection | 4.08 166March-2005
Summary
• Checkboxes can be written to the list by using ‘AS CHECKBOX’ addition with the WRITE command.
• READ LINE statement can be used to read the contents of a list. With this statement, the contents of the line are populated in system field SY-LISEL.
• MODIFY LINE statement can be used to modify the list even after it is displayed. The format of the lines in the list can also be changed using MODIFY LINE ….. FORMAT addition.
Multiple Line Selection | 4.08 167March-2005
Questions
• How do you draw checkboxes in the output list ?
• How to read the contents of a list ?• How do you modify the contents of a list after
it is displayed ?