<?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: OData JSON Deserialize in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184744#M1980148</link>
    <description>&lt;P&gt;Thanks  &lt;SPAN class="mention-scrubbed"&gt;8d8214c7f9734f45be69f95cc0d5aeee&lt;/SPAN&gt;, unfortunately we don't have the class - /UI2/CL_DATA_ACCESS and the changing parameter in the deserialize method never returns anything in my case . However i used the class-ZCL_JSON which is provided in the link, and it does have generate method. &lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2020 21:20:34 GMT</pubDate>
    <dc:creator>srikanthnalluri</dc:creator>
    <dc:date>2020-03-12T21:20:34Z</dc:date>
    <item>
      <title>OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184736#M1980140</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
  &lt;P&gt;I am trying to deserialize the simple JSON data using the class /UI2/CL_JSON. However the output internal table is initial. Can you please let me know what i am missing here.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    types:
      begin of ty_ekko,
        ebeln type ebeln,
        bukrs type bukrs,
        bstyp type bstyp,
        ktwrt type string,
      end of ty_ekko.
    data:
      lt_ekko type STANDARD TABLE OF ty_ekko.
   

    /ui2/cl_json=&amp;gt;deserialize( 
      EXPORTING 
        json = lv_json 
      CHANGING 
        data = lt_ekko ).
   check lt_ekko is not initial.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;We're on SAP_ABA - 740 SP-Level - 0009&lt;/P&gt;
  &lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 21:08:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184736#M1980140</guid>
      <dc:creator>srikanthnalluri</dc:creator>
      <dc:date>2020-03-09T21:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184737#M1980141</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can't always assign the internal table to the changing parameter data. This depends on the structure of your JSON file. A full guide on how to use the class /ui2/cl_json to deserialize a JSON string can be found in this wiki: &lt;A href="https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer"&gt;https://wiki.scn.sap.com/wiki/display/Snippets/One+more+ABAP+to+JSON+Serializer+and+Deserializer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Geert-Jan Klaps&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 21:13:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184737#M1980141</guid>
      <dc:creator>geert-janklaps</dc:creator>
      <dc:date>2020-03-09T21:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184738#M1980142</link>
      <description>&lt;P&gt;You'd better post your JSON as code instead of image, because usually people won't spend time in retyping the JSON from the image to reproduce the issue and propose a solution. Sorry.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 00:22:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184738#M1980142</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-03-10T00:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184739#M1980143</link>
      <description>&lt;P&gt;Not an XML. See the JSON in the image that the OP has attached.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 00:23:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184739#M1980143</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-03-10T00:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184740#M1980144</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;My mistake, that’s what you get wegen trying to multitask. I updated the answer!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Geert-Jan Klaps&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 04:56:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184740#M1980144</guid>
      <dc:creator>geert-janklaps</dc:creator>
      <dc:date>2020-03-10T04:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184741#M1980145</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;{"d":{"results":[{"__metadata":{"id":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353003')","uri":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353003')","type":"ZSN_TEST_REST_SERVICE_SRV.POHeaderData"},"Ebeln":"4100353003","Bukrs":"0010","Bstyp":"F","Bsart":"NB","Ktwrt":"0.000"},{"__metadata":{"id":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353103')","uri":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353103')","type":"ZSN_TEST_REST_SERVICE_SRV.POHeaderData"},"Ebeln":"4100353103","Bukrs":"0010","Bstyp":"F","Bsart":"NB","Ktwrt":"0.000"}]}}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;JSON file&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 15:43:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184741#M1980145</guid>
      <dc:creator>srikanthnalluri</dc:creator>
      <dc:date>2020-03-10T15:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184742#M1980146</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;8d8214c7f9734f45be69f95cc0d5aeee&lt;/SPAN&gt; Thanks for the link, It seems there is a method - GENERATE which can be used but i don't have this method.In this case do i have to build the internal table structure using JSON structure?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 19:52:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184742#M1980146</guid>
      <dc:creator>srikanthnalluri</dc:creator>
      <dc:date>2020-03-12T19:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184743#M1980147</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;srikanthnalluri&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;You should use /UI2/CL_DATA_ACCESS to read the data dynamically. Based on your example, I made this minimal program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA lv_json TYPE string.
lv_json = `{"d":{"results":[{"__metadata":{"id":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353003')","uri":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353003')",`
&amp;amp;&amp;amp; `"type":"ZSN_TEST_REST_SERVICE_SRV.POHeaderData"},"Ebeln":"4100353003","Bukrs":"0010","Bstyp":"F","Bsart":"NB","Ktwrt":"0.000"},{"__metadata":{"id":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353103')",`
&amp;amp;&amp;amp; `"uri":"http://xxxxxx.com:8000/sap/opu/odata/SAP/ZSN_TEST_REST_SERVICE_SRV/POHeaderDataSet('4100353103')","type":"ZSN_TEST_REST_SERVICE_SRV.POHeaderData"},"Ebeln":"4100353103","Bukrs":"0010","Bstyp":"F","Bsart":"NB","Ktwrt":"0.000"}]}}`.

