Entering content frame

Checkboxes and Radio Buttons with Function Codes Locate the document in its SAP Library structure

In the Screen Painter, you can assign a function code (up to 20 characters long) to checkboxes and radio buttons.

Checkboxes and radio buttons without a function code behave like normal input/output fields. Clicking the object changes the contents of the field, but does not trigger the PAI event. (Clicking a pushbutton, on the other hand, always triggers the PAI event, even if it has an empty function code.)

When a function code is assigned to a checkbox or radio button, clicking it not only changes the field contents, but also triggers the PAI event and places the function code in the OK CODE field. For further information, refer to Evaluating Function Codes.

While it is possible to assign an individual function code to each checkbox, you can only assign one function code to all of the radio buttons in a group. When you assign a function code to a radio button in the Screen Painter, the system automatically applies the same function code to all of the other radio buttons in the group.

You can use checkboxes and radio buttons with function codes as follows:

·        For processing parts of screens (context-sensitive processing). For example, only when a radio button or checkbox is selected is particular data read and placed in the corresponding input/output fields.

·        You can fill fields with patterns depending on checkboxes or radio buttons. A typical example would be formatting settings for letters. The input fields can all be processed separately, but it is possible to fill all input fields simultaneously and consistently by choosing a pattern.

·        You can control dynamic screen modifications directly using checkboxes or radio buttons. For example, you can make sure that an input/output field cannot accept input until the user selects a radio button.

As when you create pushbuttons, you should ensure when you assign function codes to checkboxes and radio buttons that they do not coincide with function codes from the GUI status.

Example

PROGRAM demo_dynpro_check_radio.

DATA: radio1(1) TYPE c, radio2(1) TYPE c, radio3(1) TYPE c,
      field1(10) TYPE c, field2(10) TYPE c, field3(10) TYPE c,
      box TYPE c.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

CALL SCREEN 100.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'RADIO'.
      IF radio1 = 'X'.
        field1 = 'Selected!'.
        CLEAR: field2, field3.
      ELSEIF radio2 = 'X'.
        field2 = 'Selected!'.
        CLEAR: field1, field3.
      ELSEIF radio3 = 'X'.
        field3 = 'Selected!'.
        CLEAR: field1, field2.
      ENDIF.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.

The next screen (statically defined) for screen 100 is 100. It has the following layout:

This graphic is explained in the accompanying text

The part of the element list relevant for the screen fields is as follows:

Name

Type

defLg

Format

Function Code

radio1

Radio

1

CHAR

RADIO

field1

I/O

10

CHAR

 

radio2

Radio

1

CHAR

RADIO

field2

I/O

10

CHAR

 

radio3

Radio

1

CHAR

RADIO

field3

I/O

10

CHAR

 

box

Check

1

CHAR

CANCEL

ok_code

OK

20

OK

 

The input option for the screen fields field1 to field3 has been switched off in the Screen Painter.

The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.

PROCESS AFTER INPUT.
  MODULE user_command_0100.

Each time you select one of the three radio buttons, the PAI event is triggered and the function code RADIO and the contents of the screen fields are passed to the ABAP program. The dialog module user_command_0100 fills the fields field1 to field3 according to the radio button that was selected. These field contents appear the next time the screen is sent.

The PAI event is also triggered if you select the checkbox. In this case, the function code CANCEL is passed to the ABAP program, and the dialog module user_command_0100 terminates the program immediately.

 

 

Leaving content frame