There are two special variants of the FIELD statement that you can use in PAI processing to check the values of screen fields in the screen flow logic. However, this method is obsolete and should no longer be used. It is only supported for compatibility reasons.
Checking a Value List
You can check a screen field against a value list as follows:
FIELD f VALUES ( v 1 , v 2 ,...).
The individual entries v 1 , v 2 ,... in the list can have the following format:
[NOT] BETWEEN val1 AND val2
You can check against single fields val or intervals between val1 and val2. The comparison fields must have the value range of data type CHAR or NUMC, must be enclosed in inverted commas, and must be written in uppercase. If the check fails, an error message is displayed and the corresponding field is again ready for entry.
The input help for f can also use the value list in the FIELD statement. This helps the user to enter only correct values.
The functions of the FIELD statement for controlling data transport also apply when you use the VALUES addition.
Checking Against Database Tables
You can compare a screen field with a database table follows:
FIELD f SELECT * FROM dbtab WHERE k1 = f1 AND k2 = f2 AND... [INTO tables_area] WHENEVER [NOT] FOUND SEND ERRORMESSAGE|WARNING [num [WITH h1 ... h4]].
The FIELD statement is combined with a SELECT statement. The syntax of the SELECT statement must be entered exactly as shown above. In the WHERE condition, no comparison operators other than the equals sign (=) are allowed, not even EQ. In the WHERE condition, the fields of the primary key k 1 k 2 ... of the database table dbtab are checked against the screen fields f 1 f 2 .... If a matching entry is found, you can write it into the table work area of a screen field, which was defined by transfer from the ABAP Dictionary. You can also send an error or warning message depending on the outcome of the search, which makes the input field for f ready for input again.
num allows you to specify a message number from the message class specified in the MESSAGE-ID addition of the first statement in the program. In this case, the message class can only be two characters long. If you do not specify a message class, the system displays a default message. If you use WITH, you can pass literals or screen fields to any placeholders ( &) within the message.
The input help for f can also use the SELECT statement after FIELD. This helps the user to enter only correct values.
You can also use the SELECT statement in screen flow logic without combining it with the FIELD statement. This allows you to fill screen fields with the contents of database tables without calling ABAP modules. The functions of the FIELD statement for controlling data transport also apply when you use SELECT.
Checking Inputs in the Screen Flow Logic
PROGRAM demo_dynpro_value_select MESSAGE-ID dw. DATA: ok_code TYPE sy-ucomm, carrier TYPE spfli-carrid, connect TYPE spfli-connid. CALL SCREEN 100. MODULE init_screen_0100 OUTPUT. SET PF-STATUS 'STATUS_100'. ENDMODULE. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE module_1 INPUT. MESSAGE i888(sabapdocu) WITH text-001 carrier text-002 connect. ENDMODULE. MODULE module_2 INPUT. MESSAGE i888(sabapdocu) WITH text-001 carrier text-002 connect. ENDMODULE.
The next screen (statically defined) for screen 100 is 100. It has the following layout:
The program fields carrier and connect are assigned to the input fields. The function code of the pushbutton is EXECUTE.
In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE.
The screen flow logic is as follows:
PROCESS BEFORE OUTPUT. MODULE init_screen_0100. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. FIELD carrier VALUES (NOT 'AA', 'LH', BETWEEN 'QF' AND 'UA'). MODULE module_1. FIELD connect SELECT * FROM spfli WHERE carrid = carrier AND connid = connect WHENEVER NOT FOUND SEND ERRORMESSAGE 107 WITH carrier connect. MODULE module_2.
The user must enter a value for carrier that is in the list following VALUES before module_1 is called. When module_1 is called, connect has not yet been transported.
Next, the user can only enter a value for connect that exists in the database table SPFLI as part of a primary key together with carrier. If not, error message 107 from message class AT is displayed in the status bar:
E: Unable to find any entries for key & &.
Only when a correct value has been entered will connect be transported and module_2 called.