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: 

Replace double space by single space

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

ThomasZloch
Active Contributor

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

Cheers

Thomas

Sm1tje
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi,

try this:

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

*

write: txt.

*

condense txt.

*

write: txt.

Regards, Dieter

vinod_vemuru2
Active Contributor
0 Kudos

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