SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Overview →Open SQL - Strings
Open SQL can be used to store character strings and binary data as strings in database columns. There are two kinds of strings in the database, short strings and long strings (LOBs), which differ in the way the data is stored in the database. Whether a string column is a short or a long string, is specified in ABAP Dictionary.
Note the following when using strings in database tables:
Short Strings
Short strings are only available for character strings (DDIC type SSTRING). They are normally implemented as VARCHAR fields in the database and stored in the data record. Short strings must always have a length restriction in ABAP Dictionary which cannot exceed 1333 characters. Trailing blanks are ignored by the database.
Short strings can be used as key fields of database tables. This can produce significant memory and performance gains in comparison with using long fields of type CHAR.
In Open SQL statements, you can use short strings wherever you can use CHAR fields.
Note
When you use short strings as key fields, note that their trailing blanks are ignored by the database.
An exception is raised if a row is inserted whose trailing blanks are the only thing that differentiate it from an existing row in a key field with the type SSTRING.
Long Strings
Long strings (LOBs) are provided as
CLOBs for character strings (ABAP Dictionary type STRING) or as
BLOBs for binary data (ABAP Dictionary
type RAWSTRING). These strings are generally designed so that only one LOB locator is saved in the data
record, and the actual string data is saved outside the data record. A length restriction can be defined
for long strings in ABAP Dictionary. For columns of the type STRING, trailing spaces are retained.
Long strings are subject to the following restrictions:
Note
Long strings (LOBs) can be accessed using streaming and locators.
Length Restriction
It is possible for long strings and mandatory for short strings to define a length restriction for them in ABAP Dictionary. If this restriction is violated when data is written to the database, the system raises an exception of the class CX_SY_OPEN_SQL_DB. Any truncation of the string when data is read from the database into a target field is ignored. The value of the length restriction can be queried using the function dbmaxlen( ).
Notes
Performance
Since the data of long strings is stored outside the data record, access to long strings is slower than to other data types. This applies particularly to set operations. This note is not applicable to short strings.