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

Replace double space by single space

Former Member
0 Likes
4,668

Hi all,

Can anybody please tell me how we can replace double space by single space.

For example

Here double space between D and X -> 'ABCD XY GHU'

Should be like this -> 'ABCD XY GHU'

I have tried

WHILE l_value CA ` `.

REPLACE ` ` WITH space INTO l_value.

ENDWHILE.

and

WHILE l_value CA ' '.

REPLACE ' ' WITH space INTO l_value. "SGA 2A015857

ENDWHILE.

But its not working and giving dump.

Please try to help me out.

Thanks & Regards

Swati

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,136

Hi Swati,

Declare a constant varable with value 2 spaces and do like this

CONSTANTS: c_space(2) type c value ' '.

REPLACE c_space WITH space INTO l_value.

Try this

CONDENSE l_value.

Regards,

Satish

Edited by: Satish Panakala on Apr 10, 2008 2:12 PM

5 REPLIES 5
Read only

Former Member
0 Likes
2,137

Hi Swati,

Declare a constant varable with value 2 spaces and do like this

CONSTANTS: c_space(2) type c value ' '.

REPLACE c_space WITH space INTO l_value.

Try this

CONDENSE l_value.

Regards,

Satish

Edited by: Satish Panakala on Apr 10, 2008 2:12 PM

Read only

ThomasZloch
Active Contributor
2,136

use the statement CONDENSE, it does exactly what you want here.

Cheers

Thomas

Read only

Sm1tje
Active Contributor
0 Likes
2,136

You can do a split at space into an internal table and next concatenate all valid entries (the ones which CA sy-abcde) into an new field separated by space.

Read only

Former Member
0 Likes
2,136

Hi,

try this:

data: txt(20) value 'AAA VVV TT'.

*

write: txt.

*

condense txt.

*

write: txt.

Regards, Dieter

Read only

vinod_vemuru2
Active Contributor
0 Likes
2,136

Hi Swaiti,

U can use CONDENSE statement. This will remove all extra spaces i.e. keeps one space between words.

l_value = 'ABCD XY GHU'.

WRITE:/1 l_value.

CONDENSE l_value.

WRITE:/1 l_value.

Thanks,

Vinod.

Edited by: Vinod Kumar Vemuru on Apr 10, 2008 6:48 PM

Edited by: Vinod Kumar Vemuru on Apr 10, 2008 6:53 PM