<?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 Sorting internal table dynamically. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821425#M1682136</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 want to sort an internal table dynamically. That is the sorting of the table will be done on different no of filelds, ascending, descending based on the user interaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The detailed issue is:&lt;/P&gt;&lt;P&gt;I have an ALV grid display of a dynamic structure.&lt;/P&gt;&lt;P&gt;This displayed data is then sorted and filtered by the&amp;nbsp; user.&lt;/P&gt;&lt;P&gt;This sorting is not getting applied for the internal table holding the data.&lt;/P&gt;&lt;P&gt;So i have to sort and filter the table in my program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filtering part is done.&lt;/P&gt;&lt;P&gt;Sorting I am stuck.&lt;/P&gt;&lt;P&gt;dynamic sort using single field is working, but when there are multiple fields, it is not possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cant sort one by on as the sorting by the first field will be lost.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jun 2012 13:38:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-06-07T13:38:52Z</dc:date>
    <item>
      <title>Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821425#M1682136</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 want to sort an internal table dynamically. That is the sorting of the table will be done on different no of filelds, ascending, descending based on the user interaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The detailed issue is:&lt;/P&gt;&lt;P&gt;I have an ALV grid display of a dynamic structure.&lt;/P&gt;&lt;P&gt;This displayed data is then sorted and filtered by the&amp;nbsp; user.&lt;/P&gt;&lt;P&gt;This sorting is not getting applied for the internal table holding the data.&lt;/P&gt;&lt;P&gt;So i have to sort and filter the table in my program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filtering part is done.&lt;/P&gt;&lt;P&gt;Sorting I am stuck.&lt;/P&gt;&lt;P&gt;dynamic sort using single field is working, but when there are multiple fields, it is not possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cant sort one by on as the sorting by the first field will be lost.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:38:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821425#M1682136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T13:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821426#M1682137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to sort field by field, from last key to first key with a STABLE option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:44:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821426#M1682137</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2012-06-07T13:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821427#M1682138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you try using the addition BY (otab)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;Manu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:50:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821427#M1682138</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T13:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821428#M1682139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;You can use this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;DATA: l_otab TYPE abap_sortorder_tab,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l_oline TYPE abap_sortorder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;LOOP AT gt_fld ASSIGNING &amp;lt;l_column&amp;gt;. " GT_FLD has the dynamic sort fields&lt;/P&gt;&lt;P&gt;l_oline-name = &amp;lt;l_column&amp;gt;-fldnam. " Add column name&lt;/P&gt;&lt;P&gt;APPEND l_oline TO l_otab.&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;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SORT gt_alv_temp BY (l_otab).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shambu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:53:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821428#M1682139</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T13:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821429#M1682140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think sorting is not possible by using field symbols, it can be used to modify table contents. This is because field symbol will just point to a line of the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want your table to be sorted in order of its key fields just use the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;b&amp;gt; SORT &amp;lt;itab&amp;gt; [ASCENDING|DESCENDING] &amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variable number of fields will not cause any problem in this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you want table to sorted by a different key, you can specify the key in the SORT statement. There you need to know field names (either static or dynamically) . &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;SORT &amp;lt;itab&amp;gt; [ASCENDING|DESCENDING] &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY &amp;lt;f1&amp;gt; [ASCENDING|DESCENDING]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fn&amp;gt; [ASCENDING|DESCENDING]&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;f1, f2, ........fn are the fields according to which you want to sort. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Namitha.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 13:55:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821429#M1682140</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T13:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821430#M1682141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Namitha..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SOR and the internal table are the only thins are know..&lt;/P&gt;&lt;P&gt;others are dynamic..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that is whether ascending or descending and the field names..&lt;/P&gt;&lt;P&gt;I tried somthing like SORT itab direction&amp;nbsp; (variable name holding the field name).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 14:21:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821430#M1682141</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821431#M1682142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Raymond, can you please elaborate what is STABLE and how do I decide the key field?&lt;/P&gt;&lt;P&gt;as the fields on which I want the sort are dynamic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 14:22:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821431#M1682142</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-07T14:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821432#M1682143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at the sample at the end of &lt;A href="http://help.sap.com/abapdocu_70/en/ABAPSORT_ITAB.htm"&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;SORT itab.&lt;/SPAN&gt;&lt;/A&gt;, a syntax like (where otab is of TYPE abap_sortorder_tab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;STRONG style="font-size: 10pt; font-family: Courier New;"&gt;SORT &amp;lt;itab&amp;gt; BY (otab). &lt;/STRONG&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;seems to be allowed&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB: The STABLE options insures that the relative order of records with the same sort criteria does not change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;Raymond&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 14:31:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821432#M1682143</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2012-06-07T14:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting internal table dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821433#M1682144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Piyush,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can sort the table dynamically on many fields..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort &amp;lt;ITAB&amp;gt; by ('FIELD1') ASCENDING ('FIELD2') DESCENDING..........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can also provide the field name in variables like below.&lt;/P&gt;&lt;P&gt;Sort &amp;lt;ITAB&amp;gt; by (VAR1) ASCENDING (VAR2) DESCENDING...........&lt;/P&gt;&lt;P&gt;here vari1 and var2 store the name of the field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you do some dynamic sort better to provide TRY and CATCH block. Other wise if there any typo or incorrect field name then it will give dumps. &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/777/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt; Catch the exception CX_SY_DYN_TABLE_ILL_COMP_VAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subhankar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 16:40:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-dynamically/m-p/8821433#M1682144</guid>
      <dc:creator>Subhankar</dc:creator>
      <dc:date>2012-06-07T16:40:37Z</dc:date>
    </item>
  </channel>
</rss>

