Skip to Content
author's profile photo Former Member
Former Member

Replace double space by single space

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 10, 2008 at 01:07 PM

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

    Cheers

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 10, 2008 at 01: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 01:13 PM

    Hi,

    try this:

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

    *

    write: txt.

    *

    condense txt.

    *

    write: txt.

    Regards, Dieter

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 10, 2008 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.