adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
FIND
Aus SAP Wiki ツ
Version vom 9. Dezember 2021, 16:55 Uhr von M1ch3lde (Diskussion | Beiträge)
REGEX
Programm: DEMO_REGEX_TOY
Beispiel: Alle Zeichen außer Buchstaben (a-z und A-Z), Zahlen (0-9), Punkt (.) und Leerzeichen entfernen
DATA: lv_invalid_chars, lv_invalid_char, lv_valid_char TYPE string.
DATA: lc_space TYPE string VALUE ` `. "alt+255 (non breaking space)
LOOP AT gt_csv_txt ASSIGNING FIELD-SYMBOL(<fs_csv_line>).
FIND ALL OCCURRENCES OF REGEX '[^[:alnum:]\s\.]' IN <fs_csv_line> RESULTS DATA(it_invalid_chars).
IF sy-subrc = 0.
LOOP AT it_invalid_chars INTO DATA(ls_invalid_chars).
lv_invalid_char = <fs_csv_line>+ls_invalid_chars-offset(ls_invalid_chars-length).
CASE lv_invalid_char.
WHEN 'Á'.
lv_valid_char = 'A'.
WHEN 'É'.
lv_valid_char = 'E'.
WHEN 'Ó'.
lv_valid_char = 'O'.
WHEN 'Ü'.
lv_valid_char = 'Ue'.
WHEN 'Ä'.
lv_valid_char = 'Au'.
WHEN 'Ö'.
lv_valid_char = 'Oe'.
WHEN 'ä'.
lv_valid_char = 'au'.
WHEN 'ü'.
lv_valid_char = 'ue'.
WHEN 'ö'.
lv_valid_char = 'oe'.
WHEN 'á' OR 'ª'.
lv_valid_char = 'a'.
WHEN 'ß'.
lv_valid_char = 'ss'.
WHEN OTHERS.
lv_valid_char = lc_space.
ENDCASE.
REPLACE SECTION OFFSET ls_invalid_chars-offset LENGTH ls_invalid_chars-length
OF <fs_csv_line> WITH lv_valid_char.
CLEAR lv_valid_char.
ENDLOOP.
ENDIF.
ENDLOOP.