sapdev logo background
sapdev logo sapdev logo
Comments

SAP NEWS-610-STRINGS documentation, setup help and example usage



Return to SAP documentation index



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


ABAP_MODIFICATION_1 Establishing the length and number of characters

The function charlen provides the length of the first character of a string or of a character-like field.
You can use 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 .


ABAP_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.


ABAP_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.


ABAP_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:
Short strings consist of a maximum of 256 characters, do not have trailing blanks, and can be compared on the database.
Long strings can be of any length and do have trailing blanks; however they cannot be compared on the database.
When working with strings, some restrictions have to be observed. Further details are available here .


ABAP_MODIFICATION_5 Defining string constants

Strings can now also be defined as constants and can be given an initial value using the keyword VALUE .
CONSTANTS str1 TYPE string VALUE 'ABC'.
DATA str2 TYPE string VALUE 'XYZ'.
str2 = str1.
str1 = str2. "Syntax error
WRITE: / str1, str2.


ABAP_MODIFICATION_6 Introduction of text string literals

Text string literals are enclosed by backquotes in the form str = `ABC` . String literals are of data type 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.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




NEWS-610-SQL
NEWS-610-SYSTEM




comments powered by Disqus