Application Development and Automation 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: 
Read only

Remove extra blank spaces in a (string) sentence

Former Member
0 Likes
16,771

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
Read only

Former Member
0 Likes
8,954

Use CONDENSE.

Bhupal

Read only

Former Member
0 Likes
8,954

Use Keyword CONDENSE.

Read only

Former Member
0 Likes
8,954

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.

Read only

Former Member
0 Likes
8,954

Hello

CONDENSE

Read only

peter_ruiz2
Active Contributor
0 Likes
8,954

hi,

you can use any of the following

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

regards,

Peter

Read only

Former Member
0 Likes
8,954

Go for CONDENSE command.

Read only

Former Member
0 Likes
8,954

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