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 Comma with Space Not Working

Former Member
0 Likes
3,242

Any idea why the following code prints "SAPInc" on my system? I was expecting "SAP Inc".

Thanks for any help.

REPORT zz_temp.

DATA: l_v_char2(30)  TYPE c VALUE 'SAP,Inc'.

REPLACE FIRST OCCURRENCE OF ',' in l_v_char2 with space.

WRITE: / l_v_char2.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,759

Jerry,

Use this


REPORT zz_temp.

DATA: l_v_char2(30)  TYPE c VALUE 'SAP,Inc'.

TRANSLATE l_v_char2 USING ', '.


WRITE: / l_v_char2.

Cheers

Aneesh.

9 REPLIES 9
Read only

Former Member
0 Likes
1,759

There should be a space after comma.

DATA: l_v_char2(30) TYPE c VALUE 'SAP, Inc'.

Thanks,

Srinivas

Read only

Former Member
0 Likes
1,760

Jerry,

Use this


REPORT zz_temp.

DATA: l_v_char2(30)  TYPE c VALUE 'SAP,Inc'.

TRANSLATE l_v_char2 USING ', '.


WRITE: / l_v_char2.

Cheers

Aneesh.

Read only

Former Member
0 Likes
1,759

Hi,

Can you try with LENGTH len addition

REPLACE FIRST OCCURRENCE OF ',' in l_v_char2 with space LENGTH 1.

As per SAP REPLACE is Obsolete in laltest version

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb33cc358411d1829f0000e829fbfe/content.htm

Regards,

Atish

Read only

ferry_lianto
Active Contributor
0 Likes
1,759

Hi,

Just use TRANSLATE statement instead.


DATA: L_V_CHAR2(30)  TYPE C VALUE 'SAP,Inc'.
                                                                        
TRANSLATE L_V_CHAR2 USING ', '.
                                                                        
WRITE: / L_V_CHAR2.

Regards,

Ferry Lianto

Read only

0 Likes
1,759

Thanks to all. It just bugs me that it seems like it should work since it is syntactically correct.

Read only

0 Likes
1,759

If that bothers you, try:

REPLACE ALL OCCURRENCES OF ' ' IN l_v_char2 WITH ','.

ABAP doesn't seem to handle spaces well.

Rob

Read only

0 Likes
1,759

Stop! You're torturing me!!

Read only

0 Likes
1,759

Yes - I've had a good day

Rob

Read only

Former Member
0 Likes
1,759

Check below code. it is printing as you need.

REPORT zz_temp.

DATA: l_v_char2(30) TYPE c VALUE 'SAP,Inc'.

replace ',' with space into l_v_char2.

WRITE: / l_v_char2.