Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Assignment and Conversion Rules →  Conversion Rules for Elementary Data Objects →  Date fields, time fields, and time stamp fields as source fields 

Source Field Type t

The conversion rules are designed in such a way that, when data objects of time type t are assigned to character-like data objects, they behave like character-like data objects. When assigned to numeric data objects, they behave as numeric data objects. The latter is used as the basis for calculating time in arithmetic expressions. If the content of data objects of type t are time entries in the format "hhmmss", and the values only correspond to valid times of day (hh is between 00 and 23, mm and ss are between 00 and 59), the value assigned to a numeric data object corresponds to the number of seconds since midnight.

Although the conversion rules actually permit the assignment of time fields that contain invalid data, this is not recommended.

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Fields

Target Conversion
i, int8, (b, s) If the source field contains only digits, the content is interpreted as a time entry in the format"hhmmss" from which the value hh3600+mm60+ss is calculated, which isthen converted into the internal representation of the relevant integer number. If the source field does not only contain digits, the target field is given the value 0. If thevalue range of the internaldata types b and s is not sufficient, a treatable exception CX_SY_CONVERSION_OVERFLOW is raised.
p If the source field contains only digits, the content is interpreted as a time entry in the format"hhmmss" from which the value hh3600+mm60+ss is calculated, which isthen converted into the internal representation of a packed number. If the value range of the targetfield is too small, a treatable exception CX_SY_CONVERSION_OVERFLOW is raised. If the source does not contain only digits, the target field receives the value 0.
decfloat16, decfloat34 If the source field contains only digits, the content is interpreted as a time entry in the format"hhmmss" from which the value hh3600+mm60+ss is calculated, which is then converted into the internal representation of a decimal floating point number withscaling of 0. If the source does not contain only digits, the target field is given the value 0.
f If the source field contains only digits, the content is interpreted as a time entry in the format"hhmmss" from which the value hh3600+mm60+ss is calculated, which isthen converted into the internal representation of a binary floating point number. If the source does not contain only digits, the target field is given the value 0.


Example

The result of the following conversion has the value 66656. This is the number of seconds of the specified time since midnight.

DATA tim TYPE t VALUE '183056'. 

DATA(result) = CONV i( tim ). 

Character-Like Target Fields

Target Conversion
c Content is handled in the same way as a source field of type c
n The characters in the source field are inserted in the target field, left-aligned. Trailing blanksin the source field are transferred. If the target field is longer than the source field, it is filled out to the right with the character "0". If the target field is shorter, it is truncated from the right.
string Content is handled in the same way as a source field of type c


Example

The string produced by the conversion is 18. Four characters 3056 are cut off on the right.

DATA tim TYPE t VALUE '183056'. 

TYPES n2 TYPE n LENGTH 2. 
DATA(result) = CONV n2( tim ). 

Byte-Like Target Fields

Target Conversion
x The content of the source field is converted first to data type i (seeabove) and then to type x (see conversion table for source field type i, int8,(b, s)).
xstring The content of the source field is converted first to data type i (seeabove) and then to type xstring (see conversion table for source field type i, int8,(b, s)).


Example

The byte chain produced by the conversion is 010460. This is the integer 66655 or the number of seconds since midnight.

DATA tim TYPE t VALUE '183056'. 

DATA(result) = CONV xstring( tim ). 

Date/Time Fields as Target Fields

‚ÄéTarget Conversion
d Not supported. Produces a syntax error or runtime error.
t The content of the source field is transferred unconverted.
utclong Not supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED.


Example

The conversion of t to d (not known statically) is not supported and produces the runtime error MOVE_NOT_SUPPORTED.

FIELD-SYMBOLS <fs> TYPE data. 

ASSIGN sy-uzeit TO <fs>. 
DATA(result) = CONV d( <fs> ).