TYPES:
  BEGIN OF ty_ekko,
    ebeln TYPE ebeln,
    bukrs TYPE bukrs,
    bstyp TYPE bstyp,
    ktwrt TYPE string,
  END OF ty_ekko.
DATA: lr_data TYPE REF TO data,
      lt_ekko TYPE STANDARD TABLE OF ty_ekko,
      ls_ekko LIKE LINE OF lt_ekko.

FIELD-SYMBOLS: &amp;lt;ft_result&amp;gt;    TYPE ANY TABLE,
               &amp;lt;fs_data_ref&amp;gt; TYPE any,
               &amp;lt;fs_structure&amp;gt; TYPE any,
               &amp;lt;fs_field&amp;gt; TYPE any,
               &amp;lt;fs_value&amp;gt; TYPE any.

* Convert JSON to data reference
/ui2/cl_json=&amp;gt;deserialize(
  EXPORTING
    json = lv_json
  CHANGING
    data = lr_data ).

* Prepare data access
DATA(lr_result_base) = /ui2/cl_data_access=&amp;gt;create( ir_data = lr_data iv_component = `D`)-&amp;gt;ref( ).
DATA(lr_result) = /ui2/cl_data_access=&amp;gt;create( ir_data = lr_result_base iv_component = `RESULTS`)-&amp;gt;ref( ).

* Assign result table to field symbol
ASSIGN lr_result-&amp;gt;* TO &amp;lt;ft_result&amp;gt;.

* Loop at result table
LOOP AT &amp;lt;ft_result&amp;gt; ASSIGNING &amp;lt;fs_data_ref&amp;gt;.
* Assign data reference to field symbol
  ASSIGN &amp;lt;fs_data_ref&amp;gt;-&amp;gt;* TO &amp;lt;fs_structure&amp;gt;.
  IF sy-subrc = 0.

*   Read purchase order
    ASSIGN COMPONENT 'EBELN' OF STRUCTURE &amp;lt;fs_structure&amp;gt; TO &amp;lt;fs_field&amp;gt;.
    IF sy-subrc = 0.
      ASSIGN &amp;lt;fs_field&amp;gt;-&amp;gt;* TO &amp;lt;fs_value&amp;gt;.
      IF sy-subrc = 0.
        ls_ekko-ebeln = &amp;lt;fs_value&amp;gt;.
      ENDIF.
    ENDIF.

*   Add line to internal table
    APPEND ls_ekko TO lt_ekko.
    CLEAR: ls_ekko.
  ENDIF.
ENDLOOP.&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The "Read purchase order" part needs to be repeated for each field in your structure. (you can do this dynamically off course so you don't need to repeat the code)&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1791517-result.png" /&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Geert-Jan Klaps&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 20:52:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184743#M1980147</guid>
      <dc:creator>geert-janklaps</dc:creator>
      <dc:date>2020-03-12T20:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184744#M1980148</link>
      <description>&lt;P&gt;Thanks  &lt;SPAN class="mention-scrubbed"&gt;8d8214c7f9734f45be69f95cc0d5aeee&lt;/SPAN&gt;, unfortunately we don't have the class - /UI2/CL_DATA_ACCESS and the changing parameter in the deserialize method never returns anything in my case . However i used the class-ZCL_JSON which is provided in the link, and it does have generate method. &lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 21:20:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184744#M1980148</guid>
      <dc:creator>srikanthnalluri</dc:creator>
      <dc:date>2020-03-12T21:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184745#M1980149</link>
      <description>&lt;P&gt;Hello &lt;A href="https://answers.sap.com/users/377940/srikanthnalluri.html"&gt;S Nalluri&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;you are using the wrong/incomplete receiving ABAP structure, that is why it does not work.&lt;/P&gt;&lt;P&gt;Try this one:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;types:
  begin of ty_ekko,
    ebeln type ebeln,
    bukrs type bukrs,
    bstyp type bstyp,
    ktwrt type string,
  end of ty_ekko,
  begin of ty_odata_results,
    results type standard table of ty_ekko,
  end of ty_odata_results,
  begin of ty_odata,
    d type ty_odata_results,
  end of ty_odata.
data:
   ls_odata type ty_odata.

/ui2/cl_json=&amp;gt;deserialize( EXPORTING json = lv_json 
                           CHANGING data = ls_odata ).
check ls_odata is not initial.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You also do not need to use the GENERATE method. It is only useful in case you do not know the JSON structure. &lt;/P&gt;&lt;P&gt;BR, Alexey.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 17:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184745#M1980149</guid>
      <dc:creator>alexey_arseniev</dc:creator>
      <dc:date>2020-03-13T17:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: OData JSON Deserialize</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184746#M1980150</link>
      <description>&lt;P&gt;Thanks Alexey, your blog helped me a lot&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 17:44:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/odata-json-deserialize/m-p/12184746#M1980150</guid>
      <dc:creator>srikanthnalluri</dc:creator>
      <dc:date>2020-03-17T17:44:10Z</dc:date>
    </item>
  </channel>
</rss>

