Remove blank spaces between a string

    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().

     

     

    SpaceMap:

    MAPPING LOAD repeat(' ', RecNo()), ' '

    AutoGenerate 10  // up to 10 spaces

    ;

     

    LOAD

    MapSubString('SpaceMap', trim('      XXXX     YYY     ZZ')) as y

    AutoGenerate 1;

     

     

    Hope this helps others.

     

    Regards,

    Jagan.