I assume you don't know the length of the non-blank content of your symbol.
In my example this content is stored in variable ws-symbol.
The output will be stored in ws-symbol-dynamic.
The field ws-count is for counting the non-blank characters in ws-symbol.
05 ws-symbol pic x(12).
05 ws-count pic 9(02) binary.
05 ws-symbol-dynamic pic x(39).
move 'ABCDE' to ws-symbol
move zero to ws-count
move space to ws-symbol-dynamic
inspect ws-symbol tallying ws-count
before initial space
string '<symbol>' delimited by size
ws-symbol(1:ws-len) delimited by size
'</symbol>' delimited by size
After executing this code the field ws-count contains 5 and the field ws-symbol-dynamic contains '<symbol>ABCDE</symbol>' padded at the right with 17 blanks.
This technique only works if your character string has no blanks imbedded.
If you want to handle this too, you might loop through your string from the end to the beginning tallying all blanks until you find a non-blank character. Then subtract the counter from the total field length. This will be then the value for ws-count and you can run the STRING statement from the above example again.
Hope that helps.
There are 10 types of people in the world: Those who understand binary, and those who don't.