ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → Data Types and Data Objects → Types and Objects - Overview → Data Objects
Strings
Strings are elementary data objects of variable length. Strings can be either text strings or byte strings. Like internal tables, strings are dynamic data objects.
The corresponding built-in ABAP types are string
and xstring
.
These are the dynamic equivalent of the data types c
and x
, which define text fields or byte fields of fixed length.
- Text strings and text fields contain character strings. Their common generic type is
csequence
.
- Byte strings and byte fields contain byte strings. Their common generic type is
xsequence
.
Unlike a text field or byte field, the length of a string is not defined statically, but is variable and adapts to the current content of the data object at runtime. Internally, this uses dynamic memory management (see Memory Management for Deep Data Objects). The maximum size of a string is determined by the profile parameter ztta/max_memreq_MB (see Maximum Size of Dynamic Data Objects). The initial value of a string is the empty string with length 0. Any assignments between strings with the same type produce sharing.
In contrast to text fields, trailing blanks are respected in text strings. There is a special text string literal for text strings. As with byte fields, there is no special literal for byte strings in the current release.
Strings are deep data types. A structure that contains a string is a deep structure and cannot be used as a character-like field in the same way as a flat structure.
Strings, like internal tables, can be stored in data clusters. In ABAP Dictionary, strings can have the built-in data types SSTRING, STRING, and RAWSTRING. These can also be the types of table fields in database tables (subject to certain restrictions).
Other versions: 7.31 | 7.40 | 7.54
Example
Inline declaration of a text string carrier_list
for adding a comma-separated list of character-like data.
SELECT carrid
FROM scarr
INTO TABLE @DATA(carrier_tab).
CONCATENATE LINES OF carrier_tab INTO DATA(carrier_list)
SEPARATED BY `, `.
cl_demo_output=>display( carrier_list ).