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 letters and numbers

Former Member
0 Likes
1,418

Hi,

Is there any variant of command Replace or other command to replace on a field all letters by “A” and all numbers by “1”?

Thanks in advance,

Nuno

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,255

data str type string value 'BACADA......ZA'

translate field with str. "this will replace all letters (B-Z) with A

do similarly with the numbers (use type n )

regards,

Priyank

6 REPLIES 6
Read only

Former Member
0 Likes
1,255

Hi,

use this :

REPLACE ALL OCCURENCES OF 'A' IN field WITH '1'.

Hope this is what you wanted

Read only

0 Likes
1,255

Hi Shailesh,

not exacly...

what I need is: all letters are replaced by “A” and all numbers by “1”

ex:

BANKN (Bank account) is FS-012345.12

after the replace it should be AA-11111.11

Read only

Former Member
0 Likes
1,256

data str type string value 'BACADA......ZA'

translate field with str. "this will replace all letters (B-Z) with A

do similarly with the numbers (use type n )

regards,

Priyank

Read only

0 Likes
1,255

Hi Priyank,

It doesn't seems to work... any other suggestions?

Thanks in advance,

Nuno

Read only

0 Likes
1,255

Hi nuno,

1. <b>FS-012345.12 -


> AA-111111.11</b>

2. Just copy paste

3.

report abc.

*----


data : s1(15) type c.

data : s2(15) type c.

data : ch(26) type c.

data : nu(10) type c.

data : ln type i.

data : pos type i.

*----


ch = sy-abcde.

nu = '0123456789'.

s1 = 'FS-012345.12'.

s2 = s1.

ln = strlen( s2 ).

do ln times.

pos = sy-index - 1 .

if ch CA s2+pos(1) .

s2+pos(1) = 'A'.

endif.

if nu CA s2+pos(1) .

s2+pos(1) = '1'.

endif.

enddo.

*----


write 😕 s1.

write 😕 s2.

regards,

amit m.

Read only

Former Member
0 Likes
1,255

hi,

goto edit -> click on find/replace -> giv nam to be replaced -> continue ->ok

if helpful reward some points.

with regards,

suresh babu aluri.