ABAP Keyword Documentation → ABAP - Reference → User Dialogs → Dynpros → Dynpro Fields → Screen Fields - Examples
Screens, Pushbuttons
The example shows how to process pushbuttons on screens.
Other versions: 7.31 | 7.40 | 7.54
Source Code
PROGRAM demo_dynpro_push_button .
DATA: ok_code TYPE sy-ucomm,
save_ok LIKE ok_code,
output(8) TYPE c.
CALL SCREEN 100.
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BUTTON_EXIT'.
LEAVE PROGRAM.
WHEN 'BUTTON_1'.
output = 'Button 1'(001).
WHEN 'BUTTON_2'.
output = 'Button 2'(002).
WHEN 'BUTTON_3'.
output = 'Button 3'(003).
WHEN 'BUTTON_4'.
output = 'Button 4'(004).
WHEN OTHERS.
output = save_ok.
ENDCASE.
ENDMODULE.
Description
The static next screen number of screen 100 is 100. The screen field of output
has been set as not ready for input in the Screen Painter. If the user chooses one of the pushbuttons,
the event PAI is triggered. The function code of the pushbutton is assigned to the screen field
ok_code which in turn is assigned to the ABAP field of the same name. Then the module user_command_0100
is processed. First, the contents of the field ok_code
are assigned to the
auxiliary variable save_ok
, and ok_code
is initialized.
This procedure is always recommended since it makes sure that the screen field ok_code
is also reinitialized in the PBO event and does not contain any unintended value. The control structure
CASE
then assigns a text symbol to the output
field depending on the pushbutton chosen which is then displayed in the output field of the screen, or the program is quit when the Cancel button is chosen.