The SST() built-in functions extracts the specified substring of the session variable or string.
The SST built-in function works like the SQL SUBSTR() UDF, RPG %SUBST built-in function, and the %SST CL built-in function. It works on either the right and left side of the assignment statement, or it can be used in conditional statements.
- Variable or quoted character string expression.
- The starting position within the character string.
- The Length of the subscripted result or target. If this parameter is omitted the substring continues through the end of the field.
eval &COMP = 'The Acme Tool Co.';
eval &Name = sst(&comp,5,4);
eval sst(&comp,5,4) = 'USA Mfg';
#msg The old name was: &name
#msg The new Company name is: &comp
The output written to the joblog is:
The old name was: Acme
The new Company name is: The USA Tool Co.
The output only changed positions 5, 6, 7, and 8 due to the length of 4 being specified