Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Statements for Character String and Byte String Processing 

OVERLAY

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


OVERLAY text1 WITH text2 [ONLY mask]. 

Effect

Characters in the variable text1 are replaced by the characters in the operand text2 that are in the same place there. text2 is a character-like expression position.

If the addition ONLY is not specified, all blanks in text1 are replaced. If the addition ONLY is specified, all characters are replaced that occur in the operand mask. This is case-sensitive. mask is also a character-like expression position.

If the lengths of text1 and text2 are different, text1 is processed using the shorter length only.

The operands text1, text2, and mask have to be character-like operands. In operands of fixed length, trailing blanks are respected. If mask is an empty string, no replacements are made.

System Fields

sy-subrc Meaning
0 At least one character in text1 is replaced.
4 No characters in text1 are replaced.


Example

After the text field has been assigned to the time field, it contains the invalid time "12__00" (according to the conversion rules). As a result of the overlay with the initial_time constants, the two blanks 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.