AS ABAP Release 758, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Programming Language → Processing Internal Data → Assignments → Lossless Assignments → Lossless Assignments, Rules → Checking Elementary Data Objects →Valid Values for Lossless Assignments
When a lossless conversion of an elementary argument of the operator EXACT to an incompatible data type is performed, the argument must, depending on its data type, represent a valid value according to the following tables:
Numeric Arguments
| Argument | Valid Values |
| i, int8, (b, s) | All content is valid. |
| decfloat16, decfloat34 | All values that can result from assignments and calculations in ABAP are valid. The special values that indicate infinity or invalid numbers are invalid. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_NUMBER. |
| p | All values that can result from assignments and calculations in ABAP are valid. If, however, the type has more decimal places than available places, this type is always invalid. (This means that the last half byte can contain only the hexadecimal values A, C, E, or F, for a positive sign, or B or D for a negative sign. The remaining half bytes can contain only the hexadecimal values 0 to 9.) If, however, the type has more decimal places than available places, this type is always invalid. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_NUMBER. |
| f | Integers with a maximum of 15 digits. |
Hint
Decimal numbers with decimal places cannot generally be represented precisely by binary floating point numbers of type f. The operator EXACT therefore restricts the valid value range to integers with a maximum of 15 places.
Example
The second lossless assignment raises an exception, caused by the attempt to convert a number with decimal places.
DATA arg TYPE f.
arg = 123.
FINAL(result1) = EXACT i( arg ).
arg = '123.456'.
FINAL(result2) = EXACT i( arg ).
Character-Like Arguments
| Argument | Valid Values |
| c, string | All content is valid. No check is made to determine whether a byte or string of bytes contains valid characters for the current code page. |
| n | The argument can only contain the digits 0 to 9 only. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_NUMBER. |
Example
The second lossless assignment raises an exception because numtext does not contain a valid value.
DATA numtext TYPE n LENGTH 6.
DATA time TYPE t.
numtext = time = '115500'.
FINAL(result1) = EXACT string( numtext ).
numtext = time = '1155__'.
FINAL(result2) = EXACT string( numtext ).
Byte-Like Arguments
| Argument | Valid Values |
| x, xstring | All content is valid. |
Example
The lossless assignment does not raise an exception for any of the randomly generated byte strings.
DATA hex TYPE x LENGTH 1.
FINAL(t) = cl_demo_date_time=>get_utc_time( ).
FINAL(rnd) = cl_abap_random_int=>create(
seed = CONV i( t ) min = 0 max = 1 ).
DO 8 TIMES.
SET BIT sy-index OF hex TO rnd->get_next( ).
ENDDO.
FINAL(result) = EXACT string( hex ).
Date Fields, Time Fields, and Time Stamp Fields as Arguments
| Argument | Valid Values |
| d | The argument must contain a valid date in the format yyyymmdd, for which the following values are possible: yyyy (year): 0001 to 9999, mm (month): 01 to 12, dd (day): 01 to 31. In addition, the initial value 00000000 is also a valid date. The value 00010101 is only a valid date in ABAP SQL and nowhere else in ABAP. The smallest valid value that corresponds to one day is 00010102. The values 15821005 to 15821014 are also invalid due to the switch from the Julian to the Gregorian calendar, where 04.10.1582 is followed directly by 15.10.1582. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_DATE. |
| t | The argument must contain a valid time in the format hhmmss, for which the following values are allowed: hh (hours): 00 to 23, mm (minutes): 01 to 59, ss (seconds): 01 to 59. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_TIME. |
| utclong | The argument must contain a value from the value range for utclong, meaning a valid time stamp, or be initial. Invalid values raise an exception from the class CX_SY_CONVERSION_NO_DATE_TIME. |
Hints
Example
The second lossless assignment raises an exception because date does not contain a valid value.
DATA date TYPE d.
date = '20160729'.
FINAL(result1) = EXACT i( date ).
date = '201607__'.
FINAL(result2) = EXACT i( date ).