<?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: Best Practice for using CAST operator in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879718#M1960532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;I would split up the one method which uses the cast more times into two methods.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi Armin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately i cannot split the method because it is a callback-routine of an aRFC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution is not an elegant one, but unfortunately i don't have the leisure of refactoring the stuff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Sep 2016 14:28:20 GMT</pubDate>
    <dc:creator>SuhaSaha</dc:creator>
    <dc:date>2016-09-27T14:28:20Z</dc:date>
    <item>
      <title>Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879715#M1960529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello SDNers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked up the SAP documentation but could not find any best practice on using the CAST operator multiple times in a procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Approach#1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INSERT LINES OF:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST child( parent )-&amp;gt;table1 INTO TABLE ex_table1,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;CAST &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;child&lt;/SPAN&gt;( &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;parent&lt;/SPAN&gt; )-&amp;gt;table2 INTO TABLE ex_table2&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Approach#2: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA(child) = &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;CAST child( parent ).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INSERT LINES OF:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; child-&amp;gt;table1 INTO TABLE ex_table1,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;child-&amp;gt;table2 &lt;SPAN style="font-family: 'courier new', courier; font-size: 13.3333px;"&gt;INTO TABLE ex_table2.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;In the former i am casting twice, whereas in the latter i am using a helper variable. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;SAP documentation states &amp;amp; i quote,&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;The casting operator &lt;SPAN class="qtext" style="font-family: 'Courier New'; font-weight: bold;"&gt;CAST&lt;/SPAN&gt; is suitable for avoiding the declaration of helper variables needed only for down casts.&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If i consider this statement as the thumb-rule, then approach#1 is better. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you think?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 13:21:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879715#M1960529</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-09-27T13:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879716#M1960530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd tend to 1) but always consider readability.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 13:32:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879716#M1960530</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2016-09-27T13:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879717#M1960531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would vote for 2) in this special case because of the readability.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But maybe one should think about a different solution. If I would need a cast twice or more, I would think about splitting up the logic into several blocks. In OO-words: I would split up the one method which uses the cast more times into two methods. Whereby the called method contains the coding with the casts, which would be resolved by using a parameter with the already correct interface/class to use and the calling method then has to do a single cast.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some more ideas to resolve the nasty casting, but I won't blow up the post.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 14:01:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879717#M1960531</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-27T14:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879718#M1960532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;I would split up the one method which uses the cast more times into two methods.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi Armin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately i cannot split the method because it is a callback-routine of an aRFC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution is not an elegant one, but unfortunately i don't have the leisure of refactoring the stuff.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 14:28:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879718#M1960532</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-09-27T14:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879719#M1960533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;Matthew Billingham wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;... but always consider readability.&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hence the question &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/108/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 14:29:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879719#M1960533</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-09-27T14:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879720#M1960534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it not possible to call another method inside the callback-routine?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another idea is: Provide two methods at your "child" class, which append the corresponding content. To avoid the redundant casting you can use chaining (returning the object itself, i.e. ME):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CAST child( parent )-&amp;gt;append_tab1_to( CHANGING ct_table = ex_table1 )-&amp;gt;append_tab2_to( CHANGING ct_table = ex_table2 ).&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 15:07:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879720#M1960534</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-27T15:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practice for using CAST operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879721#M1960535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN style="color: #333333; font-size: 12px;"&gt;Is it not possible to call another method inside the callback-routine?&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As i have mentioned, i don't have the flexibility of refactoring the code now. Maybe in the next sprint &lt;SPAN __jive_emoticon_name="grin" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/108/images/emoticons/grin.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 17:49:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/best-practice-for-using-cast-operator/m-p/11879721#M1960535</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2016-09-27T17:49:58Z</dc:date>
    </item>
  </channel>
</rss>

