Supported RPG Features

%STR works in both directions. As an expression it reads the characters a pointer addresses, up to but not including the first null byte. As the target of an assignment it stores a value and adds the null terminator:

DCL-S p POINTER;
p = %ALLOC(20);

%STR(p : 20) = 'abcdef';   // storage now holds 'abcdef' + a null byte
DSPLY %STR(p);             // abcdef

The store works as follows:

The pointer operand is any pointer expression, so it composes with pointer arithmetic - %STR(p + 3 : 10) = 'xy' stores three bytes in.