<?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: Efficient serialization of generically-typed structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-serialization-of-generically-typed-structure/m-p/11423367#M1926861</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative you could try to run the transformation id on the structure in order to convert the structure to an XML string and then run a Simple or XSLT transformation in order to replace the XML tags with the custom delimiter (or do this second step with a normal search and replace).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The upside of this approach would be that you don't need any dynamic lookup of the input's structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot state anything about the performance of this approach but you could give it a try and compare this to the approach you already have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Valentin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Nov 2015 08:57:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2015-11-12T08:57:40Z</dc:date>
    <item>
      <title>Efficient serialization of generically-typed structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-serialization-of-generically-typed-structure/m-p/11423366#M1926860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi people,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my code I am dealing with a structure of a generic type, that means at design time I have no information about its particular components and their actual values. My aim is to serialize this structure into a string as fast as possible. All values of the components shall be separated by a certain delimiter. The kind of delimiter and the drawbacks of using delimiters in general shall not be discussed here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My approach looks as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field symbol &amp;lt;ls_untyped_data&amp;gt; points to the generically-typed structure. lv_number_of_fields says how many components the structure has.&lt;/P&gt;&lt;P&gt;I use the approach of targeting to the component by its index, since this is faster according to the ABAP documentation than referring to the component name. If lv_counter equals 1, we are in the first loop cycle and simply add the value of the first component. If lv_Counter is &amp;gt; 1, we additionally add the field_separator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_counter &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S32"&gt;0&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;DO &lt;/SPAN&gt;lv_number_of_fields &lt;SPAN class="L0S52"&gt;TIMES&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ADD &lt;/SPAN&gt;&lt;SPAN class="L0S32"&gt;1 &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;lv_counter&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ASSIGN &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;COMPONENT &lt;/SPAN&gt;lv_counter &lt;SPAN class="L0S52"&gt;OF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;STRUCTURE &lt;/SPAN&gt;&amp;lt;ls_untyped_data&amp;gt; &lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;&amp;lt;lv_field_value&amp;gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;IF &lt;/SPAN&gt;lv_counter &amp;gt; &lt;SPAN class="L0S32"&gt;1&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mv_serialized_records &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;mv_serialized_records &amp;amp;&amp;amp; lv_field_separator &amp;amp;&amp;amp; &amp;lt;lv_field_value&amp;gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ELSEIF &lt;/SPAN&gt;lv_counter &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S32"&gt;1&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mv_serialized_records &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;mv_serialized_records &amp;amp;&amp;amp; &amp;lt;lv_field_value&amp;gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ENDIF&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;ENDDO&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This solution works as expected. However, when we deal with a large number of components (in a particular case I have more than 300) and we deal with a huge amount of structures (that means the entire coding above is called several times for a set of structures), this approach is considerably slow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect the reason is the dynamic lookup of the component at runtime. However, I am not aware of any other possibiltiy to dynamically inspect the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Nov 2015 08:19:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-serialization-of-generically-typed-structure/m-p/11423366#M1926860</guid>
      <dc:creator>former_member186608</dc:creator>
      <dc:date>2015-11-12T08:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient serialization of generically-typed structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-serialization-of-generically-typed-structure/m-p/11423367#M1926861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative you could try to run the transformation id on the structure in order to convert the structure to an XML string and then run a Simple or XSLT transformation in order to replace the XML tags with the custom delimiter (or do this second step with a normal search and replace).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The upside of this approach would be that you don't need any dynamic lookup of the input's structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot state anything about the performance of this approach but you could give it a try and compare this to the approach you already have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Valentin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Nov 2015 08:57:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/efficient-serialization-of-generically-typed-structure/m-p/11423367#M1926861</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-11-12T08:57:40Z</dc:date>
    </item>
  </channel>
</rss>

