ABAP Keyword Documentation → ABAP − Release-Specific Changes → Changes in Release 6.10
Character Strings in Release 6.10
The following new functions are available for character strings in Release 6.10:
1. Establish the length and number of characters
2. New statements FIND
and REPLACE
3. Faster access to strings
4. Support for strings in the database
5. Definition of string constants
6. Introduction of text string literals
Other versions: 7.31 | 7.40 | 7.54
Modification 1
Establishing the length and number of characters
charlen
provides the length of the first character of a string or of a character-like field.
numofchar
to obtain the number of characters in a string or a character-type field.
dbmaxlen
provides the maximum length of the string as stored in ABAP Dictionary.
Modification 2
New statements FIND
and REPLACE
There is a new statement, FIND
, for
searching in character strings. This replaces the SEARCH
command. For replacing characters in character strings, the statement
REPLACE
has been extended to include position-based replacements.
Modification 3
Faster access to strings
Offset/length access is now the fastest way to process a string character by character. This technique is also faster than searching in a field of type C that is assigned to a field symbol.
Modification 4
Support for strings in the database
From Release 6.10, character strings and binary data can be stored in database columns of types STRING or RAWSTRING. The system differentiates between short and long strings:
When working with strings, some restrictions have to be observed. Further details are available here.
Modification 5
Defining string constants
Strings can now also be defined as constants and can be given an initial value using the keyword VALUE
.
DATA str2 TYPE string VALUE 'XYZ'.
str2 = str1.
str1 = str2. "Syntax error
WRITE: / str1, str2.
Modification 6
Introduction of text string literals
Text string literals are enclosed by backquotes in the form
str =
. String literals are of data type ABC
STRING
and trailing blanks are not ignored, unlike in text field literals.
DATA: str1 TYPE string VALUE 'ABC ',
str2 TYPE string VALUE `ABC `,
cnt1 TYPE i,
cnt2 TYPE i.
cnt1 = strlen( str1 ).
cnt2 = strlen( str2 ).
WRITE: / cnt1, cnt2.
The length for the string str1
is cnt1
= 3 and the length for the string str2
is cnt2
= 5.