Entering content frame

Overlaying Character Fields Locate the document in its SAP Library structure

The OVERLAY statement overlays one string with another:

OVERLAY c1 WITH c2 [ONLY str].

This statement overlays all positions in field c1containing letters which occur in str with the contents of c2. c2remains 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) TYPE c VALUE 'a c e g i ',
      string LIKE t,
      over(10) TYPE c VALUE 'ABCDEFGHIJ',
      str(2) TYPE c VALUE 'ai'.

string = t.
WRITE string.

WRITE / over.

OVERLAY string WITH over.
WRITE / string.

string = t.
OVERLAY string WITH over ONLY str.
WRITE / string.


a c e g i



A c e g I



Leaving content frame