SAP CONVERSION TYPE IBS



Get Example source ABAP code based on a different SAP table
  



Source Field Type i, int8, (b, s)
Types b and s are internal and cannot be specified directly in ABAP statements. User-defined data types and data objects in ABAP programs have the data type b or s if they are defined with reference to data elements of the ABAP Dictionary, which have the external data types INT1 or INT2.
ITOC

Numeric Target Fields TargetConversion i, int8, (b, s)In 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 i , int8, (b, s). If the value range of the internal data types i, int8, b, or s is exceeded, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. pThe value of the integer is converted to the internal representation of a packed number. If the value range of the target field is too small, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. decfloat16, decfloat34The value of the integer is converted to internal representation of a decimal floating point number with scaling 0. fThe value of the integer is converted to the internal format of a binary floating point number.

ABAP_EXAMPLE_VX5
The integers 1 to 99999 can be converted to the type p with length 4 and two decimal places. (In this case, an exception is raised due to the value range being exceeded.)
ABEXA 00935
ABAP_EXAMPLE_END

Character-Like Target Fields TargetConversion cThe value of the integer is formatted in commercial notation and passed right-aligned and without a decimal separator to the target field. For a negative value, the character - is placed in the last position and for a positive value, a blank is placed there. If the target field is longer than the string of digits, including the plus/minus sign, it is padded with blanks on the left. If it is too short, the number representation is moved to the right by one place for positive values. If the target field is still too short (and for negative values), it is truncated on the left and the character * is set in the first position of the target field. nThe absolute value of this integer number is passed as a right-aligned string of digits to the target field. If the target field is longer than the string of digits, it is padded with zeros on the left. If it is too short, it is truncated on the left. stringThe value of the integer is formatted in commercial notation and passed, without gaps and without decimal separators to the target field. The character - is set in the last position for a negative value and a blank is set in the last position for a positive value. The resulting length of the target field is determined by the number of digits plus the place for the sign.
BEGIN_SECTION SAP_INTERNAL_HINT
In <(>NGAP<)>, an exception CX_SY_CONVERSION_OVERFLOW is raised, if the target field is too short for an int8 source field.
END_SECTION SAP_INTERNAL_HINT

ABAP_EXAMPLE_VX5
The string resulting from the conversion is 123-.
ABEXA 00936
ABAP_EXAMPLE_END

Byte-Like Target Fields TargetConversion xData objects of the types b or s are converted to the internal representation of data type i. The 4 or 8 bytes of the data types i and int8 are positioned in the target field so that they are right-aligned and in big endian order. If the target field is too long, it is padded on the left with hexadecimal 0. If it is too short, it is truncated on the left. xstring Data objects of the types b or s are converted to the internal representation of data type i. The 4 or 8 bytes of the data types i and int8 are positioned in the target field in big endian order. In this representation, positive values have 1, 2, 3, 4, or 8 bytes. Negative values always require 4 or 8 bytes. For positive values, the leading zeros before the fourth or eighth byte are not transported. Therefore, the resulting length of the target field is 1 byte for data type b , 1, 2, or 4 bytes for data type s and 1, 2, 3, 4, or 8 bytes for data type int8.



Latest notes:

In conversions of the data types b and s to x and xstring, it is important to note that the leading zeros are cut off in the previous conversion to i and also in the conversion of i to xstring. 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 4 bytes instead of the expected 2 bytes during the conversion to x or xstring. This can produce unexpected results in a target field of length 2. For fields of the type int8, possible target fields are of type x and length 8.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The byte chain resulting from the conversion is 01E240.
ABEXA 00937
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Conversion of Integer Numbers to Bytes
ABAP_EXAMPLE_END

Date/Time Fields as Target Fields TargetConversion dIf the value of the integer is between 1 and 3,652,060, it is interpreted as the number of days since 01.01.0001 and the resulting date is placed in the target field in the format yyyymmdd. If the value is outside this range, the target field is padded with the character 0. tThe value of the integer is divided by the number of seconds in a day (86,400) and the integer remainder of the division is interpreted as the number of seconds since midnight. The resulting time is placed in the target field in the format hhmmss. utclongNot supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED .



Latest notes:

The assignment of the value 0 to a target field of type d produces the value 0000000 for an invalid date and not 00010101 for 01.01.0001. The earliest valid date that can be created by assigning a number is 02.01.0001 by assigning the number 1.
Converting 577736 to a target field of type d produces 4.10.1582, and converting 577737 produces 15.10.1582. The dates for the intermediate days lost during the switch from the Julian to the Gregorian calendar cannot be created by assigning a numeric value to a target field of type d.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The value of the time field resulting from the conversion is 103045 .
ABEXA 00938
ABAP_EXAMPLE_END