Pushbuttons in the Application Toolbar 

You can create up to five pushbuttons in the application toolbar on the selection screen. Function keys are automatically assigned to these pushbuttons.

SELECTION-SCREEN FUNCTION KEY <i>.

<i> must be between 1 and 5. You must use the FUNCTXT_0<i> components of structure SSCRFIELDS for the individual pushbutton texts. You must declare this structure as an interface work area using the TABLES statement.

If the user clicks a pushbutton, function code FC0<i> of component UCOMM is assigned to structure SSCRFIELDS. The function code can be analyzed during the AT SELECTION-SCREEN event.

REPORT DEMO.

TABLES SSCRFIELDS.

DATA FLAG.

SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW TITLE TIT.
  SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.
SELECTION-SCREEN END OF SCREEN 500.

AT SELECTION-SCREEN.
  CASE SY-DYNNR.
    WHEN '0500'.
      IF SSCRFIELDS-UCOMM = 'FC01'.
        FLAG = '1'.
      ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
        FLAG = '2'.
      ENDIF.
  ENDCASE.

START-OF-SELECTION.

  SSCRFIELDS-FUNCTXT_01 = 'Button 1'.
  SSCRFIELDS-FUNCTXT_02 = 'Button 2'.
  TIT = 'Buttons'.

  CALL SELECTION-SCREEN 500 STARTING AT 10 10
ENDING AT 10 11.

  IF FLAG = '1'.
    WRITE / 'Button 1 was clicked'.
  ELSEIF FLAG = '2'.
    WRITE / 'Button 2 was clicked'.
  ENDIF.

This example program defines a user-defined selection screen as a modal dialog box, containing two pushbuttons in the application toolbar with the texts ‘Button 1’ and ‘Button 2’.

When the user clicks one of the buttons, the AT SELECTION-SCREEN event is triggered, and the FLAG field is set there. The contents of the FLAG field can be further processed during subsequent program flow after the user has chosen Execute.