PROTECT (Protect) keyword for display files

You use this record-level keyword with the OVERLAY keyword to specify that when the record you are defining is displayed, all input-capable fields already on the display are to be changed to output-only fields.

This protects them from input typing. This keyword does not affect the record format in which it is specified. The data contents of the affected fields are not changed, but your program cannot read them unless it first displays the record formats again in which the input-capable fields are specified.

To protect a single field from input typing, see the DSPATR(PR) keyword.

This keyword has no parameters.

The OVERLAY keyword must be specified in the record format in which PROTECT is specified. Also, either the OVERLAY keyword or the CLRL keyword must be in effect for PROTECT to be in effect.

You can use PROTECT to protect input-capable fields in other records only on the first output operation for which you have selected PUTOVR. On subsequent output operations, PROTECT is in effect only if the PUTOVR keyword is not in effect.

If the ERASEINP and PROTECT keywords are both in effect for an output operation, the IBM® i operating system first erases the input-capable fields specified on the ERASEINP parameter value, then protects all input-capable fields on the display from input typing.

A warning message appears at file creation time if the PROTECT keyword is specified on a record with the DSPMOD keyword. At run time, the PROTECT keyword is ignored when the display mode changes.

Option indicators are valid for this keyword.

Example

The following example shows how to specify the PROTECT keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RECORD1
00020A            FLD1           5   I  5  3
00030A
00040A          R RECORD2                   OVERLAY
00050A  32                                  PROTECT
00060A            FLDA          10   I  6  3
     A

In this example, RECORD1 has an input-capable field that has been displayed and read and that should be left on the display while RECORD2 is displayed and read. To prevent further entries in FLD1 in RECORD1, send an output operation to RECORD2 with PROTECT in effect. When this is done, FLDA is not protected, but FLD1 is protected.