Data Edits

The commands in this section are optional. The following command pair defines the beginning and the ending of the data edit section.

$EDITS FormName FormType 
$END-EDITS FormName FormType

If used, FormName and FormType must be the same as those entered next to the $FORM command. However, they are not required.

The data edits section defines a default value and a list of valid values (value list) for input fields on the form. When you transmit a form, input fields are edited against the value list and an error returns if you type an invalid value. If you do not type a value in a field, its default value substitutes during input.

The data edits section also defines translation values for all fields that have a type X. For more information, see Field Type.

A data edits definition consists of the following items in a fixed columnar format. Each record in this section must have either a default value, an edit list, or both. Positions not listed are blank.

Position Definition See this section
3-24 Field name Field Name
25-44 Default value Default Value
47-80 Value list Value List

Field Name

The field name must be one of the 4GL field names defined in the Transaction Data section. The field must be an input field or a field that has a type X. You must list all fields that have a type X in the Data Edits section. The form compiler flags any missing fields as errors.

List a field only once. When the value list for a field continues on another record, do not repeat the field name on that record. The fields listed here must be in the same order as in the Transaction Data section.

For more information, see Transaction Data Section.

Default Value

The default value for a field can be up to 20 characters long. The default value you assign to the field displays if the user does not enter a value. You cannot define a default value for signed numeric fields or fields that are longer than 20 characters.

You can define a coded default value for date and time fields. The coded value @TD moves the current date to a date field (type F).

The coded value @CT moves the current time to a time field.

To default the value of one field from the value of another field, type the coded value

@KN KeyNumber

where KeyNumber is the key number of the field whose value you want to move to the current field. When you type this coded value on a line field, the field defaults from the last value entered on a previous line.

You do not have to include the default value in the value list. This allows a valid default value that the user cannot type in a field.

Value List

The value list defines the valid values for a field. It also defines a translation for each value, if one exists. To define a value or translation for a field, use the format

Value = Translation

Value is a valid value for the field. Translation is the description of the value. Translation is required only for fields that have a type X because they display the translation instead of the value. The standard, however, is to include the translation if it exists.

In the following example, if the 4GL field type for the GLM-ACTIVE-STATUS field (RPG field name suffix: GLMACT, RPG database field name: DGLMACTSTT) is X, the form displays Active or Inactive. If the field type is A, the form displays A or I.

GLM-ACTIVE-STATUS
A=Active
I=Inactive

To define a foreign language value or translation, use the format

Value ^ DisplayValue = Translation

Value is the database value for that field. DisplayValue is the value you want the form to display for that database value. Translation is optional except for type X fields. The following definition displays the German translation for GLM-ACTIVE-STATUS (RPG field name suffix: GLMACT, RPG database field name: DGLMACTSTT)—"A" or "I" if the field type is A, Aktiv or Inaktiv if the field type is X

GLM-ACTIVE-STATUS 
A^A=Aktiv
I^I=Inaktiv

You can list values individually or in a range. Range checking is more efficient than checking for individual values. To define a range of values, separate the low and high values in the range with a colon (:). A set of range values includes the low value and the high value in the range. A value list can contain a mix of value types. For example, to edit a two-digit numeric field for the values 1, 2, 3, . . . 20, 45, and 72, type the value list

1:20
45
72

Ranges are not limited to numeric values. For example, to edit a two-character field for the values A0, A1, A2, . . . A9, enter the value list

A0:A9

You can list values and ranges on the same record but you must separate them with a comma. The standard is to list each value or range on a separate record. Because the comma (,) and colon (:) separate values in a value list, they cannot be valid field values.

Numeric fields are left-filled with zeroes, and alphabetic fields are right-filled with blanks. For example, if a field is four characters long, the values ABC, DEF, and STOP are equivalent to ABC_, DEF_, and STOP ( _ represents a blank).