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

replace hypen with space.

Former Member
0 Likes
769

Hi

I want to replace hyper with space. Is the below sytax correct. I am not getting space.

REPLACE ALL OCCURRENCES OF '-' IN str WITH SPACE

input : abc-xyz output : abcxyz

I want a space between abc and xyz.

thanks

balaji

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
744

Hi Balaji,

This will solve your problem.

data: str(20) type c.

str = 'hari,krishna,rao'.

TRANSLATE STR <b>USING ', '.</b>

write str.

Keep in mind that in <u>USING after comma....there is a SPACE.</u>

Reward points if it is answered.

Thanks.

Hari krishna

5 REPLIES 5
Read only

Former Member
0 Likes
744

Balaji,

REPLACE <str1> WITH <str2> INTO <c> [LENGTH <l>].

DATA: T(10) VALUE 'abcdefghij',

STRING LIKE T,

STR1(4) VALUE 'cdef',

STR2(4) VALUE 'klmn',

STR3(2) VALUE 'kl',

STR4(6) VALUE 'klmnop',

LEN TYPE I VALUE 2.

STRING = T.

WRITE STRING.

REPLACE STR1 WITH STR2 INTO STRING.

WRITE / STRING.

Don't forget to reward if useful...

Read only

Former Member
0 Likes
744

Hi,

I think replace will not wrk in ur case as u need to insert a space in place of hyphen.

What u can do is use the following piece of code:

DATA : str TYPE string,

a type string,

b type string.

str = 'abc-xyz'.

WRITE : str.

SPLIT str AT '-' INTO a b.

CONCATENATE a b INTO str SEPARATED BY space.

WRITE : / str.

Regards,

Himanshu

Read only

kiran_k8
Active Contributor
0 Likes
744

Balaji,

data: v1(1) type c value '-'.

replace '-' in v1 with ' '.

write:/ 'v1:-',v1.

K.Kiran.

Message was edited by:

Kiran K

Read only

Former Member
0 Likes
745

Hi Balaji,

This will solve your problem.

data: str(20) type c.

str = 'hari,krishna,rao'.

TRANSLATE STR <b>USING ', '.</b>

write str.

Keep in mind that in <u>USING after comma....there is a SPACE.</u>

Reward points if it is answered.

Thanks.

Hari krishna

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
744

Hi,

As suggested,translate will help.

data: str(20) type c.

str = 'abc-xyz'.

TRANSLATE STR USING '- '.

write str.