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

sql_exp - sql_cast

Syntax

... CAST( operand AS dtype ) ...

Effect

Modifies the type in Open SQL. A cast expression converts the value of the operand operand to a dictionary type specified by dtype. The operand operand can be SQL expressions whose type matches dtype as shown below. The result is a representation of the source value in type dtype.

Built-in data types in ABAP Dictionary with the following syntax can be specified for dtype:

len and decimals can be used to specify lengths and decimal places for those dictionary types that have variable lengths and decimal places. Literals or constant host variables of the ABAP type b, s, i, or int8 can be specified for len and decimals. If no lengths or decimal places are specified for these types, these values are taken from the operand operand. In both cases, the lengths and decimal places must meet the requirements of the following table.

The following table shows which combinations of built-in data types in ABAP Dictionary can currently be cast to each other and what the prerequisites are in each case. There is a special list of conversion rules for every combination.

from/to INT1 INT2 INT4 INT8 DEC CURR QUAN FLTP CHAR NUMC DATS TIMS CLNT LANG UNIT CUKY SSTRING RAW
INT1 x x x x x x x x z - - - - - - - - -
INT2 x x x x x x x x z - - - - - - - - -
INT4 x x x x x x x x z - - - - - - - - -
INT8 x x x x x x x x z - - - - - - - - -
DEC - - - - x x x x z - - - - - - - - -
CURR - - - - x x x x z - - - - - - - - -
QUAN - - - - x x x x z - - - - - - - - -
FLTP - - - - - - - x - - - - - - - - - -
CHAR - - - - - - - - x y y y y y x y - -
NUMC x x x x x x x x y y y y y - - - - -
DATS - - - - - - - - x y x - - - - - - -
TIMS - - - - - - - - x y - x - - - - - -
CLNT - - - - - - - - x y - - x - - - - -
LANG - - - - - - - - x - - - - x - - - -
UNIT - - - - - - - - x - - - - - x - - -
CUKY - - - - - - - - x - - - - - - x - -
SSTRING - - - - - - - - - - - - - - - - y -
RAW - - - - - - - - - - - - - - - - - c

There are no further restrictions to note in combinations using "x". The following prerequisites apply to the other combinations:

In the case of incompatible types, the content of the operand is converted to the target type (exceptions can be raised if values are not suitable). If the operand of the expression has the null value, the result of the expression is also the null value.

Notes

Executable Example

SQL Expressions, cast Expression



Continue
sql_exp - sql_cast, Conversion Rules