With Release 7.40 ABAP supports so called constructor operators. Constructor operators are used in constructor expressions to create a result that can be used at operand positions. The syntax for constructor expressions is

… operator type( … ) …

operator is a constructor operator. type is either the explicit name of a data type or the character #. With # the data type can be dreived from the operand position if the operand type is statically known. Inside the parentheses specific parameters can be specified.

## Lossless Operator EXACT

The lossless operator EXACT is a constructor operator that exceutes either a lossless calculation or a lossless assignment.

- … EXACT dtype|#( arith_exp ) …

arith_exp is an arithmetic expression that is calculated lossless with calculation type decfloat34 and the result is converted to the specified type. - … EXACT dtype|#( arg ) …

arg is**not**an arithmetic expression and its value is assigned to the result of the specified type according to the rules for lossless assignments.

### Lossless calculations

Lossless calculations were introduced for decimal floating point numbers in Release 7.02 with the addition EXACT to COMPUTE. This addition (better the whole statement COMPUTE) became obsolete now.

A lossless calculation must not perform any roundings. If it does, an exception occurrs.

#### Example

TRY.

DATA(r1) = EXACT decfloat34( 3 / 2 ).

cl_demo_output=>write( |Exact: { r1 }| ).

CATCH cx_sy_conversion_rounding INTO DATA(e1).

cl_demo_output=>write( |Not exact: { e1->value }| ).

ENDTRY.

TRY.

DATA(r2) = EXACT decfloat34( 3 / 7 ).

cl_demo_output=>write( |Exact: { r2 }| ).

CATCH cx_sy_conversion_rounding INTO DATA(e2).

cl_demo_output=>write( |Not exact: { e2->value }| ).

ENDTRY.

cl_demo_output=>display( ).

The output is:

Exact: 1.5

Not exact: 0.4285714285714285714285714285714286

You see that the non-exact result can be found in th exception object.

### Lossless assignments

Lossless assignments were introduced for conversions in Release 7.02 with the addition EXACT to MOVE. This addition (better the whole statement MOVE) became obsolete now.

A lossless assignment is an assignment where

- the value of the source is valid for its type
- there are no data losses during the assignment
- the converted value of the target is valid for its type

#### Example

TYPES numtext TYPE n LENGTH 10.

cl_demo_output=>write( CONV numtext( ‘4 Apples + 2 Oranges’ ) ).

TRY.

DATA(number) = EXACT numtext( ‘4 Apples + 2 Oranges’ ).

CATCH cx_sy_conversion_error INTO DATA(exc).

cl_demo_output=>write( exc->get_text( ) ).

ENDTRY.

cl_demo_output=>display( ).

The result is

0000000042

The argument ‘4 Apples + 2 Oranges’ cannot be interpreted as a number

The infamous conversion rule from c to n is not supported by EXACT.

Jacques NomssiHello Horst,

I can check if a DECFLOAT.. parameter

lv_numis an integer withbut it EXACT seems safer:

but is EXACT needed in to check if a parameter

value(of type ANY) is numeric?best regards,

JNN