<?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: Sort internal table by using field symbol in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129194#M1512189</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort with field symbol for an internal table is not allowed within an loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the following code and it is working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF y_trial,&lt;/P&gt;&lt;P&gt;         n TYPE i,&lt;/P&gt;&lt;P&gt;        END OF y_trial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : t_table TYPE STANDARD TABLE OF y_trial WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;       e_table LIKE LINE OF t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;fs_trial&amp;gt; TYPE y_trial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INITIALIZATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 10 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 15 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 7 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" Assign the field symbol to internal table and then sort.&lt;/P&gt;&lt;P&gt;ASSIGN t_table to &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;SORT t_table ASCENDING by &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_table ASSIGNING &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;  WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; &amp;lt;fs_trial&amp;gt;-n.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output is  : 7,10,15.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Jul 2010 09:54:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-21T09:54:54Z</dc:date>
    <item>
      <title>Sort internal table by using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129191#M1512186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I encountered the runtime error while try to sort the internal table by using field symbol below. Can anyone please advice how does this issues can be resolved? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SORT i_test                           &lt;/P&gt;&lt;P&gt; BY &amp;lt;fs_a&amp;gt; ASCENDING  &amp;lt;fs_b&amp;gt;.          &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime error: -&lt;/P&gt;&lt;P&gt;When attempting to sort the internal table "I_test[ ]" in the current ABAP/4                 &lt;/P&gt;&lt;P&gt;program "Ztest", the field symbol " " was used as a dynamic                     &lt;/P&gt;&lt;P&gt;criterion.                                                                                &lt;/P&gt;&lt;P&gt;To be used in this way, all of " " would have to fit into the header                           &lt;/P&gt;&lt;P&gt; line "I_test" of the internal table "I_test[ ]". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since this is not the case, the program "Ztest" had to be terminated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 01:35:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129191#M1512186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-21T01:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table by using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129192#M1512187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also specify the sort fields dynamically in the form (name). If name is blank at runtime, the sort field is ignored. If itab is a table with a header line, you can also use a field symbol pointing to the header line of itab as a dynamic sort criterion. A field symbol that is not assigned is ignored. If a field symbol is assigned, but does not point to the header line of the internal table, a runtime error occurs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 02:28:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129192#M1512187</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-21T02:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table by using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129193#M1512188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the field-symbols &amp;lt;fs_a&amp;gt; &amp;amp; &amp;lt;fs_b&amp;gt; contain the you can try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT i_test
BY ( &amp;lt;fs_a&amp;gt; ) ASCENDING ( &amp;lt;fs_b&amp;gt; ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this online help documentation for details [http://help.sap.com/abapdocu_70/en/ABENITAB_COMPONENTS.htm], [http://help.sap.com/abapdocu_70/en/ABAPSORT_ITAB.htm#!ABAP_ADDITION_4@4@]&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>Wed, 21 Jul 2010 02:36:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129193#M1512188</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-07-21T02:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table by using field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129194#M1512189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort with field symbol for an internal table is not allowed within an loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the following code and it is working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF y_trial,&lt;/P&gt;&lt;P&gt;         n TYPE i,&lt;/P&gt;&lt;P&gt;        END OF y_trial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : t_table TYPE STANDARD TABLE OF y_trial WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;       e_table LIKE LINE OF t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;fs_trial&amp;gt; TYPE y_trial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INITIALIZATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 10 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 15 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR e_table.&lt;/P&gt;&lt;P&gt;MOVE 7 to e_table-n.&lt;/P&gt;&lt;P&gt;APPEND e_table to t_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" Assign the field symbol to internal table and then sort.&lt;/P&gt;&lt;P&gt;ASSIGN t_table to &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;SORT t_table ASCENDING by &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_table ASSIGNING &amp;lt;fs_trial&amp;gt;.&lt;/P&gt;&lt;P&gt;  WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; &amp;lt;fs_trial&amp;gt;-n.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output is  : 7,10,15.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jul 2010 09:54:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-by-using-field-symbol/m-p/7129194#M1512189</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-21T09:54:54Z</dc:date>
    </item>
  </channel>
</rss>

