<?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>Question Re: toJSON for RAW data in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733191#M4778864</link>
    <description>&lt;P&gt;Base64 string "KT0AAA==" represents the 4 bytes: 0x29 0x3D 0x00 0x00&lt;BR /&gt;So what is done by this ABAP transaction for the SAP GUI output, is to convert the RAW bytes into a hex string.&lt;BR /&gt;If you would like to achieve the same in Java, decode the Base64 string into a byte[], and afterwards convert the byte[] into a hex string.&lt;/P&gt;&lt;P&gt;-- Or simply call myMainrec.getString("ROLLKEY") on the respective JCoStructure object. The JCoRecord.getString() API will also do an on-the-fly conversion from RAW/BYTE type fields to hex strings.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2023 16:18:28 GMT</pubDate>
    <dc:creator>HAL9000</dc:creator>
    <dc:date>2023-06-05T16:18:28Z</dc:date>
    <item>
      <title>toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaq-p/12733186</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;Here is the scenario: I execute a JCo call on a function module and call the toJSON() on the output Table or Structure. All the data prints fine except for fields which are of type "RAW". &lt;/P&gt;
  &lt;P&gt;Here is an example where I am looking at the output of SWNC_GET_WORKLOAD_STATRECS and the field DISPCNT shows up as:&lt;BR /&gt;"DISPCNT":"AAE=" &lt;/P&gt;
  &lt;P&gt;If you check the metadata, DISPCNT is of type RAW as shown in the screenshot below. The same happens for few other fields (ex: "WPID":"AAA=", "TASKTYPE":"Cw==", "LUW_INFO":"Fw==") and all of them are of type RAW. I am using JCo version 3.1.7. &lt;/P&gt;
  &lt;P&gt;Any pointers are very much appreciated! &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2169432-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 19:44:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaq-p/12733186</guid>
      <dc:creator>OhMySAP33</dc:creator>
      <dc:date>2023-05-31T19:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733187#M4778860</link>
      <description>&lt;P&gt;The RAW data bytes are serialized as Base64 string.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 11:54:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733187#M4778860</guid>
      <dc:creator>HAL9000</dc:creator>
      <dc:date>2023-06-01T11:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733188#M4778861</link>
      <description>&lt;P&gt;Thanks  &lt;SPAN class="mention-scrubbed"&gt;stefan.gass&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Any pointers on how to go about decoding it? I have tried java.util.Base64 decoder as well Apache commons without any luck. &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using Apache Commons: org.apache.commons.codec.binary.Base64;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;String encodedString = "sGwAAA==";&lt;BR /&gt;Base64 base64 = new Base64();&lt;BR /&gt;String decodedString = new String(base64.decode(encodedString.getBytes()));&lt;BR /&gt;System.out.println(decodedString);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above prints output as: �l&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using the java.util.Base64 library&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; String encodedString = "sGwAAA==";&lt;BR /&gt; byte[] decodedBytes = Base64.getDecoder().decode(encodedString);&lt;BR /&gt;String decodedString = new String(decodedBytes);&lt;BR /&gt;System.out.println(decodedString);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Prints the output as �l&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 20:55:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733188#M4778861</guid>
      <dc:creator>OhMySAP33</dc:creator>
      <dc:date>2023-06-01T20:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733189#M4778862</link>
      <description>&lt;P&gt;So the decoding worked and you got the raw byte[] again.&lt;BR /&gt;What else do you expect when printing raw bytes to the stdout stream?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 05:23:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733189#M4778862</guid>
      <dc:creator>HAL9000</dc:creator>
      <dc:date>2023-06-02T05:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733190#M4778863</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;stefan.gass&lt;/SPAN&gt; - The problem is that the output (after decoding) does not match the expected String. Here is another example:&lt;BR /&gt;Here is a snapshot of the raw JSON output received after calling toJSON() on the MAINRECS table received from SWNC_GET_WORKLOAD_SNAPSHOT&lt;/P&gt;&lt;P&gt;{“MAINREC”:{“RECNO”:2,“DISPCNT”:“AAE=“,”ZTTADATE”:“2023-06-02”,“STARTDATE”:“2023-06-02”,“STARTTIME”:“14:06:41”,“STARTTIMESTAMP”:20230602180641,“ENDDATE”:“2023-06-02",“ENDTIME”:“14:06:41",“ENDTIMESTAMP”:20230602180641,“TARGETTIMEZONE”:“EST”,“RESPTI”:3213,“CPUTI”:0,“QUEUETI”:50,“WPID”:“AAA=“,”TASKTYPE”:“Cw==“,”TABLOAD”:“AA==“,”ACCOUNT”:“SAPSYS”,“MANDT”:“000”,&lt;STRONG&gt;“ROLLKEY”:“KT0AAA==“,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As you can see, ROLLKEY shows up as: &lt;B&gt;KT0AAA==&lt;/B&gt;&lt;/P&gt;&lt;P&gt;If you look in SAPGUI for this data, ROLLKEY is displayed as 293D0000. Below is a screenshot.&lt;/P&gt;&lt;P&gt;Now when I decode &lt;B&gt;KT0AAA== &lt;/B&gt;using either java.util.Base64 or org.apache.commons.codec.binary.Base64 (same java code snippet pasted in earlier comment) in both cases the output is &lt;STRONG&gt;)= &lt;/STRONG&gt;  &lt;/P&gt;&lt;P&gt;Wondering how do I get what SAP GUI shows: 293D0000&lt;BR /&gt;&lt;BR /&gt;Thanks again! &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2172571-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 16:04:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733190#M4778863</guid>
      <dc:creator>OhMySAP33</dc:creator>
      <dc:date>2023-06-05T16:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733191#M4778864</link>
      <description>&lt;P&gt;Base64 string "KT0AAA==" represents the 4 bytes: 0x29 0x3D 0x00 0x00&lt;BR /&gt;So what is done by this ABAP transaction for the SAP GUI output, is to convert the RAW bytes into a hex string.&lt;BR /&gt;If you would like to achieve the same in Java, decode the Base64 string into a byte[], and afterwards convert the byte[] into a hex string.&lt;/P&gt;&lt;P&gt;-- Or simply call myMainrec.getString("ROLLKEY") on the respective JCoStructure object. The JCoRecord.getString() API will also do an on-the-fly conversion from RAW/BYTE type fields to hex strings.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 16:18:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733191#M4778864</guid>
      <dc:creator>HAL9000</dc:creator>
      <dc:date>2023-06-05T16:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733192#M4778865</link>
      <description>&lt;P&gt;I get it now and can decode it.&lt;/P&gt;&lt;P&gt;Thanks a lot!  &lt;SPAN class="mention-scrubbed"&gt;stefan.gass&lt;/SPAN&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 13:52:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733192#M4778865</guid>
      <dc:creator>OhMySAP33</dc:creator>
      <dc:date>2023-06-06T13:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: toJSON for RAW data</title>
      <link>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733193#M4778866</link>
      <description>&lt;P&gt;No problem.&lt;BR /&gt;If your questions are answered, it would be nice, if you upvote this answer and mark it as the correct answer.&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:32:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/tojson-for-raw-data/qaa-p/12733193#M4778866</guid>
      <dc:creator>HAL9000</dc:creator>
      <dc:date>2023-06-06T14:32:32Z</dc:date>
    </item>
  </channel>
</rss>

