Application Development and Automation 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: 
Read only

replacing space with comma

Former Member
0 Likes
1,680

hi all,

just help in replacing emty space ' 'with '.'

i used replace ' ' with '.' into b.

but its not replacing all empty spaces

b is hoding ====188 445 32

i need it like 188.445.32

plz help me

vamsee

7 REPLIES 7
Read only

Former Member
0 Likes
1,155

Hi,

Use " REPLACE ALL OCCURANCES"

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,155

Hello Vamsee,

I think you have to use the string literal ` ` instead of character literal ' '.

DATA v_str TYPE string.

v_str = '123 456 789'.

WRITE v_str.

REPLACE ALL OCCURRENCES OF ` ` IN v_str WITH '.'.

WRITE / v_str.

BR,

Suhas

Read only

Former Member
0 Likes
1,155

if i use replace all occurences its giving dump error

Read only

0 Likes
1,155

Or you can try

data: lv_string type string VALUE '188 445 32',
      lv_str type string ,
      lv_str1 type string ,
      lv_str2 type string .
SPLIT lv_string at space into lv_str lv_str1 lv_str2.

CONCATENATE lv_str lv_str1 lv_str2 into lv_string SEPARATED BY '.'.

write lv_string.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,155

Hello,

Can you please post your code here ? How you have defined the variables & how you are trying to replace the spaces.

BR,

Suhas

Read only

Former Member
0 Likes
1,155

thanks yaar

problem solved

Vamsee

Read only

Former Member
0 Likes
1,155

Hi, look at this example.

DATA: text TYPE string VALUE '-xx-'.

REPLACE ALL OCCURRENCES OF REGEX 'x*' IN text WITH 'a'.

After replacement, text contains value "a-aa-a".

Regards,

Nihad

Edited by: nihad omerbegovic on Dec 10, 2009 10:15 AM