The CHANGE subparameter changes an input field to a replacement value in the reformatted output record if a specified field equals a search constant.
The format of the CHANGE subparameter is shown below:
Multiple search-replacement paired values, with different data formats, can be specified on a CHANGE subparameter. Note the following rules for mixing data formats:
-
Search constants are character, hexadecimal, or binary strings. Multiple search constants on a CHANGE subparameter can be a mixture of character and hexadecimal formats. Binary search constants cannot be mixed with search constants of other formats; thus, if one search constant on a CHANGE subparameter is binary, all other search constants on that subparameter must also be binary.
-
Replacement values are either character or hexadecimal string constants or a field from the input record. Multiple replacement constants on a CHANGE subparameter can be a mixture of character and hexadecimal string constants and fields from the input record.
-
The constants of a search-replacement pair can be of different data format. For example, a hexadecimal or binary search constant could be paired with a character replacement constant, or a character search constant could be paired with a hexadecimal replacement constant. Thus, you could change a hexadecimal or binary input field to a character output field, or you could change a character input field to a hexadecimal output field.
p,l |
The normal MFX position-length designation that specifies the search field. When this search field matches a search constant, the input field will be changed in the output to a replacement value. For character or hexadecimal search constants, the search field can be 1 to 64 bytes long. For binary search constants, the search field must be one byte. |
||||||
%pp |
Identifies a fixed-length parsed field that specifies the search field. When this field matches a search constant, the input field will be changed in the output to a replacement value. |
||||||
o |
The length of the output replacement field. Permissible length is 1 to 64 bytes. |
||||||
srch |
The search constant to which the search field is compared. Permissible formats are character string (C'x...x'), hexadecimal string (X'x...x'), or a binary byte (B'bbbbbbbb'). When the search constant matches the search field, the input field will be changed to an output replacement value. If one of the search constants is binary in a set of search-replacement pairs on a CHANGE subparameter, then all the search constants on that CHANGE subparameter must be binary. (For additional information on using binary fields in INCLUDE/OMIT processing, see INCLUDE/OMIT Control Statement.) If the search constant is longer than the length of the search field, the constant will be truncated to the length of the search field. If the search constant is shorter, the constant will be padded on the right. Character strings are padded with blanks (X'40'). Hexadecimal strings are padded with zeros (X'00'). Binary strings are neither truncated nor padded since only one-byte strings are permissible. |
||||||
repl |
The replacement value to which the input field is changed in the reformatted output record when the search field matches a search constant. The replacement value can either be a constant, a field from the input record, or a fixed-length parsed field. The term repl represents the following syntax:
Figure 2. Syntax of repl
|
||||||
NOMATCH |
Indicates how MFX should respond if the input field does not match a search constant. If NOMATCH is not specified and no search constant matches the input field, sort processing will terminate with an error message. |
||||||
nmrepl |
A replacement constant to which the input field is changed in the reformatted output record when the search field p,l fails to match a search constant. For details, see the description of the repl variable above. |
||||||
r,n |
The position r and length n of an input field that will be inserted in the output record when the CHANGE search field fails to match a search constant. n must be at least 1. If n is greater than the length o specified for the output replacement field, the output field r,n will be truncated on the right to length o. If n is less than o, the field r,n will be padded on the right with blanks (X'40') to the length o. |
||||||
%pp |
Identifies a fixed-length parsed field that will be inserted in the output record when the CHANGE search field fails to match a search constant. The length of %pp specified by FIXLEN cannot be greater than the length o specified for the output replacement field. If FIXLEN is less than o, the %pp field will be padded on the right with blanks (X'40') to the length o. |
In the above example, the FIELDS parameter contains two CHANGE subparameters. The first CHANGE subparameter changes the input field in columns 1 through 13 to a state name in the reformatted output record when the search field in column 16 matches a state code. If the state code is XX, positions 50 through 62 of the input record will be placed in the output record. If no matches are found, the output field will be 'NOT SUPPORTED.' The second change subparameter changes the one-byte input field in column 22 to 'EAST COAST' or 'WEST COAST' in the reformatted output record, depending on the binary contents of the search field in column 24.
Note that in the above example, the search field X'06' would match both binary search constants. In such cases, the first search constant is used, thus the output would be the character string 'SHARE'. If the search field were X'02', the output would be the character string 'UNIQUE'.