Determine the length of the string. I'll call it STR-LEN
Subtract the length of the string from the length of the receiving variable.
Divide that by 2 and add 1.
Use the result as the position of the starting point of the sending string in the receiving field. I'll call it STR-POS
Move the string to the receiving variable using:
MOVE SPACES TO RECV-VAR
MOVE SEND-VAR(:STR-LEN) TO RECV-VAR(STR-POS:)
String len = 10
String pos = 16
Var len = 40
The move stmt will move the 10 byte string to pos 16 of the receiving field (leaving 15 leading spaces) and it will occupy pos 16 thru 25 there, leaving 15 trailing spaces.