OVERLAY c1 WITH c2.
Depending on whether byte or character string processing is carried out, the operands can only be byte-type or character-type (see Overview).
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Only character fields allowed in string processing.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Character String Processing and Unicode.
The contents of the field
c2 overlay the field c1
in all positions where
c1 has the value SPACE;
c2 itself remains unchanged.
The Return Code is set as follows:
DATA: WORK(20) VALUE 'Th t h s ch ng d.',
HELP(20) VALUE 'Grab a pattern'.
OVERLAY WORK WITH HELP.
WORK now contains 'That
has changed.' and the system field SY-SUBRC is set to 0.
If c1 is longer than c2,
c1 is only overlaid by the length of c2. The
result for overlapping fields c1 and c2 is undefined.
... ONLY c3
The contents of the field c2 overlay the contents of field
c1 in all positions where c1
has one of the characters contained in c3. The contents
of the fields c2 and c3 remain unchanged.
Linking field selection templates:
DATA: one(16),
two(16).
one = '----****++++....'.
two
= '-*+.-*+.-*+.-*+.'.
OVERLAY one WITH two ONLY '.'.
OVERLAY one WITH two ONLY '.+'.
OVERLAY one WITH two ONLY '+*'.
Field one now contains '-----*+.-*+.-*+.'.
Performance:
The runtime required for the OVERLAY statement in the
example of the basic form is about 45 msn (standardized microseconds).
To execute the addition ... ONLY c3, about 40 msn are needed.
FIND,
REPLACE, SEARCH,
SHIFT, TRANSLATE
Overlaying Strings