• The EXACT operator enforces either a lossless assignment or a lossless calculation depending on the data object specified within the parentheses and creates an appropriate result.
• Ordinary assignments using MOVE logic can sometimes produce unexpected results if the value assigned to a field does not match its type.
DATA: lv_var TYPE numc4.
lv_var = ‘3ABC’.
output: 0003
• To prevent such errors, you can use the EXACT operator, which ensures that the value you are assigning to the field fits the target field with no losses. If the assignment can not be performed without loss of data, an exception occurs and can be caught with exception CX_SY_CONVERSION_ERROR.Â
DATA: lv_var TYPE numc4.
TRY.
lv_var = EXACT #(‘3ABC’)
CATCH CX_SY_CONVERSION_ERROR
ENDTRY.Â
 output: exception raised
Please share with your ABAP friends and follow us.
If you want to dive deeper, visit our course https://lnkd.in/d35uqwud
Comentários