<?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: Sorting by various keys internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690798#M1293163</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Bhanu, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you want to read a internal table with different variable field, then you can sort your internal table with hierarchy and avoid 'Binary Search ' to read the record. &lt;/P&gt;&lt;P&gt;  Hope this will solve your problem. Feel free to ask if you have still any doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 May 2009 08:49:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-25T08:49:06Z</dc:date>
    <item>
      <title>Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690795#M1293160</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;There is a small confusion i am having in my mind so wanted to clear it &lt;/P&gt;&lt;P&gt;In my internal table i have 4 fields &lt;/P&gt;&lt;P&gt;1. Material no.&lt;/P&gt;&lt;P&gt;2.material plant no.&lt;/P&gt;&lt;P&gt;3.sold to party&lt;/P&gt;&lt;P&gt;4.ship to party &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read this internal table different times in different places based on various keys as like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read itab with key material no BINARY SEARCH.&lt;/P&gt;&lt;P&gt;Read itab with key material plant no. BINARY SEARCH.&lt;/P&gt;&lt;P&gt;Read itab with key  sold to party  BINARY SEARCH.&lt;/P&gt;&lt;P&gt;Read itab with key ship to party  BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my questions is shld i sort the table by each key sepertly before reading it &lt;/P&gt;&lt;P&gt;like this &lt;/P&gt;&lt;P&gt;sort itab by material no &lt;/P&gt;&lt;P&gt;Read itab with key material no BINARY SEARCH.&lt;/P&gt;&lt;P&gt;sort itab by material plant no&lt;/P&gt;&lt;P&gt;Read itab with key material plant no. BINARY SEARCH.&lt;/P&gt;&lt;P&gt;sort itab by sold to party  &lt;/P&gt;&lt;P&gt;Read itab with key  sold to party  BINARY SEARCH.&lt;/P&gt;&lt;P&gt;sort itab by ship to party  &lt;/P&gt;&lt;P&gt;Read itab with key ship to party  BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or i can once sort table by material no material plant no sold to party   ship to party  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please explain me how best this can be done and why?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:21:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690795#M1293160</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T08:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690796#M1293161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your read statements are inside a same loop then DO NOT USE BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is as different places then you have to sort it prior to corresponding read statements. But in these cases, you should be very cautious while reading data with binary search as if the sorting is not proper, you will get abrupt results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do not go for BINARY SEARCH in such cases.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:25:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690796#M1293161</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T08:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690797#M1293162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use binary search you must sort the table, otherwise the results are unpredictable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:44:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690797#M1293162</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2009-05-25T08:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690798#M1293163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Bhanu, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you want to read a internal table with different variable field, then you can sort your internal table with hierarchy and avoid 'Binary Search ' to read the record. &lt;/P&gt;&lt;P&gt;  Hope this will solve your problem. Feel free to ask if you have still any doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:49:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690798#M1293163</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T08:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690799#M1293164</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;Since the condition changes each time, it is good to sort each time based on the read condition and then read using binary search.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:49:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690799#M1293164</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2009-05-25T08:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690800#M1293165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i am using this read statement inside a loop which is unavoidable so for sure i should not use sort inside &lt;/P&gt;&lt;P&gt;loop .&lt;/P&gt;&lt;P&gt; sort your internal table with hierarchy ??Can you explain a little bit more?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 08:54:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690800#M1293165</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T08:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690801#M1293166</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;Why is it required for you to write 4 read statements... can you do it with one read statement....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Siddarth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 09:00:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690801#M1293166</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T09:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690802#M1293167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why is it required for you to write 4 read statements... can you do it with one read statement....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its like i have to read the internal table on different conditions .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say if &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN 'PROGRAM ID 'ABC ON SELECTION SCREEN '&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ ITAB BY MATERIAL NO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN PROGRAM ID 'XYZ'&lt;/P&gt;&lt;P&gt;I HAVE TO READ ON PLANT KEY&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 09:03:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690802#M1293167</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T09:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690803#M1293168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;then probably its better not to use binary search... it will lead on very high performance issue if you do it, because you will have to sort the table again and again and then give a read on it.... so its better just give a read statement to the table removing binary search.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Siddarth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 09:13:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690803#M1293168</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T09:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690804#M1293169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Bhanu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what I mean sort your internal table before loop with say Material no material plant no sold to party ship to party.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so that your internal table will be in sequence. It will become easy to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Feel free to ask still you have any doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 09:37:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690804#M1293169</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T09:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690805#M1293170</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;sort itab by material no &lt;/P&gt;&lt;P&gt;Read itab with key material no .&lt;/P&gt;&lt;P&gt;sort itab by material plant no&lt;/P&gt;&lt;P&gt;Read itab with key material plant no.&lt;/P&gt;&lt;P&gt;sort itab by sold to party &lt;/P&gt;&lt;P&gt;Read itab with key sold to party .&lt;/P&gt;&lt;P&gt;sort itab by ship to party &lt;/P&gt;&lt;P&gt;Read itab with key ship to party.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;munibabu.k&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 10:19:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690805#M1293170</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T10:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690806#M1293171</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;Instead of using the same internal table, copy the table into 4 internal tables and sort it according to the key. Then you can use bianry search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kiran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 11:01:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690806#M1293171</guid>
      <dc:creator>vadrevu_kk</dc:creator>
      <dc:date>2009-05-25T11:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690807#M1293172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do not sort before each read inside a loop, the cost of each sort would far outweigh the binary search effect.&lt;/P&gt;&lt;P&gt;I think Kiran's idea is OK, if the table is not too large, copy it 4 times and sort &lt;EM&gt;once&lt;/EM&gt; by each key.&lt;/P&gt;&lt;P&gt;Look forward to internal tables with secondary indexes, will be in the next Netweaver release.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;correction: you need 3 tables, mat# and mat# plant# can be handled with the same table. this implies that just mat# is not unique, are you sure a read is sufficient, don't you need a loop here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 11:13:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690807#M1293172</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-05-25T11:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690808#M1293173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When storing the table three times or four times in the report and if the only purpose of those tables is to be read for ceratin values, i would prefer hashed tables. They are much more performant rather than sorted tables with binary search.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 11:43:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690808#M1293173</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2009-05-25T11:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690809#M1293174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, if the full key is used for access. If only a part of the key is used (from left to right of course), then sorted tables are the best option.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 11:59:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690809#M1293174</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-05-25T11:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting by various keys internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690810#M1293175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;your task is a bit strange and I guess the reason was giving by you:&lt;/P&gt;&lt;P&gt;&amp;gt; WHEN 'PROGRAM ID 'ABC ON SELECTION SCREEN '&lt;/P&gt;&lt;P&gt;&amp;gt; READ ITAB BY MATERIAL NO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This looks to me as if you have to use onyl one read type per execution, depending to the&lt;/P&gt;&lt;P&gt;selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it should be enough to sort once also depending on the selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be on the safe side, it would better to split the whole program in different branches, such that&lt;/P&gt;&lt;P&gt;only one branch is used in one execution. Inside the branch there is the sort, the loop and the&lt;/P&gt;&lt;P&gt;respective read binary search inside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise, if you really have to read in one program execution with 4 different keys inside one loop.&lt;/P&gt;&lt;P&gt;Then you must prepare 4 identical tables and sort them outside of the loop and use for each &lt;/P&gt;&lt;P&gt;read binary search the respectivly sorted table.&lt;/P&gt;&lt;P&gt;=&amp;gt; and please update to the new Netweaver release. 7.0 EhP 2 as soon as possible, there you can define different secondary keys, which solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 May 2009 13:37:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-by-various-keys-internal-table/m-p/5690810#M1293175</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-25T13:37:06Z</dc:date>
    </item>
  </channel>
</rss>

