The below code snippet helps in trims the blank spaces in the text. Where as LTrim() and RTrim() removes the blank spaces in Left and Right side of the text. To remove the blank spaces between a string this code snippet is very useful. The below snippet replaces upto 1 to 10 blank spaces to single space. If your string has more than 10 then increase the value in AutoGenerate().
MAPPING LOAD repeat(' ', RecNo()), ' '
AutoGenerate 10 // up to 10 spaces
MapSubString('SpaceMap', trim(' XXXX YYY ZZ')) as y