Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Lossless Assignments →  Lossless Assignments - Rules →  Checking Elementary Data Objects 

Suitable Values for Lossless Assignments

When an elementary argument of the operator EXACT is converted to an incompatible elementary data type, the argument must contain a value suitable for the target type as shown in the following tables. This avoids loss of values and provides a valid value for the target type.

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Types

Target Type with Numeric Type (Except f)

Argument Suitable Values
Numeric data type Numbers from the value range of the target type that do not have to be rounded. Inappropriate valuesraise exceptions from the class CX_SY_CONVERSION_ROUNDING or CX_SY_CONVERSION_OVERFLOW.
character-like data type Numbers from the value range of the target type that do not have to be rounded. In arguments of type c or string, appropriate numberrepresentations determined after applying theconversion rules are allowed if their valuelies within the value range and does not have to be rounded. Arguments of type cor string are also allowed if they contain only blanks or empty strings.Arguments of type n can contain as many digits after leading zeroes thatare allowed within the value range. Inappropriate values raise exceptions from the class CX_SY_CONVERSION_ROUNDING or CX_SY_CONVERSION_OVERFLOW.
byte-like data type Not allowed
Date type,time type, or time stamp type In arguments of types d and t, allvalid date and times (if specified) areallowed; however they cannot be assigned to the target types b and s. Inappropriate values raise exceptions from the class CX_SY_CONVERSION_ROUNDINGor CX_SY_CONVERSION_OVERFLOW. The time stamp type utclong is not allowed.


Example

The second lossless assignment raises an exception because values would have to be rounded.

DATA(result1) = EXACT i( '123' ). 

DATA(result2) = EXACT i( '123.4' ).

Target Type of Type f

Argument Suitable Values
Numeric data type Integers with a maximum of 15 digits. In arguments of type i(b, s), all values are allowed. In arguments oftypes int8, p, decfloat16,and decfloat34, a maximum of 15 places, but no decimal places are permitted. Inappropriate values raise an exception from class CX_SY_CONVERSION_INEXACT_FLTP.
character-like data type Integers with a maximum of 15 digits. In arguments of type c or string, numbers can be expressed inscientific notation.The values are integers with a maximum of 15 places. Arguments of type cor string are also allowed if they contain only blanks or empty strings.Arguments of type n can contain up to 15 digits after leading zeroes. Inappropriate values raise an exception from class CX_SY_CONVERSION_INEXACT_FLTP.
byte-like data type Not allowed
Date type,time type, or time stamp type In arguments of types d and t, allvalid specified dates and times are allowed.Inappropriate values raise an exception from class CX_SY_CONVERSION_NO_DATEor CX_SY_CONVERSION_NO_TIME The time stamp type utclong is not allowed.


Example

The second lossfree assignment raises an exception because the value of the argument is not a whole number.

DATA(result1) = EXACT f( '3.33E+2' ). 

DATA(result2) = EXACT f( '3.33E+1' ).

Character-like target types

Target Type of Type c

Argument Suitable Values
Numeric data type Numbers for which the result from the conversionto type c is not longer than the target type; the result cannot be rounded.Positive signs represented as blanks are ignored. Inappropriate values raise exceptions from classes CX_SY_CONVERSION_OVERFLOW or CX_SY_CONVERSION_ROUNDING.
character-like data type Character strings not longer than the target type. In arguments of type c,trailing blanks are ignored. In arguments of type string, no characters areignored, including trailing blanks. Inappropriate values raise an exception from class CX_SY_CONVERSION_DATA_LOSS.
byte-like data type Byte chains for which the result from the conversionto type c is not longer than the target type. Inappropriate values raise an exception from class CX_SY_CONVERSION_DATA_LOSS.
Date type,time type, or time stamp type Valid date, time, or time stamp information.The result of the conversion must not be longer than the target type. Values that are too long raise an exception from class CX_SY_CONVERSION_DATA_LOSS.


Example

The second lossless assignment raises an exception because the character string would have to be truncated.

TYPES c4 TYPE c LENGTH 4. 

DATA(result1) = EXACT c4( 'abcd' ). 

DATA(result2) = EXACT c4( 'abcdef' ).

Target Type of Type string

Argument Suitable Values
Numeric data type Any valid numbers.
character-like data type Any character strings.
Byte-like data type Any byte chains.
Date type,time type, or time stamp type Any valid date, time, or time stamp information.


Example

This program section never raises an exception.

DATA text TYPE c LENGTH 80 VALUE 'Never say never again'. 
cl_demo_input=>request( CHANGING field = text ). 

DATA(result) = EXACT string( text ).

Target Type of Type n

Argument Suitable Values
Numeric data type Positive integers including 0, in which the number of digits does not exceed the length of the targettype. Inappropriate values raise exceptions from classes CX_SY_CONVERSION_OVERFLOW or CX_SY_CONVERSION_ROUNDING.
character-like data type A closed string of digits that cannot be longer than the target type (excluding the leading zeroes).Arguments of type c and string can contain additionalleading and trailing blanks. Inappropriate values raise exceptions from classes CX_SY_CONVERSION_NO_NUMBER or CX_SY_CONVERSION_OVERFLOW.
byte-like data type Not allowed
Date type,time type, or time stamp type. Arguments of type d and t cannot contain blanksand the target type must have the same length as the source fields. Inappropriate values raise exceptionsfrom classes CX_SY_CONVERSION_NO_NUMBER or CX_SY_CONVERSION_OVERFLOW. The time stamp type utclong is not allowed.


