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

how to replace character for a variable?

Former Member
0 Likes
3,967

Hi everyone,

In ABAP, if I want to replace * with & which in the variable 'input1'. How to write the code?

Thanks!

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
2,114

hi,

TRANSLATE string USING '*&'.

hope this helps

ec

7 REPLIES 7
Read only

matt
Active Contributor
0 Likes
2,114

Type REPLACE into the abap editor, and then press F1. or TRANSLATE can also be used.

Read only

JozsefSzikszai
Active Contributor
0 Likes
2,115

hi,

TRANSLATE string USING '*&'.

hope this helps

ec

Read only

Former Member
0 Likes
2,114

Hi,

See Help on REPLACE statement [F1].

Thanks

Sudharshan

Read only

kiran_k8
Active Contributor
0 Likes
2,114

wuyia,

Use REPLACE ALL OCCURENCES.

For syntax, check ABAPHELP transaction.

K.Kiran.

Read only

Former Member
0 Likes
2,114

TRANSALATE or REPLACE, base on your requirement.

Read only

Former Member
0 Likes
2,114

Hi Wuyia,

Try this way:

Data:
  w_char(20).

w_char = 'ab*c*def*h'.

REPLACE ALL OCCURRENCES OF '*' IN w_char WITH '&'.

Write: w_char.

With luck,

Pritam.

Read only

Former Member
0 Likes
2,114

Use this sample code

MOVE 'ABCB' TO FIELD.

REPLACE 'B' WITH 'string' INTO field.

returns:

FIELD = 'AstringCB', SY-SUBRC = 0

The fields f and g in the REPLACE statement should not overlap.

Otherwise, the result is undefined.

Regards

Alpesh