Adds to the end of the character field specified by Factor 1 (Prefix) the character field specified by Factor 2 (Suffix). The concatenated field is placed in the Result Field. Indicators are optional.
RPG Style Fixed Format:
PRE (Character Expression | *NONE)
SUF (Character Expression)
TARGET (Character Expression)
BLANK (Numeric Expression)
FILL (*NOPAD | *PAD)
TYPE (*None | *Char | *Packed | *Zoned)
LEN (Length Integer, [Decimal Integer])
The CAT operation concatenates the string specified in Factor 2 to the end of the string specified in Factor 1 and places it in the Result Field (TARGET). The source and target strings must all be of the same type, either all character or all graphic.
The SUF parameter (Factor 2) is required and must contain a string that may contain the number of blanks to be inserted between the concatenated strings. Its format is the string, followed by a colon, followed by the number of blanks.
If graphic strings are being concatenated, the blanks are double-byte blanks.
The string portion can contain one of: a field name, array element, named constant, data structure name, table name, literal, or data structure subfield name.
The number of blanks portion must be numeric with zero decimal positions, and can contain one of: a named constant, array element, literal, table name, or field name. If a colon is specified, the number of blanks must be specified. If no colon is specified, concatenation occurs with the trailing blanks, if any, in Factor 1, or the Result Field if Factor 1 is not specified. If the number of blanks, N, is specified, Factor 1 is copied to the Result Field left-justified. In Free Format, use the BLANK () parameter to specify the number of blanks. The number of blanks must be numeric with zero decimal places, and can be a literal, an array element, or field name. Leading blanks are never dropped.
The TARGET parameter (Result Field) is required and must be a string and can contain one of: a field name, array element, data structure name, or table name. It is always left justified and its length is the length of Factor 1 and Factor 2 combined, plus any intervening blanks. If it is not, truncation occurs from the right.
The PRE parameter (Factor 1) when used, must contain a valid Operand containing a character field.
If Factor 1 is not specified, Factor 2 is concatenated to the end of the Result Field string. Factor 1 can contain a string, which can be one of: a field name, array element, named constant, data structure name, table name, or literal.
If Factor 1 is not specified, the Result Field is used. The following references to Factor 1 apply to the Result Field if Factor 1 is not specified.
A P operation extender indicates that the Result Field should be padded on the right with blanks after the concatenation occurs, if the Result Field is longer than the result of the operation. Only the left-most part of the field is affected if padding is not specified.
Resulting indicators are optional. If specified, they are set just as if a COMP operation had executed, whether or not the condition in the operation code was satisfied. Avoid using indicators in this way, however, as they detract from the structure and readability of the program. This capability is provided only for compatibility with the AS/400 and System/38.
The TYPE parameter can be any of the Types listed (Character, Packed or Zoned). *NONE is the default. See Type Parameter for further information.
The LEN parameter defines the length of the field. If LEN is decimal (3,1) *ZONED is assigned as the default. If LEN is character (3), *CHAR is assigned as the default.
Depending upon the Type specified, the LEN parameter may be required. For instance, TYPES of *CHAR, *PACKED, *ZONED will require a LEN. A compiler message will display if the LEN parameter is needed.