<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conversion From Hex To Decimal in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076225#M1970455</link>
    <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/153394/frdricgirod.html"&gt;Frederic Girod&lt;/A&gt; Done. Everything merged into one answer.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Nov 2019 13:02:53 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2019-11-01T13:02:53Z</dc:date>
    <item>
      <title>Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076220#M1970450</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;
  &lt;P&gt;I have a code from #C from hex data type as follow&lt;/P&gt;
  &lt;P&gt;0x01 that will read in serial port as 01&lt;/P&gt;
  &lt;P&gt;How do you convert that into abap code?&lt;/P&gt;
  &lt;P&gt;DATA: x type i.&lt;/P&gt;
  &lt;P&gt;x = cl_abap_codepage=&amp;gt;convert_to( '0x02' )&lt;/P&gt;
  &lt;P&gt;The expected result should be 2&lt;/P&gt;
  &lt;P&gt;but I get 813183026&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 09:18:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076220#M1970450</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-01T09:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076221#M1970451</link>
      <description>&lt;P&gt;As  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; said several times, Hex or decimal is only the representation of the same data. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data hexa type xstring value '0x02'.
data(dec)  = conv string( hexa ).
write dec.


dec = 2.
hexa = dec.
write hexa.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Nov 2019 10:09:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076221#M1970451</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2019-11-01T10:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076222#M1970452</link>
      <description>&lt;P&gt;Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 12:33:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076222#M1970452</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-01T12:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076223#M1970453</link>
      <description>&lt;P&gt; @ &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; , you should convert your comment as answer&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 12:54:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076223#M1970453</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2019-11-01T12:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076224#M1970454</link>
      <description>&lt;P&gt;To convert one byte containing FF hexadecimal value (decimal 255) into an integer variable:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: byte    TYPE x LENGTH 1,
      integer TYPE i.

byte = 'FF'.
integer = byte.
ASSERT integer = 255.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abenconversion_type_x.htm"&gt;ABAP documentation - Conversion Rules for Elementary Data Objects ► Source Field Type x ► Numeric Target Fields&lt;/A&gt;:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Target 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 these bytes is interpreted as a number stored in big endian order, of type i. The hexadecimal values from "00000000" to "7FFFFFFF" are assigned to numbers from +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.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;PS: other remarks about your question:&lt;/P&gt;&lt;P&gt;The writing "&lt;STRONG&gt;0x...&lt;/STRONG&gt;" is interpreted by ABAP as two characters with no special meaning.&lt;/P&gt;&lt;P&gt;If you want to express a byte value:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA byte TYPE x LENGTH 1.
byte = 'FF'. " the two characters FF are interpreted as hexadecimal because byte has type X
DATA(byte_string) = CONV xstring( 'FF00FF00' ). " 4 bytes / interpreted as hexa because type XSTRING&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For more information: &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abenconversion_elementary.htm"&gt;ABAP documentation - Conversion Rules for Elementary Data Objects&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The method &lt;STRONG&gt;CONVERT_TO&lt;/STRONG&gt; of &lt;STRONG&gt;cl_abap_codepage&lt;/STRONG&gt; converts a text ('0x02' are four characters) into bytes, by using the encoding parameter whose default is UTF-8 (in your case all four characters are part of US-ASCII, so it's four bytes, '30783032' in hexadecimal notation).&lt;/P&gt;&lt;P&gt;But you transfer it to an integer variable, so the standard conversion rule from X to I applies (see explanation in the link above) which gives 813183026 (as you can see in the Windows Calculator in Programmer mode: press "HEX", type "30783032", and you see "813 183 026" at the right of "DEC"). Note that SAP could also have given "842 037 296" if your system was of type Little Endian.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 12:58:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076224#M1970454</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-01T12:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion From Hex To Decimal</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076225#M1970455</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/153394/frdricgirod.html"&gt;Frederic Girod&lt;/A&gt; Done. Everything merged into one answer.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 13:02:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/conversion-from-hex-to-decimal/m-p/12076225#M1970455</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-01T13:02:53Z</dc:date>
    </item>
  </channel>
</rss>

