Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove extra blank spaces in a (string) sentence

Former Member
0 Kudos

Hi all,

I need to know , whether there is any command available

to remove the extra spaces in a String.

Thanks in advance,

Uday Kumar.

7 REPLIES 7

Former Member
0 Kudos

Use CONDENSE.

Bhupal

Former Member
0 Kudos

Use Keyword CONDENSE.

Former Member
0 Kudos

Hi,

The CONDENSE statement deletes redundant spaces from a string:

CONDENSE c [NO-GAPS].

This statement removes any leading blanks in the field c and replaces other sequences of blanks by exactly one blank. The result is a left-justified sequence of words, each separated by one blank. If the addition NO-GAPS is specified, all blanks are removed.

DATA: string(25) TYPE c VALUE ' one two three four',

len TYPE I.

len = strlen( string ).

WRITE: string, '!'.

WRITE: / 'Length: ', len.

CONDENSE string.

len = strlen( string ).

WRITE: string, '!'.

WRITE: / 'Length: ', len.

CONDENSE string NO-GAPS.

len = strlen( string ).

WRITE: string, '!'.

WRITE: / 'Length: ', len.

Output:

one two three four !

Length: 25

one two three four !

Length: 18

onetwothreefour !

Length: 15

Note that the total length of the field string remains unchanged, but that the deleted blanks appear again on the right.

Regards,

Vijetha.

Former Member
0 Kudos

Hello

CONDENSE

peter_ruiz2
Active Contributor
0 Kudos

hi,

you can use any of the following

CONDENSE field.
SHIFT field LEFT DELETING LEADING space.
SHIFT field RIGHT DELETING TRAILING space.

regards,

Peter

Former Member
0 Kudos

Go for CONDENSE command.

Former Member
0 Kudos

Hi Uday,

You can use CONDENSE command.The syntax is as below:

CONDENSE <c> [NO-GAPS].

This statement removes any leading blanks from the field <c> and replaces other sequences of blanks by exactly one blank. If the addition NO-GAPS is specified, all blanks are removed.

Regards,

Ashutosh