Graphical User Interfaces for Lists (Notes)
Transcript of Graphical User Interfaces for Lists (Notes)
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
1/46
1
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
2/46
2
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
3/46
To trap a user action and to provide a mechanism for programming a response
3
to a user action ABAP provides several events associated with interactive
reports.
They are:i) AT LINE-SELECTION which is triggered when a user double clicks
on a report line;
ii) AT USER-COMMAND which is triggered when a user selects from a
menu or clicks on a pushbutton; and
iii) AT PF which is triggered when a user presses a numbered function
key.
The programs response to the user action can often be more directed byincorporating the cursor position as a factor in deciding the response. (For
instance sort the report by the column the cursor is currently in, or, popup the
details of the customer whose id number is currently under the cursor.) ABAP
provides the GET CURSOR command to allow us to interrogate the name and
value of the field currently under the cursor.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
4/46
The combination of pull down menus, application and standard toolbar
4
pushbuttons, and function keys with which the user interacts with a report
screen is referred to a GUI Status.
In a report with several different screens, the combination of the GUI statusfor each screen forms the GUI Interface for the report.
(Note that status is SAP terminology)
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
5/46
The various elements of a GUI status are described here and illustrated in the
5
next slide.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
6/46
6
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
7/46
The tool used to define/create a GUI status is the Menu Painter.
7
There are a variety of ways to start the menu painter tool:
i) choose the pushbutton labelled menu painter on the application toolbar
of the ABAP Developer Workbench;
ii) enter the transaction code /nSE41 in the command field of the
standard toolbar; or
iii) enter the line of code SET PF-STATUS in your ABAP
program and then double click (or press F2) on the .
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
8/46
8
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
9/46
This slide illustrates the opening screen of the menu painter.
9
Note that the screen requires a short text description and a status type. There
are 4 possible status types. For interactive reports we use the List type for full
screens or List in a Dialog Box if we are creating a popup up window.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
10/46
The status type Screen is used for status associated with a dialog program.
10
Similarly, type Dialog Box is used for a popup window/dialog box in a dialog
program.
Type List is used when creating a status for a report and List in Dialog Box is
used when you are creating a status for a popup window.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
11/46
11
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
12/46
The menu painter tool allows you to define basically all the elements of a status.
12
These elements include:
i) the status title (defined through the short text definition in the opening screen);
ii) thee menus and items on each menu;
iii) the standard toolbar icons that are to be displayed as active;
iv) the icons/pushbuttons on the application toolbar; and
v) the function key definitions.
The Display Standards pushbutton telle the menu painter to create the SAP
standards for the menu bar. This includes menus for List, Edit, Goto as well as
System and Help. (The System and Help menus are part of every SAP screen. Thye
will not appear on the surface of the menu painter tool but will appear on the menu
bar in your program.)
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
13/46
13
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
14/46
This slide illustrates the top section of the menu painter screen. It shows some
14
important application toolbar icons. For instance:
i) the Generate icon is used to save and generate the source code for the GUI
status from the definition you have created in the menu painter tool.
Each status must be generated before it can be used in your report
program.
ii) The Insert New Line icon can be used to insert a new line into the pull
down menu item list.
The other important feature illustrated in this slide is the (up to) 10 character
function codes assigned to each menu item. The menu item is displayed on the
screen. When a user selects from a menu, the value of the function code
attached to the selected menu item is pushed into the system variable SY-
UCOMM.
In the code for the AT USER-COMMAND event the action the program takes
in response to the user selecting a menu item is determined by testing the value
of SY-UCOMM.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
15/46
15
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
16/46
16
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
17/46
To activate an already defined GUI status from within an ABAP program use
17
the SET PF-STATUS statement.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
18/46
To dynamically change the title of the status use the SET TITLEBAR
18
statement.
The can be up to 3 characters long. For instance
SET TITLEBAR BAS.
Would set the titlebar to display the text associated with the text element
BAS.
To set the text element double click on the BAS. You will be taken to the
Text Elements maintenance screen.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
19/46
19
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
20/46
20
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
21/46
The event used to respond to a user action in a status is AT USER-
21
COMMAND.
The function code corresponding to the menu item or pushbutton selected by
the user is stored in the system variable SY-UCOMM. Hence the general logicof the AT USER-COMMAND event is:
determine the value of SY-UCOMM,
perform the appropriate program block.
In general a CASE statement is used for the above.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
22/46
Secondary lists can be displayed in a full screen or a window. A window can
22
be thought of as a screen with a frame.
Windows support all the list processing features available in full screen mode.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
23/46
Note that when you specify WINDOW STARTING AT C1 R1
23
C1 R1 determines the screen position of the first output position, not the
position of the screen border.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
24/46
24
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
25/46
The GET CURSOR command can be used to interactively retrieve both the
25
name and the value of the field on which the cursor is currently positioned.
Here FNAME and FVALUE are data items generally declared to be something
like FNAME(20) type c, FVALUE(20) type c.
TO determine whether the cursor was positioned on a field or not the program
should check the contents of the SY-SUBRC variable which holds the return
code for the operation.
If SY-SUBRC is 0, the cursor was positioned on a field, else the cursor was not
positioned on a field.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
26/46
This program demonstrates the use of GET CURSOR.
26
Here the data items FRED and BARNEY have been declared and given values.
The data items are displayed on the screen.
When the user double clicks somewhere on the screen the AT LINE-
SELECTION event is triggered. If the cursor was positioned on a field the
name and value of the field is displayed.
(See next slide for screen dumps of the working program)
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
27/46
In the first screen the cursor is on a field and the GET CURSOR statement
27
returns the name and value of the field.
In the second screen the cursor is not on a field.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
28/46
The following code shows how to use GET CURSOR to allow the user to
28
interactively select a field by which to sort a list.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
29/46
29
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
30/46
Note that in the example it is not correct to simply
30
GET CURSOR FNAME.
SORT ITAB BY FNAME.
This code will result in an error ITAB does not contain a field called FNAME.
Hence it is necessary to use the CASE statement to determine the value of
FNAME and hence to perform the appropriate sort.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
31/46
31
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
32/46
32
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
33/46
33
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
34/46
34
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
35/46
Messages are an important feature of reports. Rather than using a WRITE
35
statement to display a message on the screen we can use the MESSAGE
statement to display a message that has been stored in a database table
reserved specifically for storing message text, (table T100).
In order to be able to use messages the REPORT statement at the beginning of
the program must include the MESSAGE-ID xx clause where xx represents a
class of messages.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
36/46
36
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
37/46
To display a message use the statement MESSAGE xnnn where x represents a
37
message level and nnn is the number of the message.
The system responds differently to messages at different levels. For instance,
after displaying a level I message processing will resume. However afterdisplaying a level A message the program will terminate.
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
38/46
It is also possible to pass up to 4 values to a message using the WITH addition.
38
In order for the message to be able to accept parameters the message text must
include placeholders, eg, &1 to &4.
When the MESSAGE .. WITH statement is executed the
placeholders &1 .. &4 are replaced with the values in .
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
39/46
39
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
40/46
40
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
41/46
41
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
42/46
42
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
43/46
43
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
44/46
44
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
45/46
45
-
7/29/2019 Graphical User Interfaces for Lists (Notes)
46/46