<?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: how to convert a character string to a hex string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370062#M8221</link>
    <description>&lt;P&gt;This FM does a code page conversion (to Korean), but the OP doesn't ask for it.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2016 13:13:54 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2016-11-28T13:13:54Z</dc:date>
    <item>
      <title>how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370057#M8216</link>
      <description>&lt;P&gt;Hi all, I am a Java Programmer, and I have two functions:&lt;/P&gt;&lt;P&gt;1. covert a character string to a hex string&lt;/P&gt;&lt;P&gt;2. covert a hex string to a character string &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I can implement these functions in Java, anyone can help me implement these functions in ABAP.&lt;/STRONG&gt; below is my Java code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import java.io.ByteArrayOutputStream;


public class Main {
	private static String hexString = "0123456789ABCDEF";
	/**
	 * encoding a character string to hex String
	 * @param str
	 * @return
	 */
	public static String encode(String str) {
		byte[] bytes = str.getBytes();
		StringBuilder sb = new StringBuilder(bytes.length * 2);
		for (int i = 0; i &amp;lt; bytes.length; i++) {
			sb.append(hexString.charAt((bytes[i] &amp;amp; 0xf0) &amp;gt;&amp;gt; 4));
			sb.append(hexString.charAt((bytes[i] &amp;amp; 0x0f) &amp;gt;&amp;gt; 0));
		}
		return sb.toString();
	}
	/**
	 * decoding a hex string to character string
	 * @param bytes
	 * @return
	 */
	public static String decode(String bytes) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length() / 2);
		for (int i = 0; i &amp;lt; bytes.length(); i += 2)
			baos.write((hexString.indexOf(bytes.charAt(i)) &amp;lt;&amp;lt; 4 | hexString.indexOf(bytes.charAt(i + 1))));
		return new String(baos.toByteArray());
	}
	public static void main(String[] args) {
		String ch = "寄售差额调整";
		System.out.println("‘寄售差额调整’ in Hex String："+Main.encode(ch));
		System.out.println("‘BCC4CADBB2EEB6EEB5F7D5FB’ in Chinese charater String:："+Main.decode(Main.encode(ch)));


	}
}

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 06:37:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370057#M8216</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-11-27T06:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370058#M8217</link>
      <description>&lt;P&gt;There's an implicit data type conversion between byte-like strings and character-like strings (cf ABAP documentation: &lt;A href="http://help.sap.com/abapdocu_702/en/?url=ABENCONVERSION_ELEMENTARY.htm"&gt;Conversion Rules for Elementary Data Types&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA hex TYPE xstring.&lt;BR /&gt;DATA chars TYPE string.&lt;BR /&gt;chars = 'EFBBBF'. "only uppercase&lt;BR /&gt;hex = chars.&lt;BR /&gt;chars = hex.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370058#M8217</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-27T10:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370059#M8218</link>
      <description>&lt;P&gt;Dear Hui,&lt;/P&gt;&lt;P&gt;  Use Function Module &lt;STRONG&gt;CHAR_HEX_CONVERSION &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://archive.sap.com/discussions/thread/1369358" target="test_blank"&gt;https://archive.sap.com/discussions/thread/1369358&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://archive.sap.com/discussions/thread/49906" target="test_blank"&gt;https://archive.sap.com/discussions/thread/49906&lt;/A&gt;&lt;/P&gt;Thank You</description>
      <pubDate>Mon, 28 Nov 2016 11:58:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370059#M8218</guid>
      <dc:creator>former_member209372</dc:creator>
      <dc:date>2016-11-28T11:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370060#M8219</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please use below code.&lt;/P&gt;&lt;P&gt;* READ TABLE i_data into w_data INDEX 1.&lt;BR /&gt;
** move w_data-line to v_xml.&lt;BR /&gt;
 CALL FUNCTION 'HR_KR_STRING_TO_XSTRING'&lt;BR /&gt;
 EXPORTING&lt;BR /&gt;
* CODEPAGE_TO = '8500'&lt;BR /&gt;
 unicode_string = l_xml_table&lt;BR /&gt;
* OUT_LEN =&lt;BR /&gt;
 IMPORTING&lt;BR /&gt;
 xstring_stream = v_xml.&lt;BR /&gt;
* EXCEPTIONS&lt;BR /&gt;
* INVALID_CODEPAGE = 1&lt;BR /&gt;
* INVALID_STRING = 2&lt;BR /&gt;
* OTHERS = 3&lt;BR /&gt;
* .&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bala&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 12:24:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370060#M8219</guid>
      <dc:creator>pandiri_balaraju2</dc:creator>
      <dc:date>2016-11-28T12:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370061#M8220</link>
      <description>&lt;P&gt;This FM systematically dumps in Unicode systems (unicode being mandatory from 7.50)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 13:12:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370061#M8220</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-28T13:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370062#M8221</link>
      <description>&lt;P&gt;This FM does a code page conversion (to Korean), but the OP doesn't ask for it.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 13:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370062#M8221</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2016-11-28T13:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert a character string to a hex string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370063#M8222</link>
      <description>&lt;P&gt;If a codepage conversion is needed, use CL_ABAP_CODEPAGE, Methods CONVERT_TO and CONVERT_FROM.&lt;/P&gt;&lt;P&gt;Otherwise, as Sandra said ...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:30:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-convert-a-character-string-to-a-hex-string/m-p/370063#M8222</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2016-11-28T18:30:00Z</dc:date>
    </item>
  </channel>
</rss>

