ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Statements for Character String and Byte String Processing
OVERLAY
Other versions: 7.31 | 7.40 | 7.54
Syntax
OVERLAY text1 WITH text2 [ONLY mask].
Effect
Characters in the text1 variable are replaced by characters in the text2 operand that are there in the same location. text2 is a
character-type expression position.
If the ONLY addition is not specified, all blank characters in text1
are replaced. If the ONLY addition is specified, all characters are replaced
that occur in the mask operand, and case sensitivity is taken into account. mask is also a
character-type expression position.
If the lengths of text1 and text2 are different, text1 is processed using the shorter length only.
The text1, text2, and mask
operands must be character-type. In operands of fixed length, closing blank characters are taken into account. If mask is an empty string, no replacements are made.
System Fields
| sy-subrc | Meaning |
|---|---|
| 0 | At least one character in text1 was replaced. |
| 4 | No characters were replaced in text1. |
Example
After the text field has been assigned to the time field, it contains the invalid time "12__00" according to the
conversion rule. As a result of the overlay with
the initial_time constants, the two blank characters are replaced by "00" and the result is the valid time "120000".
CONSTANTS initial_time TYPE t VALUE IS INITIAL.
DATA: time TYPE t,
text TYPE c LENGTH 4.
text = '12'.
time = text.
OVERLAY time WITH initial_time.