KFLD (Define Parts of a Key)
Free-Form Syntax | (not allowed - use %KDS) |
Code | Factor 1 | Factor 2 | Result Field | Indicators | ||
---|---|---|---|---|---|---|
KFLD | Indicator | Key field |
The KFLD operation is a declarative operation that indicates that a field is part of a search argument identified by a KLIST name.
The KFLD operation can be specified anywhere within calculations, including total calculations. The control level entry (positions 7 and 8) can be blank or can contain an L1 through L9 indicator, an LR indicator, or an L0 entry to group the statement within the appropriate section of the program. Conditioning indicator entries (positions 9 through 11) are not permitted.
KFLDs can be global or local. A KLIST in a cycle-main procedure can have only global KFLDs associated with it. A KLIST in a subprocedure can have local and global KFLDs. For more information, see Scope of Definitions.
Factor 2 can contain an indicator for a null-capable key field if ALWNULL(*USRCTL) is specified as a keyword on a control specification or as a command parameter.
If the indicator is on, the key fields with null values are selected. If the indicator is off or not specified, the key fields with null values are not selected. See Keyed Operations for information on how to access null-capable keys.
The result field must contain the name of a field that is to be part of the search argument. The result field cannot contain an array name. Each KFLD field must agree in length, data type, and decimal position with the corresponding field in the composite key of the record or file. However, if the record has a variable-length KFLD field, the corresponding field in the composite key must be varying but does not need to be the same length. Each KFLD field need not have the same name as the corresponding field in the composite key. The order the KFLD fields are specified in the KLIST determines which KFLD is associated with a particular field in the composite key. For example, the first KFLD field following a KLIST operation is associated with the leftmost (high-order) field of the composite key.
Graphic and UCS-2 key fields must have the same CCSID as the key in the file.
Figure 1 shows an example of the KLIST operation with KFLD operations.
Figure 2 illustrates how keyed operations are used to position and retrieve records with null keys.
For more information, see Declarative Operations.