You are on page 1of 16

IBM Global Services

The AT USER-COMMAND Event and Menu Painter

The AT USER-COMMAND Event an Dec-2008 © 2005 IBM Corporation


d Menu Painter |
IBM Global Services

Objectives

 The participants will be able to:


 Apply the AT USER-COMMAND syntax.
 Use the Graphical User Interface.
 Use the SY-UCOMM system field.

2 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Graphical User Interface (GUI)

Titlebar Menubar

Application Standard
Toolbar Toolbar

3 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Menu Painter

Menu Painter

Creates Function Codes

Function Key Standard Application


Assignments Toolbar Toolbar Menubar

4 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

GUI Status
The 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.

5 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

GUI Title
The GUI Title (Graphical User Interface Title)

Programmer defined titlebar

6 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

ABAP Code

DATA: WA_LFA1 TYPE LFA1.

START-OF-SELECTION.
SET PF-STATUS ‘TEST1’. SELECT *
SELECT * FROM LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR, 30 WA_ LFA1-NAME1.
ENDSELECT.

AT USER-COMMAND.
CASE SY-UCOMM. CHECK
WHEN ‘RUNX’. SY-SUBRC
SET PF-STATUS ‘TEST2’.
SET TITLEBAR ‘TB2’.
WHEN ‘RUNY’.
....
ENDCASE.

7 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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

3rd. Behind the scenes, the ABAP processor reacts and triggers the AT
USER-COMMAND event.

8 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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
ABAP
Event

SYNTAX: AT USER-COMMAND.

9 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

The SY-UCOMM System Field

A New
ABAP
System Field

1st. The user clicks on a button 2nd.


The SY-UCOMM
that the programmer created system field is
on the GUI Status. updated with the
four char. “tag” RUNY
3rd. Behind the scenes, the ABAP processor reacts
and triggers the AT USER-COMMAND event.

SYSTEM FIELD: SY-UCOMM

10 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Using AT USER-COMMAND with the SY-UCOMM System


Field

*--BEGIN OF AT USER-COMMAND EVENT MODULE.--------------


Must be in
AT USER-COMMAND.
CASE SY-UCOMM. all caps and
WHEN ‘RUNX’.
single quotes
WRITE: / ‘The user just pressed button X’.

WHEN ‘RUNY’.
WRITE: / ‘The user just pressed button Y’.
ENDCASE.

*--END OF AT USER-COMMAND EVENT MODULE.----------------

11 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

Interactive Report that Utilizes a GUI Status

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.

Two programmer defined buttons,


BUTTON X, and BUTTON Y.

12 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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.

13 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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.

14 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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.

15 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation
IBM Global Services

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 ?

16 The AT USER-COMMAND Event and Menu Painter | Dec-2008 © 2005 IBM Corporation

You might also like