Example

The second lossfree assignment raises an exception because not enough places are available for all digits.

TYPES n8 TYPE n LENGTH 8. 

DATA(result1) = EXACT n8( 12345678 ). 

DATA(result2) = EXACT n8( 1234567890 ).

Byte-Like Target Types

Target Type of Type x

Argument Suitable Values
Numeric data type Not allowed
Character-like data type An even number of characters between "0" and "9" and "A" and "F" in a closed sequence. The numberof bytes represented must correspond exactly to the length of the target type. Other characters arenot allowed; the only exception is that trailing blanks in arguments of type care ignored. Arguments of the type n are not allowed. Inappropriate valuesraise exceptions from classes CX_SY_CONVERSION_SRC_TOO_SHORT, CX_SY_CONVERSION_DATA_LOSS, or CX_SY_CONVERSION_NO_RAW.
byte-like data type A byte chain that has exactly the same length as the target type. Inappropriate values raise exceptionsfrom classes CX_SY_CONVERSION_SRC_TOO_SHORT or CX_SY_CONVERSION_DATA_LOSS.
Date type,time type, or time stamp type Arguments of the types d, t, and utclong are not allowed.


Example

The second lossless assignment raises an exception because the byte string would have to be truncated.

TYPES hex TYPE x LENGTH 1. 

DATA(result1) = EXACT hex( 'FF' ). 

DATA(result2) = EXACT hex( 'FFFF' ).

Target Type of Type xstring

Argument Suitable Values
Numeric data type Not allowed
Character-like data type An even number of characters between "0" and "9" and "A" and "F" in a closed sequence. Other charactersare not allowed; the only exception is that trailing blanks in arguments of type care ignored. Arguments of the type n are not allowed. Inappropriate values raise an exception from class CX_SY_CONVERSION_NO_RAW.
byte-like data type A byte chain of any length.
Date type,time type, or time stamp type Arguments of the types d, t, and utclong are not allowed.


Example

The second lossless assignment raises an exception because the number of characters is uneven.

DATA(result1) = EXACT xstring( 'FF' ). 

DATA(result2) = EXACT xstring( 'FFF' ).

Date/Time Types as Target Types

Target Type of Type d

Argument Suitable Values
Numeric data type Positive integers between 0 and 3652060 (which corresponds to the date 12/31/9999). Inappropriatevalues raise exceptions from classes CX_SY_CONVERSION_OVERFLOW or CX_SY_CONVERSION_ROUNDING.
character-like data type A left-justified valid date specifiedwith the format "yyyymmdd". Arguments of type n and stringcan contain these eight digits only. Arguments of type c can also containtrailing blanks. Inappropriate values raise an exception from class CX_SY_CONVERSION_NO_DATE.
byte-like data type Not allowed
Date type,time type, or time stamp type Valid date specification in an argument of type d. An argument of type t or utclong is not allowed.


Example

The second lossless assignment raises an exception because the date is invalid.

DATA(result1) = EXACT d( '20160729' ). 

DATA(result2) = EXACT d( '20160700' ).

Target Type of Type t

Argument Suitable Values
Numeric data type Positive integers between 0 and 86399 (which corresponds to the time 23:59:59). Inappropriate valuesraise exceptions from classes CX_SY_CONVERSION_OVERFLOW or CX_SY_CONVERSION_ROUNDING.
character-like data type A left-justified valid time specifiedwith the format "hhmmss". Arguments of type n and stringcan contain only these six digits. Arguments of type c can also contain trailingblanks. Inappropriate values raise an exception from class CX_SY_CONVERSION_NO_TIME.
byte-like data type Not allowed
Date type,time type, or time stamp type Valid time specification in an argument of type t. An argument of type d or utclong is not allowed.


Example

The second lossless assignment raises an exception because the numerical value exceeds the number of seconds for a day.

DATA(result1) = EXACT t( 10000 ). 

DATA(result2) = EXACT t( 100000 ).

Target Type of Type utclong

Argument Suitable Values
Numeric data type Not allowed
Character-like data type A left-justified valid character-like representationof a time stamp, such as "yyyy-mm-ddThh:mm:ss.fffffff" or an initial valuewith any number of trailing blanks. Inappropriate values raise an exception from class CX_SY_CONVERSION_NO_DATE_TIME. Arguments of type n are not allowed.
byte-like data type Not allowed
Date type,time type, or time stamp type Valid time stamp in an argument of type utclong. Arguments of type d or t are not allowed.


Example

A character string composed correctly can be assigned to a time stamp without loss.

CONVERT UTCLONG utclong_current( ) 
        INTO DATE DATA(dat) 
             TIME DATA(tim) 
             FRACTIONAL SECONDS DATA(fs) 
             TIME ZONE sy-zonlo. 

DATA(ts) = EXACT utclong( |{ dat DATE = ISO } { 
                             tim TIME = ISO }{ 
                             shift_left( val = |{ fs }| 
                                        places = 1 ) }| ).