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

Remove space

I have a string which value is 'abc eee bbb ccc'. I would like to remove all space and the result is abceeebbbccc. How can i do that. Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 06:51 AM

    Hi,

    use CONDENSE statement

    <b>CONDENSE V_STR NO-GAPS.</b>

    Regards,

    Omkar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 06:51 AM

    hi

    try to use <b>condense -- no gaps</b>

    regards'

    karthik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 06:52 AM

    use following line of code...

    REPLACE ALL OCCURANCES OF ' ' IN STR1 WITH ''.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 06:54 AM

    try this,

    x type string value 'ak fkfg'.

    CONDENSE x NO-GAPS.

    reward points if useful.

    Regards,

    Vimal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 07:18 AM

    Hi, Portfolio.

    I found this in SAP Library, hope this can help you.

    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) 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,

    feng.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 07:27 AM

    data : str type string value 'kiran kumar'.

    condense str no-gaps.

    write:/ str.

    i will check this code this is working.plz check it once.

    ANOTHER TYPE:

    DATA: FIELD(10) VALUE 'abcde'.

    WRITE: / '|' NO-GAP, FIELD LEFT-JUSTIFIED NO-GAP, '|',

    / '|' NO-GAP, FIELD CENTERED NO-GAP, '|',

    / '|' NO-GAP, FIELD RIGHT-JUSTIFIED NO-GAP, '|'.

    • Output: |abcde |

    • | abcde |

    • | abcde|

    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.