Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Assignment and Conversion Rules →  Conversion Rules for Elementary Data Objects →  Byte-Like Source Fields 

Source Field Type x

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Fields

Target Conversion
i, (b, s) Only the last 4 bytes of the source field are converted. If the source field is shorter than 4 bytes,it is made longer on the left with the hexadecimal 0 until it is 4 bytes long. The content of thesebytes is interpreted as a number stored in big endian order, of type i. Thehexadecimal values from "00000000" to "7FFFFFFF" are assigned to numbersfrom +0 to +2147483647 and the hexadecimal values from "80000000" to "FFFFFFFF" are assigned to the numbers -2147483648 to -1. The numbers obtained in this way are converted in the internal representation of the corresponding integer. If thevalue range of data typesb or s is not sufficient, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
int8 Only the last 8 bytes of the source field are converted. If the source field is shorter than 8 bytes,it is made longer on the left with the hexadecimal 0 until it is 8 bytes long. The content of thesebytes is interpreted as a number stored in big endian order, of type int8.The hexadecimal values from "0000000000000000" to "7FFFFFFFFFFFFFFF" areassigned to numbers from +0 to +9223372036854775807 and the hexadecimal values from "8000000000000000"to "FFFFFFFFFFFFFFFF" are assigned to the numbers --9223372036854775808to -1. The numbers obtained in this way are converted in the internal representation of the corresponding integer.
p The content of the source field is converted first to data type i (seeabove) and then to type p (see conversion table for source field type i, int8,(b, s)).
decfloat16, decfloat34 The content of the source field is first converted into data type i (seeabove) and then into type decfloat16 or decfloat34(see conversion table for source field type i, int8,(b, s)).
f The content of the source field is converted first to data type i (seeabove) and then to type f (see conversion table for source field type i, int8,(b, s)).


Example

The result of the following conversion has the value 10000.

DATA hex TYPE x LENGTH 2 VALUE '2710'. 

DATA(result) = CONV i( hex ). 

Character-Like Target Fields

Target Conversion
c The values of each half-byte in the source field are converted to the hexadecimal characters "0"to "9" and "A" to "F" and passed left-justified to the target field. If the target field is longer thanthe number of characters passed, it is padded on the right with blank characters. If it is too short, the number is truncated on the right.
n The content of the source field is converted first to data type i (seeabove) and then to type n (see conversion table for source field type i, int8,(b, s)).
string The values of each half-byte in the source field are converted to the hexadecimal characters "0"to "9" and "A" to "F" and placed in the target field. The resulting length of the target field is determined by the number of characters passed.


Example

The string produced by the conversion is 27. Two characters 10 are cut off on the right.

DATA hex TYPE x LENGTH 2 VALUE '2710'. 

TYPES c2 TYPE c LENGTH 2. 
DATA(result) = CONV c2( hex ). 

Byte-Like Target Fields

Target Conversion
x The bytes in the source field are passed left-justified to the target field. The length of the targetfield is specified by the number of bytes passed. If the target field is shorter, it is truncated on the right.
xstring The bytes in the source field are placed in the target field. The resulting length of the target field is determined by the number of bytes passed.


Example

The byte chain produced by the conversion is 27100000.

DATA hex2 TYPE x LENGTH 2 VALUE '2710'. 

TYPES hex4 TYPE x LENGTH 4. 
DATA(result) = CONV hex4( hex2 ).

Date/Time Fields as Target Fields

Target Conversion
d The content of the source field is converted first to data type i (seeabove) and then to type d (see conversion table for source field type i, int8,(b, s)).
t The content of the source field is converted first to data type i (seeabove) and then to type t (see conversion table for source field type i, int8,(b, s)).
utclong Not supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED.


Example

The value of the time field produced by the conversion is 024640 (or 10000 seconds after midnight).

DATA hex TYPE x LENGTH 2 VALUE '2710'. 

DATA(result) = CONV t( hex ).