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

String handling..

Former Member
0 Likes
552

Hi.

i have string in import parameter like..

STRING = 'A,B,C,D,...'

now i want it to convert like..

STRING1 = 'A','B','C','D',....

how can i do it.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
526

Hi purushottam,

A,B,C,D,E

'A','B','C','D','E'

1. just copy paste

2.

report abc.

data : abc(200) type c.

data : def(200) type c.

abc = 'A,B,C,D,E'.

def = abc.

replace all occurrences of ',' in def with ''',''' .

concatenate '''' def into def.

concatenate def '''' into def.

write : / abc.

write : / def.

*STRING1 = 'A','B','C','D',....

regards,

amit m.

4 REPLIES 4
Read only

Former Member
0 Likes
526

Hi,

You can use split at , into various fields

and then

use concatenate ' var1 ' into new_var.

Rgds,

HR

Read only

0 Likes
526

Hi ,

there is one simpler way . Try to use REPLACE .here is an example

DATA: myText type string.

myText = 'abcabcabcabcabc'.

REPLACE ALL OCCURRENCES OF 'abc' IN myText WITH 'XYZ'.

returns: myText = 'XYZXYZXYZXYZXYZ', sy-subrc = 0

Hope this helps .

Regards ,

Shounak M.

Read only

Former Member
0 Likes
527

Hi purushottam,

A,B,C,D,E

'A','B','C','D','E'

1. just copy paste

2.

report abc.

data : abc(200) type c.

data : def(200) type c.

abc = 'A,B,C,D,E'.

def = abc.

replace all occurrences of ',' in def with ''',''' .

concatenate '''' def into def.

concatenate def '''' into def.

write : / abc.

write : / def.

*STRING1 = 'A','B','C','D',....

regards,

amit m.

Read only

dani_mn
Active Contributor
0 Likes
526

HI,

check this code.

<b>REPORT zwa_test1 line-size 132 line-count 60.


data: string(20) value 'A,B,C,D'.
data: string1(30).
data: len type i.
data: index type i.
data: ind type i.

len = strlen( string ).

index = 1.
ind = 0.
string1(1) = ''''.
DO LEN times.

string1+index(1) = string+ind(1).
index = index + 1.
string1+index(1) = ''''.
index = index + 1.
ind = ind + 1.
ENDDO.


write:/ string1.</b>

Regards,

HRA