ABAP - Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Objects →  Literals → 

Character Literals

Character literals can be either text field literals or text string literals. A text field literal is a character string enclosed in single quotation marks ('); a text string literal is a character string enclosed in single backquotes (`).

Syntax Name Possible Characters
'...' Text field literal String of any alphanumeric characters. The data type is c with the length of the enclosed characters (including trailing blanks). The length of a text field literal must lie between 1 and 255 characters. There is no empty text field literal: The text field literal '' has the same meaning as the text field literal ' ' with length 1. To represent a quotation mark in a text field literal, two consecutive quotation marks must be specified.
`...` Text string literal String of any alphanumeric characters. The data type is string. A text string literal can have a maximum of 255 characters. The empty text string literal `` represents an empty string with length 0. To represent a backquote in a text string literal, two consecutive backquotes must be specified.

Character literals that span multiple lines are not allowed. The literal operator & can, however, be used to join multiple literals with the same type as a composite literal.

Trailing blanks are not ignored. If a text field literal is specified at an operand position at which a text symbol is possible, the three-character identifier idf of a text symbol can be appended in parentheses.

... 'Literal'(idf) ...

If the text symbol exists in the currently loaded text pool, the content of the text symbol is used instead of the literal, otherwise the literal is used. Text string literals cannot be associated with text symbols.

Programming Guidelines

Notes

Example

Represents quotation marks and backquotes in character literals. The first two and the last two literals always have the same meaning.

cl_demo_output=>write_text( 'This is John''s bike' ).
cl_demo_output=>write_text( `This is John's bike` ).
cl_demo_output=>write_text( 'This is a backquote: `' ).
cl_demo_output=>write_text( `This is a backquote: ``` ).
cl_demo_output=>display( ).

Example

If quotation marks and backquotes are required in a string, string templates are also suitable, whose special characters are consistently masked with \.

cl_demo_output=>display( |Quote: ', Backquote: `, Bar: \| | ).