Skip to content

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

Source Field Type i, (b, s)

Types b and s are internal and cannot be specified directly in ABAP statements. Self-defined data types and data objects in ABAP programs have the data types b or s if they have been defined with reference to data elements in ABAP Dictionary that have the external data types INT1 or INT2.

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Fields

Target Conversion
i, (b, s) If an assignment is made to the same data type, the content is passed unconverted. Otherwise, the value of the integer is converted to the internal representation of i,(b, s) . If thevalue range of the internaldata types i, b, or s is exceeded, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
p The value of the integer is converted into the internal format of a packed number. If the value range of the target field is too small, a handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
decfloat16, decfloat34 The value of the integer is converted to internal representation of a decimal floating point number with scaling 0.
f The value of the integer is converted into the internal format of a binary floating point number.

Character-Like Target Fields

Target Conversion
c The value of the integer is formatted in businessnotation and passed right-aligned and without decimal separators into the target field. The character"-" is set at the last position for a negative value, and a blank is set for a positive value. If thetarget field is longer than the sequence of digits, including the plus/minus sign, the field is paddedwith blanks to the left. If it is too short, the number representation is moved to the right - in thecase of positive values. If the target field is still too short (for negative values) and truncated on the left for the types i,(b, s) and the character "*" is set at the first position of the target field.
string The value of the integer is formatted in business notation and passed, without gaps and without decimal separators, to the target field.The character "-" is set at the last position for a negative value, and a blank is set for a positivevalue. The resulting length of the target field is determined by the number of digits plus the minus sign or blank character.
n The absolute value of this integer number is passed as a character string and right-aligned to thetarget field. If the target field is longer than the character string, the field is padded with zeros from the left. If it is too short, the values to the left are cut off.
d If the value of the integer is between 1 and 3,652,060, it is interpreted as the number of dayssince 01.01.0001 and the resulting date is put in the target field in the format "yyyymmdd". If the value lies outside this range, the target field is padded with the character "0".
t The value of the integer is divided by the number of seconds in a day (86,400) and the whole numberof the divide remainder is interpreted as the number of seconds since midnight. The resulting time is put in the target field in the format "hhmmss".


Notes

  • The assignment of the value 0 to a target field of type d does not result in the value "00010101" for 01.01.0001, but rather in "0000000" for an invalid date. The earliest valid date that can be created by assigning a number is 02.01.0001 by assigning the number 1.

  • Converting 577,736 to a target field of type d results in 4.10.1582, and converting 577,737 results in 15.10.1582. The dates for the intermediate days, which were lost during the switch from the Julian to the Gregorian calendar, cannot be attained by assigning a numerical value to a target field of type d.

Byte-Like Target Fields

Target Conversion
x Data objects of the types b or s are convertedin the internal representation from data type i. The four bytes of the data type i are positioned in the target field so that they are right-aligned and inbig endian order. If thetarget field is too long, it is padded to the left with hexadecimal 0s. If it is too short, it is truncated from the left.
xstring Data objects of the types b or s are convertedin the internal representation from data type i. The four bytes of the data type i are positioned in the target field so that they are inbig endian order. In thisrepresentation, positive values have one, two, three, four, or eight bytes. Negative values always requirefour or eight bytes. For positive values, the leading zeros before the fourth or eighth byte are nottransported. Therefore, the resulting length of the target field is one byte for data type b,one, two, or four bytes for data type s, and one, two, three, or four bytes for data type i.


Note

With the conversion of the data types b and s to x and xstring, it is important to note that during the prior conversion to iand also during the conversion of i to xstring, the leading zeros have been truncated. To ensure the result is correct, it is recommended that only the data types i, b, and s are converted to fields of type x and length 4 and then used. For example, negative values in a field of data type s always require four bytes during the conversion to x or xstring and not the potentially expected two bytes, resulting in unexpected results in the target field of length 2.


Continue

Conversion of Integer Numbers to Bytes - Example