SAP CONVERSION TYPE DECFLOAT



Get Example source ABAP code based on a different SAP table
  



Source Field Type decfloat16, decfloat34
If the source field does not contain a valid decimal floating point number, the catchable exception CX_SY_CONVERSION_NO_NUMBER is raised, except in the case of assignments to another decimal floating point number. In ABAP, invalid decimal floating point numbers are also the special values +Infinity, -Infinity, NaN, and sNaN, which represent infinity or invalid numbers and are designated in standard IEEE-754-2008.
ITOC

Numeric Target Fields TargetConversion i, int8, (b, s)The value of the decimal floating point number is rounded up to an integer. If this number is within the value range for the data type i, int8, (b, s), it is converted to the internal representation of the corresponding integer. Otherwise, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. pThe value of the decimal floating point number is rounded to the number of decimal places in the target field. If this number is within the value range for the data type of the target field, it is converted to the internal representation of a packed number. Otherwise, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. decfloat16, decfloat34If an assignment is made to the same data type, the content is passed unconverted. In assignments from decfloat34 to decfloat16, the mantissa is truncated from 34 to 16 places and, if necessary, rounded commercially. If the mantissa of the target field is long enough, the scaling is preserved. If the value range of decfloat16 is exceeded, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. fThe value of the decimal floating point number is converted to the value of a binary floating point number. If the decimal number cannot be represented as a binary floating point number, the nearest value is used. If the value is outside the value range for binary floating point numbers, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised.

ABAP_EXAMPLE_VX5
The result of the following conversion has the rounded value 1234.57 .
ABEXA 00928
ABAP_EXAMPLE_END

Character-Like Target Fields TargetConversion cThe content of the source field is first converted to a mathematical notation or scientific notation, as described for the data type string. The result of this conversion is then passed right-aligned to the target field. If the target field is longer than the text string, it is padded on the left with blanks. If the target field is shorter than the text string, mathematical notation is converted to scientific notation and, if necessary, the mantissa is commercially rounded. If the length is not sufficient for at least one position of the mantissa, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. nThe value of the decimal floating point number is rounded up to an integer. The absolute value is passed to the target field as a right-aligned string of digits. If the target field is longer than the string of digits, the field is padded with zeros on the left. If it is too short, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. stringIf the exponent of the decimal floating point number is less than or equal to 0 and the absolute value of the number is greater than or equal to 1E-6, the floating point number is formatted in mathematical notation without gaps as follows: the string of digits consists of the mantissa of the decimal floating point number without leading zeros. If the exponent of the decimal floating point number is less than 0, a decimal point is set at the corresponding position. If the exponent of the decimal floating point number is greater than 0 or the absolute value of the number is less than 1E-6, the floating point number is formatted in scientific notation as follows: the mantissa is made up of the mantissa of the decimal floating point number without leading zeros. If the mantissa consists of more than one place, a decimal point is set after the first place. The exponent is always represented by a plus/minus sign and without leading zeros. In both representations, the minus sign is used for negative values but not for positive. Both representations are also used if the value of the decimal floating point number is 0. The maximum length of the target field is 24 for decfloat16 and 42 for decfloat34.



Latest notes:

The conversion rule for floating point numbers to text strings is as follows: a text string that was filled by the assignment of a decimal floating point number produces the same internal representation as in the original decimal floating point number (the scaling is preserved).
NON_V5_HINTS
The formatting options STYLE for the statement WRITE ... TO and STYLE for embedded expressions in string templates of string expressions provide additional formats for assignments of decimal floating point numbers to text strings.
ABAP_HINT_END

ABAP_EXAMPLES
The following table shows how decimal floating point numbers are converted to text strings: Floating Point NumberText String 123E+0123 123E+11.23E+3 2E+1 2E+1 1230E-2 12.30 5E-6 0.000005 50E-7 0.0000050 5E-7 5E-7 50E-8 5.0E-7 -0E+0 -0 0E-100 0E-100
ABAP_EXAMPLE_END

Byte-Like Target Fields TargetConversion xThe content of the source field is first converted to data type i (see above) and then to type x (see conversion table for source field type i, int8, (b, s)). xstringThe content of the source field is first converted to data type i (see above) and then to type xstring (see conversion table for source field type i, int8, (b, s)).

ABAP_EXAMPLE_VX5
The byte chain resulting from the conversion is 0000007C and matches the result of the conversion of the rounded number 124.
ABEXA 00929
ABAP_EXAMPLE_END

Date/Time Fields as Target Fields TargetConversion dThe content of the source field is first converted to data type i (see above) and then to type d (see conversion table for source field type i, int8, (b, s)). tThe content of the source field is first converted to data type i (see above) and then to type t (see conversion table for source field type i, int8, (b, s)). utclongNot supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED .

ABAP_EXAMPLE_VX5
The value of the time field resulting from the conversion is 100001 .
ABEXA 00930
ABAP_EXAMPLE_END