Field validation specifications

The DDS keywords in this topic provide validation checks on input-capable fields on your display.

Using the DDS keywords with any hard-coded values that are language, country, or cultural-dependent makes duplication and modification of the DDS and the application program necessary.

Example: Validation checks

An example of field validation checks on input-capable fields on your display using the DDS keywords VALUES, COMP, and CHECK follows:

A     field-name   length type usage line pos  VALUES('Y' 'N')
or
A     field-name   length type usage line pos  COMP(EQ 'US$')
or
A     field-name   length type usage line pos  CHECK(M10 or M11)
(Modulus checking)
or
A     field-name   length type usage line pos  CHECK(RL)
(Right-to-left support)

Validation checks are provided according to the sort sequence defined for the display file at creation time. You can use the same DDS source file to create objects for different languages. For example, the following command creates a display object tagged with the Latin 1 sort sequence table:

CRTDSPF FILE(name) SRTSEQ(*LANGIDSHR) LANGID(DEU)

The following specification:

A     field-name   length type usage line pos  COMP(EQ 'a')

accepts all lowercase, uppercase, and accented characters, as defined by the shared-weight in the Latin 1 sort sequence.

In addition, note that all the checks specified using those DDS keywords are done by the data management function of the operating system. Any error message caused by wrong input or handling by the user appears in the language of the operating system. This can be the primary language or a secondary language, depending how the library list of the job is set up.

You can override this when you use the additional DDS keyword CHKMSGID (Check Message Identifier). This keyword allows you to specify your own customized messages and message file to be used by the checking routines of the operating system.

For example:

A     field-name   length type usage RANGE(1 999)
A                                    CHKMSGID(USR1234 [*libl/]APPMSGF [&MSGFLD1])
A     MSGFLD1      length type   P   TEXT('Message data field')

and   

ADDMSGD   MSGID(USR1234) MSGF(APPTXDENU/APPMSGF)
          MSG('Value &1; is out of range 1 to 999')
and   

ADDMSGD   MSGID(USR1234) MSGF(APPTXDDEU/APPMSGF)

MSG('Wert &1; ist ausserhalb des g U umlaut character ltigen Bereichs 1 bis 999')

To use different message files of different library names, do not specify a fixed library name. You can use a message file for different languages by setting the library list when you run the program.

Related concepts
RANGE (Range) keyword
VALUES (Values) keyword
CMP (Comparison) keyword
CHECK (Check) keyword
CHKMSGID (Check Message Identifier) keyword