When used on the left-hand side of an expression, %STR(ptr:length) assigns the value of the right-hand side of the expression to the storage pointed at by the pointer, adding a null-terminating byte at the end. If the length specified as the second parameter of %STR is N, then at most N-1 bytes of the right-hand side can be used, since 1 byte must be reserved for the null-terminator at the end.
The maximum length that can be specified is 65535. This means that at most 65534 bytes of the right-hand side can be used, since 1 byte must be reserved for the null-terminator at the end.
The length indicates the amount of storage that the pointer points to. This length should be greater than the maximum length the right-hand side will have. The pointer must be set to point to storage at least as long as the length parameter. If the length of the right-hand side of the expression is longer than the specified length, the right-hand side value is truncated.
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
D String1 S *
D Fld1 S 10A
/FREE
%str(String1: 25)= 'abcdef';
// The storage pointed at by String1 now contains 'abcdef¬'
// Bytes 8-25 following the null-terminator are unchanged.
%str (String1: 4) = 'abcdef';
// The storage pointed at by String1 now contains 'abc¬'
/END-FREE