Here's one method using SUBSTR. Loop through your string a character at a time, and build a new string based on the non-blank characters.
-* Set initial value to be parsed
-SET &FIELD = ' 12 3 xxx 456 7 8 9 ';
-* Get the length of the field
-SET &FIELD_LEN = &FIELD.LENGTH;
-* Set the field format
-SET &FIELD_FMT = 'A' | &FIELD_LEN;
-* Initialize the field that will store the parsed field
-SET &NEWSTR = '';
-* Initialize the loop index
-SET &IDX = 1;
-* Iterate through the number (&FIELD)
-REPEAT :ENDLOOP WHILE &IDX LE &FIELD_LEN;
-* Get the next character in the string
-SET &CHARACTER = SUBSTR(&FIELD_LEN, &FIELD, &IDX,
- &IDX, 1, 'A1');
-* If a non-blank is found, append it to the new
-* string, otherwise do nothing
-SET &NEWSTR = IF (&CHARACTER NE ' ') THEN &NEWSTR || &CHARACTER
-ELSE &NEWSTR;
-* Advance to the next character
-SET &IDX = &IDX + 1;
-:ENDLOOP
-* Remove trailing space
-SET &NEWSTR = TRUNCATE(&NEWSTR);
-* Here's the final value
-TYPE NEWSTR: (&NEWSTR)
------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode