ABAP Keyword Documentation → ABAP - Reference → Assignments → Value Assignments → MOVE → MOVE EXACT → MOVE EXACT - Elementary Data Objects
Lossless Assignment
This example demonstrates the addition EXACT
of the statement MOVE
.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA: text TYPE string VALUE `4 Apples + 3 Oranges`,
num_text TYPE n LENGTH 8,
exc TYPE REF TO cx_sy_conversion_error.
MOVE text TO num_text.
MESSAGE num_text TYPE 'I'.
TRY.
MOVE EXACT text TO num_text.
CATCH cx_sy_conversion_error INTO exc.
MESSAGE exc TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
Description
Without the addition EXACT
, the string
is assigned to n
without the validity of the assigned value being checked with respect to the
conversion rules. This produces a value that it is not very intuitive, "00000043".
With the EXACT
addition, the value that is passed is checked and an exception is raised in the case in question.