ABAP Keyword Documentation → ABAP Dictionary → Predefined 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 decimal places are returned exactly 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:
These data types are a replacement for real decimal floating point types that are supported by all database systems:
- 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. Calculations (SELECT
with appropriate SQL expressions or with the aggregate functionsSUM
andAVG
,UPDATE
withSET
+
, and-
) can be performed on the database for this type. When there is a write to the database, the system implicitly rounds off to the number of decimal places and decimal overflows can occur. Database fields with these types can be edited in Native SQL.
- 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 executed on the database. This is an SAP-specific format, which means that the corresponding fields also cannot be edited in Native SQL. The scaling is lost when writing to the database.
Notes
- The actual predefined data type from ABAP Dictionary used for decimal point numbers depends on their purpose.
- 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 types DF16_DEC and DF34_DEC should be uneven.
- As well as the types above, there are also the obsolete predefined data 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 automatically filled with the scaling and during reading, the scaling is automatically taken from it.
- 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 numbers, 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 displayed places in the mantissa is recommended.
This can be specified using the predefined 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 which 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. In
arithmetic SQL expressions, decimal floating point numbers are not supported.
The STYLE
addition after
WRITE [TO]
and the STYLE
formatting option in
embedded expressions are available for the formatting of decimal floating numbers in programs. These overwrite the output style defined in ABAP Dictionary.