2022 Aug 04 4:21 AM
Hi Experts!
Good day!
I am trying to mask a sensitive element in a view.
So for example, in the following data, the expected output is beside it.
Elon Musk -> E*** M***
Meta World Peace -> M*** W**** P****
Arnold Schwarzenegger -> A***** S*************
I was thinking of using a table function which uses substring and other string functions but the one thing i don't think will work is the fact that we dont know how many words will be in the field itself. This calls for a dynamic approach, some sort of loop which I know isnt possible in SQL (please correct me if Im wrong). Any thoughts?
Thanks and regards,
Erwin Formaran
2022 Aug 08 1:35 PM
Hello everybody, just an update. This was resolved by using function replace_regex in table function.
2022 Aug 04 11:45 AM
** This is bad code but it use helpful.
REPORT ZTEST.
DATA: TEXT TYPE STRING VALUE 'Arnold Schwarzenegger',
LV_LENGTH TYPE I,
LV_ITEM TYPE STRING,
LV_RESULT TYPE STRING.
SPLIT TEXT AT SPACE INTO: DATA(STR1) DATA(STR2) DATA(STR3),
TABLE DATA(ITAB).
LOOP AT ITAB ASSIGNING FIELD-SYMBOL(<FS_ITAB>).
LV_LENGTH = STRLEN( <FS_ITAB> ) - 1.
DO LV_LENGTH TIMES.
CONCATENATE LV_ITEM '*' INTO LV_ITEM.
ENDDO.
<FS_ITAB> = <FS_ITAB>+0(1) && LV_ITEM.
IF LV_RESULT IS INITIAL.
CONCATENATE LV_RESULT <FS_ITAB> INTO LV_RESULT.
ELSE.
CONCATENATE LV_RESULT <FS_ITAB> INTO LV_RESULT SEPARATED BY SPACE.
ENDIF.
CLEAR: LV_ITEM.
ENDLOOP.
BREAK QUYNHBC.
2022 Aug 05 5:43 AM
Hi Quynh Bui Cong,
Decent code i would say. But I am looking for ABAP CDS/SQL Script not ABAP. How i wish we could do this in CDS.
Thanks anyway.
2022 Aug 08 1:35 PM
Hello everybody, just an update. This was resolved by using function replace_regex in table function.