Skip to content

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

Open SQL - Work Areas in Statements

If in the Open SQL statements

  • SELECT or FETCH without the addition CORRESPONDING FIELDS,
  • INSERT, UPDATE, MODIFY, or DELETE

work areas wa or internal tables itab are specified as the target or source areas, the following prerequisites apply to the work area or row type of the internal table; if the prerequisites are ignored, a syntax error occurs or an exception is raised.

Other versions: 7.31 | 7.40 | 7.54

Work Areas without Reference Variables for LOB Handles

The following rules apply to work areas that do not contain reference variables for LOB Handles:

  • The data type of the work area or row type of the internal table must not be deep or contain deep components. This excludes strings and special work areas for streaming and locators.
  • The work area or row type of the internal table must be at least as long as the database structure and the alignment must match. In the statement DELETE, this prerequisite must only be met in the length of the primary key.
  • If the work area or rows of the internal table are structured, the Unicode fragment view of the database structure must match that of the work area or the internal table.
  • If the work area or rows of the internal table are elementary, they must be character-like and flat. The columns of the database structure must also be character-like and flat.
  • If the work area contains strings as components or is itself a string, or if columns of type SSTRING, STRING, or RAWSTRING appear in the database structure, the work area must be compatible with the database structure.
  • If the column specification * is used in the statement SELECT to access a CDS entity of a CDS view, the work area is always checked as if it contained a string as a component.
  • For the modifying operations INSERT, UPDATE, and MODIFY, the passed values must match the value range of the columns of the database tables. Otherwise, overflows occur and corresponding exceptions are raised. This applies in particular for:
  • Columns with numerical data types.
  • Columns of the types SSTRING, STRING, or RAWSTRING. The strings of the work area must not be longer than the maximum length of the columns in the database structure. This length can be determined using the predefined function dbmaxlen.


Notes

  • The work area or row structure of the internal table should always be built like the database structure. If a single database table or view is used in the Open SQL statement, a data object built the same way can be declared with reference to the relevant structure in ABAP Dictionary. If more than one database table is used (in the statement SELECT), a data object built the same way can be built as nested structure, which contains, as substructures, the structures of the single database tables or views in the order in which they are listed in the statement. No structure should be used in which all components lie on one level, since potential alignment gaps between the single database tables or views are ignored.

  • In obsolete non-Unicode programs, the Unicode fragment view does not need to match in the case of structured work areas or internal tables. In the case of elementary work areas or internal tables, the areas or tables and the structure of the database table do not need to be character-like and flat.

LOB Handle Structures

If a work area is an LOB handle structure, that is, it contains at least one reference variable for LOB handles, it must be structured exactly like the structure of the database table and all components except for the LOB handle components must be compatible with the corresponding components of the database table. The static type of each LOB handle component must contain the IF_ABAP_DB_LOB_HANDLE interface and match both the current statement and the data type of the assigned LOB.


Note

In the statement FETCH, no LOB handle structures can currently be specified.