ABAP Keyword Documentation → ABAP - Dictionary → Built-In Data Types in ABAP Dictionary → Attributes of the Predefined Dictionary Types → General Dictionary Types
Decimal Floating Point Numbers
In decimal floating point numbers, a maximum of 16 or 34 places exactly are returned in the mantissa depending on the data type.
Other versions:
7.31 | 7.40 | 7.54
Handling in ABAP Dictionary
In ABAP Dictionary, the following data types are available for decimal floating numbers.
Decimal Floating Point Types
The following built-in ABAP Dictionary data types represent real floating point types of a database:
- DECFLOAT16 for 16-digit numbers.
- DECFLOAT34 for 34-digit numbers.
They can be used, without restrictions, as numeric data types in appropriate expressions and functions. They are currently only supported by SAP HANA databases.
Replacement Types
The following built-in data types in ABAP Dictionary are used as replacements for real decimal floating point types:
These types can be used as replacements on database systems that do not support decimal floating point types. They are mainly used to save decimal floating point numbers from ABAP programs and have only restricted use as numeric data types in appropriate expressions and functions:
- DF16_DEC and DF34_DEC
In database fields of this type, decimal floating point numbers are stored as a packed number (format DEC). The length and the number of decimal places must be specified when defining a data type in ABAP Dictionary. For this type, restricted operations can be performed on the database:
- No operands of these types can be used in arithmetic SQL expressions or numeric SQL functions.
- Columns, but no SQL expressions of these types, can be used as operands in the aggregate functions except for
STRING_AGG
.
- In the statement
UPDATE
, operations with these types are possible withSET
+
and-
.
- Database fields with these types can be edited in Native SQL or AMDP.
- When there is a write to the database, the system implicitly rounds off to the number of decimal places and decimal overflows can occur.
- DF16_RAW and DF34_RAW
In database fields of this type, decimal floating point numbers are stored as binary (in RAW format). The length is set to 16 or 34 places. Values can be sorted, compared, and used in indexes. For this type, no calculations can be performed on the database. This is an SAP-specific format, which means that the corresponding fields also cannot be edited in Native SQL or AMDP. The scaling is lost when writing to the database.
Notes
- If possible, the types DECFLOAT16 and DECFLOAT34 should be used.
- The case in question determines which replacement type needs to be used if necessary:
- The types DF16_DEC and DF34_DEC can be used for calculations on the database, but their value ranges are smaller than those of real decimal floating point numbers.
- The types DF16_RAW and DF34_RAW cover the whole value range, but are not recognized as numbers by the databases.
- As in the general packed numbers, the number of places in the replacement types DF16_DEC and DF34_DEC should be odd.
- In ABAP CDS it is not usually possible to execute expressions or functions for the replacement types.
- As well as the types above, there are also the obsolete replacement types DF16_SCL and DF34_SCL for decimal floating point numbers with scaling.
- In database fields of this type, decimal floating point numbers are stored in the same way as DF16_RAW or DF34_RAW (length 16 or 34 places, and the same restrictions apply). The scaling must be specified in a direct successor database field with type INT2. When a decimal floating point number is written, this field is filled automatically with the scaling and the scaling is taken from it in reads.
- It is strongly advised not to use the types DF16_SCL and DF34_SCL. Their functions are rarely needed and the additional column for scaling makes them too complicated and error-prone to use correctly.
Handling in Dynpros - Output Length and Output Style
The maximum output length that can be specified in a domain for a 16-character decimal floating point number is 24. For a 34-character number, 46 is the maximum output length. These are also the default values.
In a domain, or directly in a structure component created using one of the types for decimal floating numbers (but not in data elements with directly specified technical attributes), one of the following output styles is always defined. The output style defines how a dynpro field defined with reference to this domain (or a corresponding ABAP field in the case of list output) is formatted:
- Simple
- Leading sign to the right
- Scale-preserving
- Scientific
- Scientific with leading zero
- Scale-preserving scientific
- Technical
For dynpro fields whose data type is not defined in ABAP Dictionary, the output style can also be determined in
Screen Painter. In the
case of formatting with the statements WRITE
or WRITE TO
, the addition STYLE
is available (as for the
string templates).
Notes
- If scientific notation is used, a limited number of the displayed places in the mantissa is recommended.
This can be specified using the built-in function
rescale
.
- The "scale-preserving" style ensures that the scaling is restored in conversions from dynpro fields to ABAP, and not just the original value.
- If vertically aligned decimal separators and exponents are needed on UIs, the scale-preserving scientific notation can be used.
Handling in ABAP Programs
The ABAP types that correspond to the 16 or 34 figure decimal floating numbers in ABAP Dictionary are
decfloat16
and decfloat34
, which are handled internally
according to the IEEE-754-2008 standard, and are supported by all ABAP operations. There is restricted support for floating point numbers with replacement types in
SQL expressions. In
arithmetic SQL expressions, only those decimal floating point numbers are supported that are based on the decimal floating point types.
The addition STYLE
after WRITE [TO]
and the formatting option STYLE
in
embedded expressions are available for the formatting of decimal floating numbers in programs. These overwrite the output style defined in ABAP Dictionary.