<?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: Serialize an object wir TYPE REF TO attribute. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502126#M2003296</link>
    <description>&lt;P&gt;As explained in the ABAP documentation, it doesn't work with "internal types" (also called "bound types"). You must use DDIC Types or Standalone Types. For example, with a Standalone Type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    TYPES ty_sflight_lines TYPE STANDARD TABLE OF SFLIGHT WITH EMPTY KEY.
    CREATE DATA mock_data TYPE ty_sflight_lines.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 20 Nov 2021 22:44:18 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2021-11-20T22:44:18Z</dc:date>
    <item>
      <title>Serialize an object wir TYPE REF TO attribute.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502123#M2003293</link>
      <description>&lt;P&gt;Dear SAP community,&lt;/P&gt;
  &lt;P&gt;I tried to save serialized object to DB table. The problem is that this approach doesn't work for classes with attribute TYPE REF TO.&lt;/P&gt;
  &lt;P&gt;My class looks like this:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;CLASS zcl_mock DEFINITION&lt;BR /&gt;  PUBLIC&lt;BR /&gt;  CREATE PUBLIC.
  INTERFACES IF_SERIALIZABLE_OBJECT .&lt;BR /&gt;&lt;BR /&gt;  PUBLIC SECTION.&lt;BR /&gt;  PROTECTED SECTION.&lt;BR /&gt;  PRIVATE SECTION.&lt;BR /&gt;&lt;BR /&gt;    DATA mock_data TYPE REF TO data.&lt;BR /&gt;ENDCLASS. 



CLASS zcl_mock IMPLEMENTATION.
...
ENDCLASS.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Do you have any idea how can I solved this problem?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 19:47:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502123#M2003293</guid>
      <dc:creator>mykola_tokariev2</dc:creator>
      <dc:date>2021-11-19T19:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Serialize an object wir TYPE REF TO attribute.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502124#M2003294</link>
      <description>&lt;P&gt;No problem for me, with option data_refs = 'heap-or-create':&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"&amp;gt;
    &amp;lt;asx:values&amp;gt;
        &amp;lt;OBJ href="#o9" /&amp;gt;
    &amp;lt;/asx:values&amp;gt;
    &amp;lt;asx:heap xmlns:dic="http://www.sap.com/abapxml/types/dictionary" xmlns:cls="http://www.sap.com/abapxml/classes/global" xmlns:abap="http://www.sap.com/abapxml/types/built-in" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;
        &amp;lt;prg:ZCL_MOCK xmlns:prg="http://www.sap.com/abapxml/classes/program/ZZSRO_TEST8" id="o9"&amp;gt;
            &amp;lt;local.ZCL_MOCK&amp;gt;
                &amp;lt;MOCK_DATA href="#d2" /&amp;gt;
            &amp;lt;/local.ZCL_MOCK&amp;gt;
        &amp;lt;/prg:ZCL_MOCK&amp;gt;
        &amp;lt;xsd:int id="d2"&amp;gt;5&amp;lt;/xsd:int&amp;gt;
    &amp;lt;/asx:heap&amp;gt;
&amp;lt;/asx:abap&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ABAP program:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT.

CLASS zcl_mock DEFINITION
  CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES IF_SERIALIZABLE_OBJECT .
    methods constructor.

  PROTECTED SECTION.
  PRIVATE SECTION.

    DATA mock_data TYPE REF TO data.
ENDCLASS.

CLASS zcl_mock IMPLEMENTATION.
  METHOD constructor.
    create data mock_data type i.
    cast i( mock_data )-&amp;gt;* = 5.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
  data(obj) = new zcl_mock( ).
  CALL TRANSFORMATION ID source obj = obj result xml data(xstring)
      OPTIONS data_refs = 'heap-or-create'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 20:11:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502124#M2003294</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-11-19T20:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Serialize an object wir TYPE REF TO attribute.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502125#M2003295</link>
      <description>&lt;P&gt;Hey &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;, &lt;/P&gt;&lt;P&gt;thank you for your answer. Your example works fine. But if I set some table to mock_data attribute, I get an CX_REFERENCE_NOT_SERIALIZABLE exception. You can see the example below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;REPORT.&lt;BR /&gt;&lt;BR /&gt;CLASS zcl_mock DEFINITION&lt;BR /&gt;  CREATE PUBLIC.&lt;BR /&gt;&lt;BR /&gt;  PUBLIC SECTION.&lt;BR /&gt;    INTERFACES if_serializable_object .&lt;BR /&gt;    METHODS constructor.&lt;BR /&gt;&lt;BR /&gt;    DATA mock_data TYPE REF TO data.&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;CLASS zcl_mock IMPLEMENTATION.&lt;BR /&gt;  METHOD constructor.&lt;BR /&gt;    FIELD-SYMBOLS: &amp;lt;flight&amp;gt; TYPE any.&lt;BR /&gt;    SELECT * FROM sflight INTO TABLE @DATA(sflight_tab) UP TO 10 ROWS.&lt;BR /&gt;&lt;BR /&gt;    CREATE DATA mock_data TYPE TABLE OF ('SFLIGHT').&lt;BR /&gt;    ASSIGN mock_data-&amp;gt;* TO &amp;lt;flight&amp;gt;.&lt;BR /&gt;    &amp;lt;flight&amp;gt; = sflight_tab.&lt;BR /&gt;  ENDMETHOD.&lt;BR /&gt;&lt;BR /&gt;ENDCLASS.&lt;BR /&gt;&lt;BR /&gt;START-OF-SELECTION.&lt;BR /&gt;  DATA(obj) = NEW zcl_mock( ).&lt;BR /&gt;  CALL TRANSFORMATION id SOURCE obj = obj RESULT XML DATA(xstring)&lt;BR /&gt;      OPTIONS data_refs = 'heap-or-create'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  DATA deser_obj TYPE REF TO zcl_mock.&lt;BR /&gt;&lt;BR /&gt;  CALL TRANSFORMATION id SOURCE XML xstring RESULT obj = deser_obj.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 20 Nov 2021 20:13:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502125#M2003295</guid>
      <dc:creator>mykola_tokariev2</dc:creator>
      <dc:date>2021-11-20T20:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Serialize an object wir TYPE REF TO attribute.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502126#M2003296</link>
      <description>&lt;P&gt;As explained in the ABAP documentation, it doesn't work with "internal types" (also called "bound types"). You must use DDIC Types or Standalone Types. For example, with a Standalone Type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    TYPES ty_sflight_lines TYPE STANDARD TABLE OF SFLIGHT WITH EMPTY KEY.
    CREATE DATA mock_data TYPE ty_sflight_lines.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Nov 2021 22:44:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/serialize-an-object-wir-type-ref-to-attribute/m-p/12502126#M2003296</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-11-20T22:44:18Z</dc:date>
    </item>
  </channel>
</rss>

