Skip to Content

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.


    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 }| ).

    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 }| ).

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


TYPES numtext TYPE n LENGTH 10.

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

    DATA(number) = EXACT numtext( ‘4 Apples + 2 Oranges’ ).
  CATCH cx_sy_conversion_error INTO DATA(exc).
  cl_demo_output=>write( exc->get_text( ) ).

cl_demo_output=>display( ).

The result is


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.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Jacques Nomssi

    Hello Horst,

    I can check if a DECFLOAT.. parameter lv_num is an integer with

      IF frac( lv_num ) NE 0.
    "    throw exception...

    but it EXACT seems safer:

          DATA(lv_int) = EXACT int8( lv_num ).  " check lossless assignment
        CATCH cx_sy_conversion_error INTO DATA(exc).
          cl_demo_output=>write( exc->get_text( ) ).

    but is EXACT needed in to check if a parameter value (of type ANY) is numeric?

    * Assume value is numeric if it can be converted to a decfloat34
              DATA(lv_num) = EXACT decfloat34( value ) ##needed. " is it a number
            CATCH cx_sy_conversion_no_number.
             " NaN


    best regards,




Leave a Reply