$SUBSTR returns an alphanumeric expression that is part (or all) of another alphanumeric expression.
This function has the following format:
$SUBSTR (alpha‑expression [,START=start][,LENGTH=len])
Defines an alphanumeric expression.
Defines a numeric expression to be extracted whose value is the starting position of the alphanumeric expression. It cannot be a nullable expression. If the start value exceeds the length of the alphanumeric expression, then a null value is returned (a value of length 0). If assigned to an alphanumeric field, the field attains a value of all spaces according to the usual padding rules for SET or MOVE. The default start position is 1. If the start value is less than 1, 1 is assumed.
Identifies the number of characters to extract from the alphanumeric expression beginning at the start. You must specify the length as a numeric expression. It cannot be a nullable expression. If you omit len, all characters from the start to the end of the alphanumeric expression are extracted. If the value of len exceeds the remaining length of the alphanumeric expression, then the remaining length is used. If the len value is less than 1, a null value is returned (see START).
The start and length parameters are optional. You can use them independently of each other. You can use them in either order.
You must define a numeric field specified for the start or length parameter with integer digits only. When you specify any other kind of numeric expression, if the value is not a whole number, the integer portion is used.
Examples
Assume that A is a 16‑character alphanumeric and B is a five‑character alphanumeric.
SET A = 'THESE THREE WORDS' SET B = $SUBSTR (A,START=7,LENGTH=5) :result B='THREE'
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|