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 charcter from string in 46c

Former Member
0 Likes
465

Hi,

If you could send me code for below scanerio that will be great.

in 46c i have string '/ABCD/te_12' now i want to replace the '/' with '+' and '_' with '|', can you tell me how to do this.

thanks,

john

3 REPLIES 3
Read only

former_member156446
Active Contributor
0 Likes
429

hi check the replace statement... hit F1 on replace and make ur code..

Basic form

REPLACE f WITH g INTO h.

Addition

... LENGTH len (length specification for field f )

Effect

Replaces the first occurrence of the contents of field f in field h with the contents of field g . All fields are handled in their defined length; this means that closing blanks are not ignored.

The return code value indicates whether the string f was found in h and replaced by g :

SY-SUBRC = 0 String replaced.

SY_SUBRC = 4 String not replaced.

Example

DATA FIELD(10).

MOVE 'ABCB' TO FIELD.

REPLACE 'B' WITH 'string' INTO FIELD.

returns:

FIELD = 'AstringCB', SY-SUBRC = 0

Note

The fields f and g in the REPLACE statement should not overlap. Otherwise, the result is undefined.

Addition

... LENGTH len ... (length specification for field f )

Effect

Searches for the string f in the field h not in its (full) field length, but in the length len .

Example

DATA: PATTERN(5) VALUE 'ABC',

LEN TYPE I,

REPL_STRING(5) VALUE '12345',

FIELD(12) VALUE 'abcdeABCDE'.

REPLACE PATTERN WITH REPL_STRING

INTO FIELD.

does not change FIELD , since 'ABC ' does not occur in abcdeABCDE ' .

LEN = STRLEN( PATTERN ).

REPLACE PATTERN LENGTH LEN

WITH REPL_STRING

INTO FIELD.

Read only

Former Member
0 Likes
429

data:data(13) value '/ABCD/te_12' .

data:output(13).

output0(1) = ''.

output1(7) = data1(7).

OUTPUT+8(1) = '/'.

OUTPUT9(3) = data9(3).

WRITE:/ OUTPUT.

HI CKECK IT ,

Regards,

pandu.

Edited by: pandu app on Feb 16, 2008 6:37 PM

Edited by: pandu app on Feb 16, 2008 6:45 PM

Read only

Former Member
0 Likes
429

Hi Pandu,

thanks for reply but what if the slash come in any other place how that can be handle .

thanks,

John