MichaelB.
7/23/2018 - 7:57 PM

REPLACE character strings

Replaces characters/bytes with other characters/bytes. By default only replaces the first occurrence in the string. All occurrences can be replaced for instance by using a loop.

DATA surname(40).

surname2 = 'Mr, Joe, Smith'.
REPLACE ',' WITH '.' INTO surname2. "only replaces first occurrence
WRITE: surname2.
ULINE.

surname2 = 'Mr, Joe, Smith'.
REPLACE ALL OCCURRENCES OF ',' IN surname2 WITH '.'.
WRITE: surname2.
ULINE.

surname2 = 'Mr, Joe, Smith'.
WHILE sy-subrc = 0.
  REPLACE ',' WITH '.' INTO surname2.
ENDWHILE.
WRITE: surname2.
ULINE.