Processing Input/Output Fields

Input/output fields are either conventional fields in which the user can enter values using the keyboard or by selecting from a value list, or checkboxes or radio buttons, for which the mouse is required. All input/output fields have a name that associates them with a dynpro field. The data type of the dynpro field determines the input format. For example, letters cannot be entered in an input field with a numeric type. The dynpro detects invalid values automatically. Radio buttons and checkboxes always have the data type char and length 1. A selected radio button or checkbox has the value ‘X’, when empty, both have the value space.

The ABAP program must contain identically named data objects that match the dynpro fields exactly, otherwise data may be lost (see Associating ABAP Strings with Dynpro Fields). The ABAP data types that correspond to the screen data types are listed in a table in the Data Types in the ABAP Dictionary section. The ABAP fields for checkboxes and radio buttons must have type c and length one.

After the PBO event has been processed, the screen fields are filled with the values from the ABAP fields. Before or during the PAI event, the values from the screen fields are written to the ABAP fields. Only one radio button within a group can be selected at a time. If more than one of the associated fields contains the value 'X', the program terminates.

To ensure that screen fields and ABAP fields always correspond exactly, use the following procedure.

Local Program Fields

If input/output fields are to be used in one program only, the fields should be declared in the ABAP program first (except for checkboxes and radio buttons), then the program activated, and finally the fields applied from the ABAP program to the dynpro in Screen Painter. Afterwards, however, you must avoid changing the fields in the ABAP program.

Dynpro Fields with Dictionary Reference

If input/output fields are required in more than one program and information from the ABAP Dictionary is required, such as field labels, field helps, and input helps, the corresponding fields should be applied from ABAP Dictionary. Both flat structures and database tables can be referenced here.

You must then declare identically-named fields as an interface work area in the ABAP program using the TABLES statement. Declaring an identically-named field using a TYPES reference to the data type in the ABAP Dictionary is insufficient for data to be transferred between the screen and the ABAP program.

To avoid naming conflicts between screen fields, work areas in programs, and database tables, it is often worth defining your own ABAP Dictionary structure for screens, containing all of the input/output fields you want to use for one or more screens of a program, or even for a whole package. The work areas that you declare with TABLES in the ABAP program then function exclusively as an interface between the program and the screen. If necessary, you can assign values between program fields and the interface work area.

The advantage of referring to ABAP Dictionary data types is that both the screen fields and the fields in the ABAP program are updated automatically if the data type changes.

Name

Type

defLg

Format

input

I/O

9

INT4

output

I/O

11

INT4

radio1

Radio

1

CHAR

box1

Check

1

CHAR

radio2

Radio

1

CHAR

box2

Check

1

CHAR

radio3

Radio

1

CHAR

box3

Check

1

CHAR

exit

Check

1

CHAR

OK

20

OK