The LENGTH function returns the length of a character text string.
Category
String
Syntax
LENGTH(data_string)
Parameter and Description
Parameter | Description |
---|---|
data_string | This parameter specifies a data string in character format. This data string can be a field from a source datastore, a variable or the result of another Function. |
Example
The length of source field SRC_FLD1 into target field LEN_FLD1. Assume that the length of the source field is 18.
LEN_FLD1 = LENGTH (SRC_FLD1)
Returns the value 18 and maps the result to the target field.
Examine the length of source field SRC_FLD1
. If the length is less than 5, map it to target field TGT_FLD1
unchanged. Otherwise, map only the first 4 bytes into TGT_FLD1
.
OUTPUT_STRING = LEFT ('ABCDEFGHIJK', 2)
Returns the value AB and maps the result to the target field.
Examine a source data string INPUT_STRING and map the leftmost 8 characters to the target field OUTPUT_STRING.
IF LENGTH(SRC_FLD1) < '5'
{
TGT_FLD1 = SRC_FLD1
}
ELSE
{
TGT_FLD1 = LEFT(SRC_FLD1, 4)
}