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: 

Remove space

Former Member
0 Kudos

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!

6 REPLIES 6

Former Member
0 Kudos

Hi,

use CONDENSE statement

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

Regards,

Omkar.

Former Member
0 Kudos

hi

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

regards'

karthik

Former Member
0 Kudos

use following line of code...

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

Former Member
0 Kudos

try this,

x type string value 'ak fkfg'.

CONDENSE x NO-GAPS.

reward points if useful.

Regards,

Vimal

Former Member
0 Kudos

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.

Former Member
0 Kudos

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|