SUBTO pseudovariable

The SUBTO pseudovariable assigns a string value to a substring, specified by y and z, of x. The remainder of x is unchanged. Assignments to a varying string do not change the length of the string.

Read syntax diagramSkip visual syntax diagramSUBSTR( x, y, z)
x
String-reference. x must not be a numeric character.
y
Expression that can be converted to a FIXED BINARY value which specifies the starting position of the substring in x.
z

Expression that is converted to FIXED BINARY(31,0). z specifies the ending position of the substring in x. If z = y-1, a null string is returned. If z is omitted, the substring assigned is position y in x to the end of x.

SUBTO(x,y) is equivalent to SUBSTR(x,y), and SUBTO(x,y,z) is equivalent to SUBSTR(x,y,z-y+1).

When the STRINGRANGE condition is disabled, an assignment to SUBTO(x,y,z) assigns a string with starting position y and ending position z. If z > MAXLENGTH(x), the program is invalid and data past the end of x will be overwritten.