If you use one of the decimal floating point data types when creating a domain in the ABAP Dictionary, you must define the output style. With the output style, you specify whether commercial notation (minus sign as a postfix), mathematical notation (minus sign as a prefix), or one of three possible exponential notations is used.
If the field has currency semantics, the system admits only commercial notation. In this case there is a variant of the commercial notation which enforces a strict currency-dependent limit on the number of decimal places during output and input.
The following styles for the output are supported:
Style | Description |
---|---|
Mathematical notation (Normal) |
If the value is negative, the sign is output as a prefix. If the absolute value is so large that the output needs more characters than the default output length, the system automatically switches to scientific notation. This does not involve rounding. This output style is the default. Short form: Simple |
Commercial notation (Sign right) |
If the value is negative, the sign is output as a postfix. If the output needs more characters than the default output length, the system does not switch to scientific notation, but terminates with a short dump. Short form: Sign as postfix |
Scale-preserving notation |
The output format is the same as if you perform a MOVE from DECFLOAT to type STRING, but the user-specific decimal point and thousands separators are used. The length of the output is at most 46. The primary advantage of this output style is that trailing zeros of the fractional part are not cut off. It is guaranteed that a conversion back to the DECFLOAT type recovers not just the original value, but also the scale. Short form: Scale-preserving |
Scientific notation |
The output always has an exponent. The exponent has at least two digits and always has a sign. The integer part of the mantissa is in the range [1..9] (unless the value to be output is zero). Short form: Scientific |
Scientific notation with a leading zero (Scientific with leading zero) |
Compared with the Scientific output style, the difference is that the integer part of the mantissa is always zero. Short form: Scientific with leading zero |
Scale-preserving scientific notation |
The output has an exponent. To achieve vertically adjusted output, the exponent has 3 digits for the type DECFLOAT16 and 4 digits for the type DECFLOAT34. The exponent always has a sign. The integer part of the mantissa is in the range [1..9]. Short form: Scale-preserving scientific |
Engineering notation |
This is a variant of the scientific notation in which the exponent is a multiple of 3. The integer part of the mantissa is in the range [1..999]. Short form: Engineering |
Monetary amount in commercial notation (Enhanced Currency Amount) |
A field with this output style must have a reference field of the domain /ISCER/CURRENCY. The reference field specifies the minimum number of decimal places that are output (in analogy to the UNIT key for the type QUAN). The reference field does not impose a limit on the number of decimal digits which can be input. Short form: Extended monetary |
Monetary amount in commercial notation with strict limit on the decimal places (Currency Amount) |
A field with this output style must have a reference field of the domain /ISCER/CURRENCY, which specifies the maximum number of decimal places that can be output and input. This number is at the same time the minimum number of decimal places which are output. Short form: Monetary |
When using Scientific notation, it is best to limit the number of mantissa digits displayed. This can be achieved by calling the RESCALE function with the argument prec being the number of mantissa digits to be output. If vertically adjusted decimal points and exponents are required, the scale-preserving scientific notation has to be used.
For input, all formats that are accepted by a MOVE from type C to a DECFLOAT type are allowed, but the character for the decimal point has to be the same as when inputting a DEC-value. Additionally, thousands separators can be used. If rounding is necessary, the value is not accepted. There is no other limit on the number of digits or decimal places unless Currency Amount has been specified. In analogy to existing P-based types, a minus sign is allowed both as a prefix and postfix. If the input contains an exponent, the sign is allowed as a prefix only. During input, the system normalizes the values unless a scale-preserving notation is specified.
If you hit the return key, in most cases the system redisplays the value in normalized form.
Constraints for the output length of DECFLOAT types:
The default values for the output length are 24 (DECFLOAT16) and 46 (DECFLOAT34).
For more information, see the ABAP Keyword documentation.
Constraints
The are two output styles that are allowed for monetary amounts:
With Web Dynpro ABAP and with classical Dynpro, the number of decimal places is limited according to the currency.
There is no special limit on the number of decimal places.
When specifying a reference field, the system checks whether the reference field is of the domain /ISCER/CURRENCY. For each currency, the number of decimal places is stored in the database table /ISCER/C_CUR. If the output style is not Currency Amount or Enhanced Currency Amount, you have three options for the reference field:
If a DECFLOAT field has a reference field of type UNIT or /ISQC/UNIT, this has no effect on the output on Web Dynpro ABAP and the classical Dynpro.
If a DECFLOAT field with the Currency Amount output style is output on a classical Dynpro, you must round the value according to the currency before the value is output.
Here is an example of the various output styles:
Input | -12.30 | -12.3456 | -1230E1 |
---|---|---|---|
Commercial notation |
12.3- |
12.3456- |
12,300- |
Mathematical notation |
-12.3 |
-12.3456 |
-12,300 |
Scale-preserving notation |
-12.30 |
-12.3456 |
-1.230E+4 |
Scientific notation |
-1.23E+01 |
-1.23456E+01 |
-1.23E+04 |
Scientific notation with a leading zero |
-0.123E+02 |
-0.123456E+02 |
-0.123E+05 |
Scale-preserving scientific notation |
-1.230E+0001 |
-1.23456E+0001 |
-1.230E+0004 |
Engineering notation |
-12.3E+00 |
-12.3456E+00 |
-12.3E+03 |
There is a limit on the decimal places for currencies. When inputting a monetary amount, the user expects that the number of decimal places is limited according to the currency used. This requirement is covered by output style Currency Amount. Before output, you must round the value accordingly, otherwise there is a short dump. This also holds if the field is not an input field. The side effect of this policy is that the output is right-adjusted.