Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP - Database Accesses →  Open SQL →  Open SQL - Overview 

Open SQL - Strings

Other versions: 7.31 | 7.40 | 7.54

short stringslong strings

Note the following when using strings in database tables:

  • The structure of a database table with strings is deep and cannot be specified in positions in which only flat structures are possible, for example in the TABLES statement, which is obsolete for database access, or for typing the obsolete table parameters of procedures.
  • Database tables with strings cannot be used in views.

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. Trailings spaces are ignored by the database.

Short strings can be used as key fields of database tables. This can lead to 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 you try to insert a row 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. You can define a length restriction for long strings in the ABAP Dictionary. For columns of the type STRING, trailing spaces are retained.

Long strings are subject to the following restrictions:

  • They must not be used in key fields.
  • They must not be used in database indexes.
  • They must not be used in the SELECT clause in combination with the addition DISTINCT.


Note

Long strings (LOBs) can be accessed using streaming and locators.

Length Restriction

writtenread


Notes

  • Any database can choose to represent an empty string by a NULL value.

  • If a database table dbtab or a work area wa contains strings, then the work area wa must be compatible with the line structure of the database table dbtab for the following statements:
    - SELECT * FROM dbtab INTO wa
    - INSERT dbtab FROM wa or INSERT INTO dbtab VALUES wa
    - UPDATE dbtab FROM wa
    - MODIFY dbtab FROM wa
    - DELETE dbtab FROM wa
    Similarly, if you use the following set operations, the line structure of the internal table itab must be compatible with the line structure of the database table dbtab if itab or dbtab contains strings:
    - SELECT * FROM dbtab INTO TABLE itab
    - INSERT dbtab FROM TABLE itab
    - UPDATE dbtab FROM TABLE itab
    - MODIFY dbtab FROM TABLE itab
    - DELETE dbtab FROM TABLE itab

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 if you use short strings.