sapdev logo background
sapdev logo sapdev logo
Comments

ABAP MOVE EXACT Statement syntax, information and example SAP source code



Return to Statement index



Lossless Assignments - Rules
A lossless assignment checks the assigned content, before its conversion to an incompatible target object, to see whether the assignment is possible without data loss. This means:
the value is checked to see whether it is a valid value for the data type of the source
whether a conversion to the target field can result in a loss of values
whether the value is valid for the target field after conversion
If the source contains a valid value and no values are lost, the conversion is performed in accordance with the associated conversion rules . Otherwise no assignment is made. If it is statically detectable that one of the prerequisites is not met, a syntax error occurs. If this violation is not identified until the program is executed, a handleable exception is raised. The exception class of this exception is generally a subclass of CX_SY_CONVERSION_ERROR .
The following sections outline which rules are used by the operator EXACT when checking the content of its argument with respect to the data types involved:
Checks elementary data objects
Checks structures
Checks internal tables
If an exception is raised as a result of an invalid or inappropriate value, the VALUE attribute of the exception object is assigned this value in character form; this value is generally also included in the exception text.
No checks are made for:
  • compatible data types

  • The content of the argument is passed to the return value without being converted, even if it already contains an invalid value.
  • Reference Variables

  • Checks on the content of a reference variable using EXACT are not useful. This is because nothing is converted and the content is either assignable or not assignable, as specified by the assignment rules for reference variables
    .
    A syntax check warning is produced if it is determined (statically) that no checks are performed for the combination of argument and target type, so making EXACT superfluous.

    Latest notes: Since lossless checks are only performed for conversions to incompatible data types, it is best to only use the operator EXACT
    to fill data objects that should only be given valid objects. Other types of assignments that require a start value to be specified in the declaration using VALUE can generate invalid values that are then not recognized when a lossless assignment is made to a compatible target field.
    Example ABAP Coding See Lossless Assignment .
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    MOVE_CAST
    MOVE_EXCEPTIONS




    comments powered by Disqus