<?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: Loop on a internal table with data ref and a key in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128240#M1818002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested a TABLE of 10,000,000 records with 1000 matching keys:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;With a standard table and linear search (LOOP ... WHERE ... FROM field = 'value' )&lt;/LI&gt;&lt;LI&gt;With a sorted table and LOOP ... WHERE ... FROM&amp;nbsp; key = 'value'&lt;/LI&gt;&lt;LI&gt;With a sorted table and READ FROM ... WITH TABLE KEY ... followed by a LOOP FROM INDEX where index is the index of the first matching from READ statement.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The third approach is the fastest one (10-100) times faster. Incredibly the second approach is the slowest one (2 times slower then the first one). Maybe ABAP is performing multiple not optimized binary searches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This result remain the same with any number of non-unique matching keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other side the second approach is faster on small tables (10000 elements).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this could help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Feb 2014 09:04:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-02-19T09:04:35Z</dc:date>
    <item>
      <title>Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128222#M1817984</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;this is my situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I have a &lt;STRONG&gt;data reference&lt;/STRONG&gt; to a &lt;STRONG&gt;sorted&lt;/STRONG&gt; internal table lr_t_myTable;&lt;/LI&gt;&lt;LI&gt;The sorted internal table has a &lt;STRONG&gt;non-unique&lt;/STRONG&gt; primary &lt;STRONG&gt;key&lt;/STRONG&gt;;&lt;/LI&gt;&lt;LI&gt;I need to perform a loop on the internal table &lt;STRONG&gt;only&lt;/STRONG&gt; on &lt;STRONG&gt;element&lt;SPAN style="text-decoration: underline;"&gt;s&lt;/SPAN&gt;&lt;/STRONG&gt; with key = "value1"&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "where" clause does not work because I have only the data reference or the field symbol of the original table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A loop with an &lt;EM&gt;if&lt;/EM&gt; inside is not feasible for performance reasons (the sorted table would become useless and it is really large).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I obtain this loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 14:58:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128222#M1817984</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T14:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128223#M1817985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one way, not most elegant but I have used approach before as it is only few lines of simple code and I just get the records I want to loop at&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create a table copy, but as standard table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then move all the data over...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data lt_standard type standard table of xyz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lt_standard[] = lt_sorted[].&lt;/P&gt;&lt;P&gt;delete lt_standard where key ne 'VALUE1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_standard assigning &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...do you work, updates, etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 15:03:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128223#M1817985</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T15:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128224#M1817986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However this is not a solution for me because:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;It requires 2 times the space of the original table;&lt;/LI&gt;&lt;LI&gt;It is a sequential slow approach (does not exploit the sorted table)&lt;/LI&gt;&lt;LI&gt;I am not able to know what is "xyz" (in your example)&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 15:13:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128224#M1817986</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T15:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128225#M1817987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It requires 2 times the space of the original table&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;? your copying the records from sorted to standard table. You will then remove all the records you dont want, and then wrok with the subset remaining!!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;It is a sequential slow approach (does not exploit the sorted table)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;think again - you are just looping at the records you interested in using my way for records that equal VALUE1. Sequential is now irrelevant. I deleted all the records i did not want to loop through. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;However, with your method - you are looping through a sorted table - this is still sequential - its only useful when you READ the table with a table key syntax doing it your way. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not able to know what is "xyz" (in your example)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;come on, dont be silly - xyz is just a dummy reference name - it could be VBAK or whatever.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I will leave it here as I think you have not grasped what i was suggesting. I have used this technique a handful of times and it is fast. There are in fact several ways you can resolve your problem - but I just gave you a fast simple one. &lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 16:59:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128225#M1817987</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T16:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128226#M1817988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your method is really easy to understand. I think OP is dealing with dynamic table, and this is why he can't know in advance the value of "xyz". For the &lt;EM&gt;where&lt;/EM&gt; clause to work, line type must be statically defined. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 17:09:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128226#M1817988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T17:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128227#M1817989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try to explain better my previous post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) It requires twice the original space because you are copying the original table. Suppose that the original table is 500MB, you will generate another 500MB of data and&lt;EM&gt; then&lt;/EM&gt; remove some data. Generating 500MB of extra data and then removing a part of it is both time and memory consuming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Sequential approach: yes, I would like to search records with the key using binary search, since I have a sorted table. Binary search is log(n) with n the number of records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Of course I was not searching for "xyz", what I said is that I have only a reference to the original table as a "data ref". How can I get the type of the working area without using a dynamic allocation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment I solved the problem using a work around:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I use READ... WITH KEY key='value1'&lt;/P&gt;&lt;P&gt;- I save the index returned by this reading operation;&lt;/P&gt;&lt;P&gt;- This index contains the first matching record.&lt;/P&gt;&lt;P&gt;- Inside a loop I check if the record with index+1 has the same key of the previous records.&lt;/P&gt;&lt;P&gt;- I continue to read the next record until the key is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is possibile because I have a sorted table and I am filtering with the primary key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 17:11:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128227#M1817989</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128228#M1817990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It really is like the parallel cursor method. In case you are not already using the &lt;EM&gt;FROM index&lt;/EM&gt; addition in &lt;EM&gt;LOOP&lt;/EM&gt; statement, please add it. And exit the loop on first mismatch of key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 17:19:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128228#M1817990</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T17:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128229#M1817991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Manish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So can I use the LOOP statement with FROM %index% clause and the loop will start from %index"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment I'm using a DO loop and checking the sy values. The LOOP statement would be better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 17:26:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128229#M1817991</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T17:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128230#M1817992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you can. The INDEX addition does not work for &lt;EM&gt;hashed&lt;/EM&gt; and &lt;EM&gt;any&lt;/EM&gt; table types, but will work for &lt;EM&gt;sorted&lt;/EM&gt; type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Feb 2014 17:32:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128230#M1817992</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-17T17:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128231#M1817993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Alberto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can achieve this using RTTI &amp;amp; dynamic WHERE condition for LOOP. If your ABAP kernel does not support dynamic token for LOOP...WHERE, then i don't see this solution working.&lt;/P&gt;&lt;DIV style="background-color: #e7e5dc; width: auto; overflow: auto; margin: 1em 0 !important; padding-top: 1px; font-family: courier new,courier;"&gt;&lt;OL start="1" style="list-style: decimal; background-color: #fff; margin: 0 0 1px 3.5em !important; padding: 0; color: #5c5c5c;"&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;:&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flights_tab &lt;SPAN style="color: #0000ff;"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;SORTED &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;TABLE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;OF &lt;/SPAN&gt;sflight &lt;SPAN style="color: #0000ff;"&gt;WITH &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;NON-UNIQUE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;KEY &lt;/SPAN&gt;carrid&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;PARAMETERS&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;:&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_carr &lt;SPAN style="color: #0000ff;"&gt;TYPE &lt;/SPAN&gt;sflight&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;carrid &lt;SPAN style="color: #0000ff;"&gt;VALUE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;CHECK &lt;/SPAN&gt;OBLIGATORY &lt;SPAN style="color: #0000ff;"&gt;DEFAULT &lt;/SPAN&gt;&lt;SPAN style="color: #4da619;"&gt;'LH'&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;START-OF-SELECTION&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;SELECT &lt;/SPAN&gt;* &lt;SPAN style="color: #0000ff;"&gt;FROM &lt;/SPAN&gt;sflight &lt;SPAN style="color: #0000ff;"&gt;INTO &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;TABLE &lt;/SPAN&gt;flights_tab&lt;SPAN style="color: #800080;"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-style: italic; color: #808080;"&gt;"#EC CI_NOWHERE&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;GET &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;REFERENCE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;OF &lt;/SPAN&gt;flights_tab &lt;SPAN style="color: #0000ff;"&gt;INTO &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;tab_ref&lt;SPAN style="color: #800080;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&lt;SPAN style="font-style: italic; color: #808080;"&gt;* RTTI reads the data reference &amp;amp; gives us info regarding the keys&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;o_tab_desc&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;= &lt;/SPAN&gt;CAST cl_abap_tabledescr&lt;SPAN style="color: #800080;"&gt;( &lt;/SPAN&gt;cl_abap_typedescr&lt;SPAN style="color: #808080;"&gt;=&amp;gt;&lt;/SPAN&gt;describe_by_data_ref&lt;SPAN style="color: #800080;"&gt;( &lt;/SPAN&gt;tab_ref &lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;IF &lt;/SPAN&gt;o_tab_desc&lt;SPAN style="color: #808080;"&gt;-&amp;gt;&lt;/SPAN&gt;table_kind &lt;SPAN style="color: #800080;"&gt;= &lt;/SPAN&gt;cl_abap_tabledescr&lt;SPAN style="color: #808080;"&gt;=&amp;gt;&lt;/SPAN&gt;tablekind_sorted&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&lt;SPAN style="font-style: italic; color: #808080;"&gt;*&amp;nbsp;&amp;nbsp; For illustration purposes only, can use LOOP &amp;amp; build the dynamic condition accordingly&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;READ &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;TABLE &lt;/SPAN&gt;o_tab_desc&lt;SPAN style="color: #808080;"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;key &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;ASSIGNING &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;FIELD&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;SYMBOL&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;&amp;lt;key&amp;gt;&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;INDEX &lt;/SPAN&gt;&lt;SPAN style="color: #3399ff;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;cond&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;= &lt;/SPAN&gt;|{ &amp;lt;key&amp;gt;&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;name } &lt;SPAN style="color: #800080;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #4da619;"&gt;'{ p_carr }'&lt;/SPAN&gt;|&lt;SPAN style="color: #800080;"&gt;. &lt;/SPAN&gt;&lt;SPAN style="font-style: italic; color: #808080;"&gt;"Build dynamic WHERE clause&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;TRY &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;LOOP &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;AT &lt;/SPAN&gt;tab_ref&lt;SPAN style="color: #808080;"&gt;-&amp;gt;&lt;/SPAN&gt;* &lt;SPAN style="color: #0000ff;"&gt;ASSIGNING &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;FIELD&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;SYMBOL&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;&amp;lt;wa&amp;gt;&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;cond&lt;SPAN style="color: #800080;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;WRITE&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;: &lt;/SPAN&gt;/ sy&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;tabix&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;ENDLOOP&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;CATCH &lt;/SPAN&gt;cx_sy_itab_dyn_loop &lt;SPAN style="color: #0000ff;"&gt;INTO &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;o_excp&lt;SPAN style="color: #800080;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;MESSAGE &lt;/SPAN&gt;o_excp&lt;SPAN style="color: #808080;"&gt;-&amp;gt;&lt;/SPAN&gt;get_text&lt;SPAN style="color: #800080;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN style="color: #4da619;"&gt;'I'&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;ENDTRY&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #f8f8f8; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt; &lt;/LI&gt;&lt;LI style="list-style: decimal-leading-zero; list-style-position: outside !important; border-left: 3px solid #6CE26C; background-color: #ffffff; color: #5c5c5c; padding: 0 3px 0 10px !important; margin: 0 !important; line-height: 14px;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;ENDIF&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;P&gt;In case you are not on ABAP 740, you'll have to change the code accordingly &lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.sap.com/568/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt;&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>Mon, 17 Feb 2014 21:24:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128231#M1817993</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2014-02-17T21:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128232#M1817994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You always use the inline data declaration, just to remind the rest of us that you are on ABAP 740 &lt;A __jive_macro_name="tag" class="jive_macro_tag jive_macro" data-objecttype="null" data-orig-content="showoff" href="https://community.sap.com/" tag="showoff"&gt;&lt;/A&gt; and we are not. Maybe i'll write a converter to make such statement backward compatible using search/replace &lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/568/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 03:45:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128232#M1817994</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-18T03:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128233#M1817995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is less showoff &amp;amp; more learning &lt;SPAN __jive_emoticon_name="wink" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/568/images/emoticons/wink.gif"&gt;&lt;/SPAN&gt; I need to get used to the 740 syntax &amp;amp; i'm luvin' it, isn't it cool?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;Maybe i'll write a converter to make such statement backward compatible using search/replace&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Be my guest &lt;SPAN __jive_emoticon_name="cool" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/568/images/emoticons/cool.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 08:38:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128233#M1817995</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2014-02-18T08:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128234#M1817996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Suhas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try your code as soon as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inline data declaration looks great! However we have to develop our system on 731. We are migrating everything to 740 but for the moment we are on 731.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try your code, I understood the RTTI approach, however your code looks really close to my first attemp with a standard LOOP AT ... ASSIGNING ... WHERE. I can not understand why a dynamic (cond) works while my code did not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also please could you expalin me how to write this line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;LOOP &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;AT &lt;/SPAN&gt;tab_ref&lt;SPAN style="color: #808080;"&gt;-&amp;gt;&lt;/SPAN&gt;* &lt;SPAN style="color: #0000ff;"&gt;ASSIGNING &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;FIELD&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;SYMBOL&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;&amp;lt;wa&amp;gt;&lt;SPAN style="color: #800080;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;(&lt;/SPAN&gt;cond&lt;SPAN style="color: #800080;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on 731? I'm not sure about the (cond) part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 09:45:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128234#M1817996</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-18T09:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128235#M1817997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Alberto,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that you got the idea about what the code is doing, although it is written in 740 syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll have to dereference the data reference before looping on it. This means another helper variable &lt;SPAN __jive_emoticon_name="angry" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_emote jive_macro" height="1" src="https://community.sap.com/568/images/emoticons/angry.gif" width="1"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;FIELD-SYMBOLS &amp;lt;tab&amp;gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;SORTED &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TABLE&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ASSIGN tab_ref&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;* &lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;&amp;lt;tab&amp;gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&lt;SPAN class="L0S52"&gt;&lt;SPAN class="L0S55"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;LOOP &lt;SPAN class="L0S52"&gt;AT &lt;/SPAN&gt;&amp;lt;tab&amp;gt; &lt;SPAN class="L0S52"&gt;ASSIGNING &lt;/SPAN&gt;&amp;lt;wa&amp;gt; &lt;SPAN class="L0S52"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;(&lt;/SPAN&gt;dyn_cond&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="L0S52"&gt;&amp;nbsp;&amp;nbsp; ENDLOOP&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Good thing is that you are on ABAP 731 &amp;amp; dynamic WHERE is supported &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.sap.com/568/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&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, 18 Feb 2014 10:17:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128235#M1817997</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2014-02-18T10:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128236#M1817998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sushas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you, yes I got the idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is: will the dynamic WHERE clause search in the sorted table usin binary search or will it use a linear iteration?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: this code is also working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;DATA l_cond &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;string &lt;SPAN class="L0S52"&gt;VALUE &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'FIELD1 = '&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'KEYVALUE1'&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;''&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;LOOP &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;AT &lt;/SPAN&gt;&amp;lt;lt_myTable&amp;gt; &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;&amp;lt;ls_table&amp;gt; &lt;SPAN class="L0S52"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;(&lt;/SPAN&gt;l_cond&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ENDLOOP&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm not sure that it performs binary search on the sorted table using the key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 10:33:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128236#M1817998</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-18T10:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128237#M1817999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I also found that this code is working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;DATA l_cond &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;string &lt;SPAN class="L0S52"&gt;VALUE &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'FIELD1 = '&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'KEYVALUE1'&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;''&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;LOOP &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;AT &lt;/SPAN&gt;&amp;lt;lt_myTab&amp;gt; &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;&amp;lt;ls_tabRow&amp;gt; &lt;SPAN class="L0S52"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;(&lt;/SPAN&gt;l_cond&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;BR /&gt;&amp;nbsp; &lt;SPAN class="L0S52"&gt;ENDLOOP&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm not sure if it is using the binary search on the where statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 10:44:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128237#M1817999</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-18T10:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128238#M1818000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;Alberto Bedin wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;My question is: will the dynamic WHERE clause search in the sorted table usin binary search or will it use a linear iteration?&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I had the same question yesterday. I checked the ABAP documentation &amp;amp; i don't see any thing which states that the LOOP...WHERE will not be optimized for dynamic condition &lt;SPAN __jive_emoticon_name="sad" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.sap.com/568/images/emoticons/sad.gif"&gt;&lt;/SPAN&gt; I'm not sure if SAT/SE30 can be helpful &lt;SPAN __jive_emoticon_name="confused" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.sap.com/568/images/emoticons/confused.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN class="L0S52"&gt;DATA l_cond &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;string &lt;SPAN class="L0S52"&gt;VALUE &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'FIELD1 = '&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'KEYVALUE1'&lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;''&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can use this is you know that FIELD1 will always be the keyfield. In that case you do not need RTTI&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, 18 Feb 2014 12:00:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128238#M1818000</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2014-02-18T12:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128239#M1818001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you. I think that I will check the dynamic WHERE performances on sorted tables and I will compare them with the READ statement followed by an index loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2014 13:31:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128239#M1818001</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-18T13:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128240#M1818002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested a TABLE of 10,000,000 records with 1000 matching keys:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;With a standard table and linear search (LOOP ... WHERE ... FROM field = 'value' )&lt;/LI&gt;&lt;LI&gt;With a sorted table and LOOP ... WHERE ... FROM&amp;nbsp; key = 'value'&lt;/LI&gt;&lt;LI&gt;With a sorted table and READ FROM ... WITH TABLE KEY ... followed by a LOOP FROM INDEX where index is the index of the first matching from READ statement.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The third approach is the fastest one (10-100) times faster. Incredibly the second approach is the slowest one (2 times slower then the first one). Maybe ABAP is performing multiple not optimized binary searches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This result remain the same with any number of non-unique matching keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other side the second approach is faster on small tables (10000 elements).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this could help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 09:04:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128240#M1818002</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-19T09:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Loop on a internal table with data ref and a key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128241#M1818003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Oct 2015 09:58:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-on-a-internal-table-with-data-ref-and-a-key/m-p/10128241#M1818003</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-10-07T09:58:00Z</dc:date>
    </item>
  </channel>
</rss>

