2020 Mar 16 7:59 AM
Hello,
I am new to ABAP and I need some help for a project.
I have some data (NAME1, NAME2), the value is a string for example John Doe.
I need to anonymize this data because its showing on some reports, so I want to make a check and take all the values and change them in J*** D** , i need 1st letter to stay unchanged and the rest of the characters to be changed to ' * ' .
I need to make this to a whole table with names.
I know that i need to use REPLACE IN WITH statement but i don't know how to keep the first character and change the others.
Hi Bogdan,
String handling in ABAP link can help. Stings in SAP and String processing in SAP through ABAP
Regards,
Abinath
2020 Mar 16 8:05 AM
Hi Bogdan,
String handling in ABAP link can help. Stings in SAP and String processing in SAP through ABAP
Regards,
Abinath
2020 Mar 16 11:32 AM
2020 Mar 16 8:37 AM
2020 Mar 16 8:54 AM
For information, the regular expression \B. means any character (.) which is inside the boundary characters of a word (\B).
2020 Mar 16 9:14 AM
data: name1 type char10,
name2 type char10,
v1 type char1,
v2 type char1.
name1 = 'John'.
name2 = 'Deo'.
v1 = name1.
v2 = name2.
concatenate v1'***' v2'***' into name1.
break-point.

2020 Mar 16 9:23 AM
Hi
You can try this - I tried this - it works -
name1 = 'ALLEXCEPTFIRSTCHAR'.
mask_length = strlen( my_var ) - 1.
name1 = replace( val = name1
off = 1
len = mask_length
with = repeat( val = '*' occ = mask_length ) ).I tested it and it is working as expected.
2020 Mar 16 11:41 AM
2020 Mar 16 11:53 AM
DATA : var1 type string VALUE 'John Doe'
, var2 TYPE string
, varfinal TYPE char32
, varfinal1 TYPE char32
, varfinal2 TYPE char32
, str TYPE char32
, len TYPE i
, len1 type i.
SPLIT var1 at space INTO : data(str1) data(str2) .
len = strlen( str1 ).
len1 = len - 1.
var2 = repeat( val = '*' occ = len1 ).
CONCATENATE str1(1) var2 into varfinal1.
*write : ' Anonymous Text is :' , varfinal1.
len = strlen( str2 ).
len1 = len - 1.
var2 = repeat( val = '*' occ = len1 ).
CONCATENATE str2(1) var2 into varfinal2.
*write : ' Anonymous Text is :' , varfinal2.
CONCATENATE varfinal1 varfinal2 INTO varfinal SEPARATED BY space.
write : ' Anonymous Text is :' , varfinal.
2020 Mar 16 11:55 AM
2020 Mar 16 2:04 PM
Hi
If you find the answer, please mark the right one and close the thread. Curios to know that
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |