‎2019 Nov 08 9:19 AM
Dear Experts,
I tried this code below to convert hex into string but why did the result is becoming ###
DATA conv TYPE REF TO cl_abap_conv_in_ce.
DATA buffer(4) TYPE x.
DATA text(100) TYPE c.
buffer = '02'. "
conv = cl_abap_conv_in_ce=>create(
encoding = 'UTF-8' ).
conv->convert(
EXPORTING input = buffer
IMPORTING data = text ).
Please advice.
Thanks
‎2019 Nov 13 3:54 AM
The answer is simply because the hex in abap is 16 bits and not the same with this one. everything in abap must be multiply by 100. If I adjust it then the # will not appear.
‎2019 Nov 08 9:23 AM
In ABAP debugger and many UIs in ABAP, non-characters (example: byte hexadecimal values "00" to "1F" converted to UTF-8) are often represented with:
#
‎2019 Nov 08 9:25 AM
‎2019 Nov 08 9:37 AM
Do you try the opposite ?
data hexa type xstring value '02'.
data(dec) = conv string( hexa ).
write dec.
dec = 2.
hexa = dec.
write hexa.
‎2019 Nov 08 9:39 AM
I do not see any problem. Your code works OK.
Your code is converting HEX value 02000000 (it is defined as X length 4 so it is = 02 00 00 00).
And result is corectly "control characte" U+0002. Which is not "printable" so SAP is displaying it as # in debugger.
Maybe you wanted to convert number 2 (DIGIT TWO) character ?
That is not 02 in HEX but 32 in HEX (U+0032). Check for example https://www.utf8-chartable.de/ or similar tables of HEX / UTF-8 characters...
‎2019 Nov 08 10:04 AM
In an ABAP Unicode system (any system with release >= 7.50 can only be Unicode), a character occupies two bytes. What you did is to convert four bytes with hexadecimal value 02.00.00.00 representing UTF-8 "characters" into ABAP characters. If your system is Unicode (UTF-16) big endian, you'll get four characters with hexadecimal value 0002.0000.0000.0000. With little endian: 0200.0000.0000.0000. You can see that in the debugger, you may display the hexadecimal representation of characters.
‎2019 Nov 13 3:54 AM
The answer is simply because the hex in abap is 16 bits and not the same with this one. everything in abap must be multiply by 100. If I adjust it then the # will not appear.