The OVERLAY statement overlays one string with another:
OVERLAY <c1> WITH <c2> [ONLY <str>].
This statement overlays all positions in field <c1> containing letters which occur in <str> with the contents of <c2>.
<c2> remains unchanged. If you omit ONLY <str>, all positions of <c1> containing spaces are overwritten.If at least one character in
<c1> was replaced , SY-SUBRC is set to 0 . In all other cases, SY-SUBRC is set to 4. If <c1> is longer than <c2>, it is overlaid only in the length of <c2>.
DATA: T(10) VALUE 'a c e g i ',
STRING LIKE T,
OVER(10) VALUE 'ABCDEFGHIJ',
STR(2) VALUE 'ai'.
STRING = T.
WRITE STRING.
WRITE / OVER.
OVERLAY STRING WITH OVER.
WRITE / STRING.
STRING = T.
OVERLAY STRING WITH OVER ONLY STR.
WRITE / STRING.
Output:
a c e g i
ABCDEFGHIJ
aBcDeFgHiJ
A c e g I