04-10-2008 2:03 PM
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
04-10-2008 2:07 PM
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
04-10-2008 2:07 PM
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
04-10-2008 2:07 PM
use the statement CONDENSE, it does exactly what you want here.
Cheers
Thomas
04-10-2008 2:09 PM
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.
04-10-2008 2:13 PM
Hi,
try this:
data: txt(20) value 'AAA VVV TT'.
*
write: txt.
*
condense txt.
*
write: txt.
Regards, Dieter
04-10-2008 2:17 PM
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