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 characters in a string

rainer_hbenthal
Active Contributor
0 Likes
1,824

Hi,

with a character variable you can manipulte the contents via

var+5(02) = 'XY'.

With a string variable this is not allowed. Is there any other way of doing this except copying the string to a char variable, doing the change and copy it back? Another way of doing this concatenating the first part, the new chars and the rest together, but this is an ugly solution too....

Why is it syntactically ok to read parts of a string, but not to write? Is it because a string content is shared between several variables all pointing to the same string content?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,424

try this.

REPLACE SECTION [OFFSET off] [LENGTH len] OF text WITH new.

Awrd Points if Useful

bhupal

3 REPLIES 3
Read only

Former Member
0 Likes
1,424

use REPLACE ...

e.g.

DATA field(10) TYPE C.

MOVE 'ABCB' TO field.

REPLACE 'B' WITH 'string' INTO field.

OR

DATA: pattern(6) TYPE C VALUE 'ABC',

len TYPE I,

repl_string(6) TYPE C VALUE '123456',

field(12) TYPE C VALUE 'abcdeABCDE'.

REPLACE pattern WITH repl_string INTO field.

Edited by: Sharayu Kumatkar on Dec 21, 2007 12:32 PM

Read only

Former Member
0 Likes
1,425

try this.

REPLACE SECTION [OFFSET off] [LENGTH len] OF text WITH new.

Awrd Points if Useful

bhupal

Read only

Former Member
0 Likes
1,424

Hi,

This can be done using REPLACE command.

Regards,

Lalit