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 the tabular space with a comma

Former Member
0 Likes
892

Hi Experts,

i have a string have values separated by tabular spaces eg

19 asd 23 adf 23

i need to replace the string like this

19,asd,23,adf,23

thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
757

Hi,'

Use statement REPLACE ALL OCCURANCES OF ,

Regards,

Bharat

Read only

Former Member
0 Likes
757

Hi Karthick,

In our code, use the following Syntax,

REPLACE ALL OCCURENCES OF ' ' WITH ',' RESPECTING BLANKS.

Hope this is helpful to you. If you need further information, revert back.

Reward all the helpful answers.

Regards

Nagaraj T

Read only

Former Member
0 Likes
757

Hi,

use the following code

DATA: w_text TYPE char10.

CONSTANTS: c_colon TYPE char1 VALUE ','.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN w_text WITH c_colon.

cl_abap_char_utilities=>horizontal_tab takes tablular space.

Reward points if helpful.

Regards,

Sriram

Edited by: Srirama Murthy Maddirala on May 20, 2008 11:54 AM

Read only

Former Member
0 Likes
757

Hi,

Kindly use the following sample code:

DATA: VAR1(10) VALUE 'sau rabh',

LENGTH TYPE I,

START TYPE I.

LENGTH = STRLEN( VAR1 ).

DO LENGTH TIMES.

IF VAR1+START(1) EQ SPACE.

VAR1+START(1) = ','.

ENDIF.

START = START + 1.

ENDDO.

I know the logic to get the blank space is tedious but the problem is u cannot use REPLACE statement directly.

hopefully it helps.

Regards,

Saurabh

Read only

Former Member
0 Likes
757

Hi..

try this logic.

DATA: var1(80) VALUE '19 asd 23 adf 23',

length TYPE i,

start TYPE i.

CONDENSE var1.

length = strlen( var1 ).

DO length TIMES.

IF var1+start(1) EQ space.

var1+start(1) = ','.

ENDIF.

start = start + 1.

ENDDO.

WRITE: var1.

i hope this will solve your problem.

Regards,

N M Poojari.