Вы находитесь на странице: 1из 46

1

To trap a user action and to provide a mechanism for programming a response 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<nn> which is triggered when a user presses a numbered function key. The programs response to the user action can often be more directed by incorporating 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.

The combination of pull down menus, application and standard toolbar 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 status for each screen forms the GUI Interface for the report. (Note that status is SAP terminology)

The various elements of a GUI status are described here and illustrated in the next slide.

The tool used to define/create a GUI status is the Menu Painter. 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 <status name> in your ABAP program and then double click (or press F2) on the <status name>.

This slide illustrates the opening screen of the menu painter. 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.

The status type Screen is used for status associated with a dialog program. 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.

10

11

The menu painter tool allows you to define basically all the elements of a status. 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.)

12

13

This slide illustrates the top section of the menu painter screen. It shows some 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 SYUCOMM. 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.

14

15

16

To activate an already defined GUI status from within an ABAP program use the SET PF-STATUS <status name> statement.

17

To dynamically change the title of the status use the SET TITLEBAR <titlebarname> statement. The <titlebarname> 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.

18

19

20

The event used to respond to a user action in a status is AT USERCOMMAND. 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 logic of 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.

21

Secondary lists can be displayed in a full screen or a window. A window can be thought of as a screen with a frame. Windows support all the list processing features available in full screen mode.

22

Note that when you specify WINDOW STARTING AT C1 R1 C1 R1 determines the screen position of the first output position, not the position of the screen border.

23

24

The GET CURSOR command can be used to interactively retrieve both the 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.

25

This program demonstrates the use of GET CURSOR. 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 LINESELECTION 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)

26

In the first screen the cursor is on a field and the GET CURSOR statement returns the name and value of the field. In the second screen the cursor is not on a field.

27

The following code shows how to use GET CURSOR to allow the user to interactively select a field by which to sort a list.

28

29

Note that in the example it is not correct to simply 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.

30

31

32

33

34

Messages are an important feature of reports. Rather than using a WRITE 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.

35

36

To display a message use the statement MESSAGE xnnn where x represents a 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 after displaying a level A message the program will terminate.

37

It is also possible to pass up to 4 values to a message using the WITH addition. 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 <f1><f4> statement is executed the placeholders &1 .. &4 are replaced with the values in <f1> <f4>.

38

39

40

41

42

43

44

45

46

Вам также может понравиться