Get Example source ABAP code based on a different SAP table
ABAP_ARITHEXP > - Lossless Calculations A lossless calculation> is a calculation of an arithmetic expression> in which no roundings occur. Lossless calculations can be performed using the lossless operator EXACT>> :
ABAP_SYNTAX ... EXACT type( arith_exp ) ...>. If the operand of the operator EXACT> is an arithmetic expression, the data type specified by type> must not be of type f>. arith_exp> must be an arithmetic expression simplified as follows:
The allowed arithmetic operators > are +>, ->, *>, and />. The operators DIV>, MOD>, and **> cannot be used.
The allowed built-in functions> are abs>, sign>, ceil>, floor>, trunc> , frac>, round>, and rescale>. These functions do not raise the exception CX_SY_CONVERSION_ROUNDING>. No other built-in functions can be specified because their results are not lossless in principle.
No operands of data type x> and xstring> can be specified.
No functional methods> can be specified, since the requirement for losslessness cannot be applied to the method execution.
Operands of the type f> (binary floating point numbers) are not allowed because they cannot represent every decimal number precisely, due to their internal representation. The operator EXACT> ensures that a simplified expression with the calculation type> decfloat34 > is calculated and checks whether roundings are performed. If no roundings occur, the result is assigned to the return value. If necessary, the result is converted from decfloat34> to the data type determined by type>. If a rounding is required by the calculation, the exception CX_SY_CONVERSION_ROUNDING>> is raised. Rounding can occur when operands are converted to the calculation type, during the calculation, or when the result is converted to the target field. The exception is raised when the first subexpression that requires a rounding is calculated. If the exception is handled, the exception object in the VALUE> attribute contains the result of a regular calculation. The attribute OPERATION> contains the first operation that had to be rounded, whereby conversions are represented by := >.
Latest notes:
If the operand of the operator EXACT> is not an arithmetic expression, the operator performs a lossless assignment>.
Since the first calculation in lossless calculations that requires rounding raises an exception, the behavior in arithmetic expressions that are mathematically identical but constructed in different ways can be different. NON_V5_HINTS
For this, see the executable example>.
The use of the addition EXACT> in the obsolete statement COMPUTE>> is an obsolete form of lossless calculation. ABAP_HINT_END
ABAP_EXAMPLE_VX5 The second arithmetic expression raises an exception, since it requires rounding to two decimal places. ABEXA 01121 ABAP_EXAMPLE_END