SAP CONVERSION INT TO HEX ABEXA



Get Example source ABAP code based on a different SAP table
  



Conversion of Integer Numbers to Bytes
This example demonstrates the conversion of integers into byte fields and byte strings.

ABAP_SOURCE_CODE
DEMO CL_DEMO_INT_TO_HEX

ABAP_DESCRIPTION
The class assigns numbers of the data types b, s, and i and int8, which cover the entire value range, to byte fields with the lengths 1, 2, 4, and 8 as well as to a byte string and displays them.
To calculate the numbers with powers of two, the use of the calculation type decfloat34 is forced in some cases to avoid overflows when assigning the results of the function ipow to interim results of the calculation type i or int8.
This example highlights the different lengths that can result from these assignments to byte strings. It also shows that, in the case of assignments of the type s to x, a field length of 4 bytes instead of only 2 bytes is required for negative numbers.