<?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 read statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324753#M510800</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi experts ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please explain me about loop and read statement ..&lt;/P&gt;&lt;P&gt;what is the difference between loop and read..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 May 2007 10:20:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-31T10:20:36Z</dc:date>
    <item>
      <title>read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324753#M510800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi experts ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please explain me about loop and read statement ..&lt;/P&gt;&lt;P&gt;what is the difference between loop and read..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:20:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324753#M510800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324754#M510801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sweta,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table gets a single row from the internal table.&lt;/P&gt;&lt;P&gt;loop statement is used to get more than one row from the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:22:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324754#M510801</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324755#M510802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;         It complete depends on what you wish to do with the table data...lets say you have the main data in internal table itab and want to do some calculation for each record..you need to use LOOP AT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or if you are processing some other internal table and just need to fetch the corresponding record from itab..use should use READ TABLE ...it also advisable to sort the table internal table when you use READ on it and use BINARY SEARCH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:26:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324755#M510802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324756#M510803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;LOOP: looop will read each and evry record in the inetrnal table.&lt;/P&gt;&lt;P&gt;Loop doesnt return Sy-subrc value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ : statement will read only single record at at time and not more than that.&lt;/P&gt;&lt;P&gt;Read statement will return Sy-subrc value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if we want to compare 2 internal tables (itab1 &amp;amp; itab2) then we will loop one internal table and read another internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex:  loop at itab1 into w_itab1.&lt;/P&gt;&lt;P&gt;read table itab2 into e_iatb2 with key f1 = w_itab1-f1.&lt;/P&gt;&lt;P&gt;If sy-subrc  = 0.&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;....logic...&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revert back if any issues.&lt;/P&gt;&lt;P&gt;Reward with points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:26:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324756#M510803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324757#M510804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read Table returns a single entry if it exists. If not exists SY-SUBRC is 4.&lt;/P&gt;&lt;P&gt;Loop statement returns every entry of the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually you use read table to know if exists a determined entry and loop to loop all table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324757#M510804</guid>
      <dc:creator>former_member582701</dc:creator>
      <dc:date>2007-05-31T10:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324758#M510805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi swetha &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LOOP...ENDLOOP screen command lets you perform looping operations in the flow logic. You can use this statement to loop through both table controls and step loops. Between a LOOP and its ENDLOOP, you can use the FIELD, MODULE, SELECT, VALUES and CHAIN screen keywords. Most often, you use the MODULE statement to call an ABAP module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You must code a LOOP statement in both the PBO and PAI events for each table in your screen. This is because the LOOP statement causes the screen fields to be copied back and forth between the ABAP program and the screen field. For this reason, at least an empty LOOP...ENDLOOP must be there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two important forms of the LOOP statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP.&amp;lt;/b&amp;gt;This statement loops through screen table rows, transferring the data in each block to and from the corresponding ABAP fields in your program. The screen table fields may be declared in ABAP as anything (database table, structure or individual fields) except as internal table fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With step loops, if you are implementing your own scrolling (for example, with F21 - F24 ) you must use this statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;internal table&amp;gt;.&lt;/P&gt;&lt;P&gt;This statement loops through an internal table and the screen table rows in parallel. The screen table fields often are, but need not be, declared as internal table fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this LOOP, step loop displays appears with scroll bars. This scrolling is handled automatically by the system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more details on the different LOOP statements, see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping Directly Through a Screen Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looping Through an Internal Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Read&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The read statement is used to read a particular table or any field &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewards if helpfull&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:31:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324758#M510805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324759#M510806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;if your intension to to read JUST only one record from the internal table&amp;lt;/b&amp;gt;,&lt;/P&gt;&lt;P&gt;you can use&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY F1 = &amp;lt;VALUE&amp;gt; ...&lt;/P&gt;&lt;P&gt;BINARY SEARDCH.&lt;/P&gt;&lt;P&gt;this statement can ONLY return 1 record. so if you know,only 1 record will be there for the given condition,you can use this statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;you must use LOOP AT and ENDLOOP statements to process more than 1 record.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB WHERE F1 = &amp;lt;VALUE&amp;gt;.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Case 1:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;If table has lot of data first of all loop at using field symbols,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB ASSIGNING &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would definitely improve the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Case 1.1:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;=========&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have single loop and dependsing up on the previous value you want to select data. Then first sort that internal table based on primary key and read the table using READ statement with BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB by f1.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INTO &amp;lt;WA&amp;gt; WITH KEY f1 = &amp;lt;Variable&amp;gt;&lt;/P&gt;&lt;P&gt;BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Case 3:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;Always ignore Loop inside loop. Instead go for READ if you have to play around 2 loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO &amp;lt;WA&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB2 INTO &amp;lt;WA2&amp;gt; WITH KEY&lt;/P&gt;&lt;P&gt;f1 = &amp;lt;WA&amp;gt;-f1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;ravish&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;plz dont forget to reward points if helpful&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:31:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324759#M510806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324760#M510807</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;Loop statement:  You use the Loop...Endloop to process the records of an internal table (where the condition (if any)specified in the WHERE clause of LOOP AT ITAB is used).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT itab [ WHERE &amp;lt;expression&amp;gt; ]&lt;/P&gt;&lt;P&gt;ENDLOOP.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ statement is used to get/retrieve a record matching the condition from a internal table holding the records. We sort the internal table on key fields and use BINARY SEARCH  to increase the efficiency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg: &amp;lt;b&amp;gt;READ Table itab with key field1 = &amp;lt;value&amp;gt; binary search.&amp;lt;/b&amp;gt;&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;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 10:33:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324760#M510807</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T10:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324761#M510808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks all...i have got the my answer..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 11:37:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324761#M510808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T11:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324762#M510809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sweta &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If ur problem is solved then give points to the related person and close ur thread so that it will be not confused to help others &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 11:40:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324762#M510809</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T11:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324763#M510810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In loop control will take all entries in that table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose u do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab  into wa_itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;control will run for all entries in itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and if u do read table itab into wa_itab with key&amp;lt; &amp;gt; &lt;/P&gt;&lt;P&gt;it will take only first entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sudha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 11:44:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324763#M510810</guid>
      <dc:creator>S0025444845</dc:creator>
      <dc:date>2007-05-31T11:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: read statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324764#M510811</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;&amp;lt;b&amp;gt;Reading Lines of Tables&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;To read a single line of any table, use the statement:&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; &amp;lt;key&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;For the statement to be valid for any kind of table, you must specify the entry using the key and not the index. You specify the key in the &amp;lt;key&amp;gt; part of the statement. The &amp;lt;result&amp;gt; part can specify a further processing option for the line that is retrieved. If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate entries, the first entry is read. Specifying the Search Key The search key may be either the table key or another key. &lt;/P&gt;&lt;P&gt;Using the Table Key To use the table key of &amp;lt;itab&amp;gt; as a search key, enter &amp;lt;key&amp;gt; as follows:&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; FROM &amp;lt;wa&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;or as follows&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; WITH TABLE KEY &amp;lt;k1&amp;gt; = &amp;lt;f1&amp;gt; ... &amp;lt;kn&amp;gt; = &amp;lt;fn&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;In the first case, &amp;lt;wa&amp;gt; must be a work area compatible with the line type of &amp;lt;itab&amp;gt;. The values of the key fields are taken from the corresponding components of the work area. In the second case, you have to supply the values of each key field explicitly. If you do not know the name of one of the key fields until runtime, you can specify it as the content of a field &amp;lt;ni&amp;gt; using the form (&amp;lt;ni&amp;gt;) = &amp;lt;fi&amp;gt;. If the data types of &amp;lt;fi&amp;gt; are not compatible with the key fields, the system converts them. The system searches for the relevant lines as follows:&lt;/P&gt;&lt;P&gt;  Standard tables&lt;/P&gt;&lt;P&gt;Linear search, where the runtime is in linear relation to the number of table entries.&lt;/P&gt;&lt;P&gt;  Sorted tables&lt;/P&gt;&lt;P&gt;Binary search, where the runtime is in logarithmic relation to the number of table entries.&lt;/P&gt;&lt;P&gt;  Hashed tables&lt;/P&gt;&lt;P&gt;The entry is found using the hash algorithm of the internal table. The runtime is&lt;/P&gt;&lt;P&gt;independent of the number of table entries.&lt;/P&gt;&lt;P&gt;Using a Different Search Key&lt;/P&gt;&lt;P&gt;To use a key other than the table key as a search key, enter &amp;lt;key&amp;gt; as follows:&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; WITH KEY = &amp;lt;f&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;or as follows&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; WITH KEY &amp;lt;k1&amp;gt; = &amp;lt;f1&amp;gt; ... &amp;lt;kn&amp;gt; = &amp;lt;fn&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;BC - ABAP Programming SAP AG&lt;/P&gt;&lt;P&gt;In the first case, the whole line of the internal table is used as the search key. The contents of the entire table line are compared with the contents of field &amp;lt;f&amp;gt;. If &amp;lt;f&amp;gt; is not compatible with the line type of the table, the value is converted into the line type. The search key allows you to find entries in internal tables that do not have a structured line type, that is, where the line is a single field or an internal table type. In the second case, the search key can consist of any of the table fields &amp;lt;k1&amp;gt;...&amp;lt;kn&amp;gt;. If you do not know the name of one of the components until runtime, you can specify it as the content of a field &amp;lt;ni&amp;gt; using the form (&amp;lt;ni&amp;gt;) = &amp;lt;fi&amp;gt;. If &amp;lt;ni&amp;gt; is empty when the statement is executed, the search field is ignored. If the data types of &amp;lt;fi&amp;gt; are not compatible with the components in the internal table, the system converts them. You can restrict the search to partial fields by pecifying offset and length.The search is linear for all table types. The runtime is in linear relation to the number of table lines. Specifying the Extra Processing Option&lt;/P&gt;&lt;P&gt;You can specify an option that specifies what the system does with the table entry that it finds. Using a Work Area You can write the table entry read from the table into a work area by specifying &amp;lt;result&amp;gt; as follows:&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; &amp;lt;key&amp;gt; INTO &amp;lt;wa&amp;gt; [COMPARING &amp;lt;f1&amp;gt; &amp;lt;f2&amp;gt; ...&lt;/P&gt;&lt;P&gt;|ALL FIELDS]&lt;/P&gt;&lt;P&gt;[TRANSPORTING &amp;lt;f1&amp;gt; &amp;lt;f2&amp;gt; ...&lt;/P&gt;&lt;P&gt;|ALL FIELDS&lt;/P&gt;&lt;P&gt;|NO FIELDS].&lt;/P&gt;&lt;P&gt;If you do not use the additions COMPARING or TRANSPORTING, the contents of the table line must be convertible into the data type of the work area &amp;lt;wa&amp;gt;. If you specify COMPARING or TRANSPORTING, the line type and work area must be compatible. You should always use a work area that is compatible with the line type of the relevant internal table. If you use the COMPARING addition, the specified table fields &amp;lt;fi&amp;gt; of the structured line type are compared with the corresponding fields of the work area before being transported. If you use&lt;/P&gt;&lt;P&gt;the ALL FIELDS option, the system compares all components. If the system finds an entry with the specified key &amp;lt;key&amp;gt; and if the contents of the compared fields are the same, SY-SUBRC is set to 0. If the contents of the compared fields are not the same, it returns the value 2. If the system cannot find an entry, SY-SUBRC is set to 4. If the system finds an entry, it copies it into the target work area regardless of the result of the comparison. If you use the TRANSPORTING addition, you can specify the table fields of the structured line type that you want to transport into the work area. If you specify ALL FIELDS without RANSPORTING, the contents of all of the fields are transported. If you specify NO FIELDS, no fields are transported. In the latter case, the READ statement only fills the system fields SYSUBRC and SY-TABIX. Specifying the work area &amp;lt;wa&amp;gt; with TRANSPORTING NO FIELDS is unnecessary, and should be omitted.&lt;/P&gt;&lt;P&gt;In both additions, you can specify a field &amp;lt;fi&amp;gt; dynamically as the contents of a field &amp;lt;ni&amp;gt; in the form (&amp;lt;ni&amp;gt;). If &amp;lt;ni&amp;gt; is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using a Field SymbolYou can assign the table entry read from the table to a field symbol by specifying &amp;lt;result&amp;gt; as&lt;/P&gt;&lt;P&gt;follows:&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; &amp;lt;key&amp;gt; ASSIGNING &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;After the READ statement, the field symbol points to the table line. If the line type is structured, you should specify the same type for the field symbol when you declare  it. This allows you to address the components of the field symbol. If you cannot specify the type statically, you must use further field symbols and the technique of assigning components of structures  to address the components of the structure.For further information about assigning table lines to field symbols, refer to Access Using Field Symbols.&amp;lt;b&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;loop&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a loop, a statement block is executed several times in succession. There are four kinds of&lt;/P&gt;&lt;P&gt;loops in ABAP:&lt;/P&gt;&lt;P&gt;  Unconditional loops using the DO statement.&lt;/P&gt;&lt;P&gt;  Conditional loops using the WHILE statement.&lt;/P&gt;&lt;P&gt;  Loops through internal tables and extract datasets using the LOOP statement.&lt;/P&gt;&lt;P&gt;  Loops through datasets from database tables using the SELECT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unconditional Loops&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To process a statement block several times unconditionally, use the following control structure:&lt;/P&gt;&lt;P&gt;DO [&amp;lt;n&amp;gt; TIMES] [VARYING &amp;lt;f&amp;gt; FROM &amp;lt;f1&amp;gt; NEXT &amp;lt;f2&amp;gt;].&lt;/P&gt;&lt;P&gt;&amp;lt;Statement block&amp;gt;&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;If you do not specify any additions, the statement block is repeated until it reaches a termination&lt;/P&gt;&lt;P&gt;statement such as EXIT or STOP (see below). The system field SY-INDEX contains the number of loop passes, including the current loop pass Use the TIMES addition to restrict the number of loop passes to &amp;lt;n&amp;gt;. &amp;lt;n&amp;gt; can be literal or a variable. If &amp;lt;n&amp;gt; is 0 or negative, the system does not process the loop. If you do not use the&lt;/P&gt;&lt;P&gt;TIMES option, you must ensure that the loop contains at least one EXIT or STOP statement to avoid endless loops.&lt;/P&gt;&lt;P&gt;You can assign new values to a variable &amp;lt;f&amp;gt; in each loop pass by using the VARYING option You can use the VARYING addition more than once in a DO statement. &amp;lt;f1&amp;gt; and &amp;lt;f2&amp;gt; are the first two fields of a sequence of fields the same distance apart in memory and with the same type&lt;/P&gt;&lt;P&gt;and length. In the first loop pass, &amp;lt;f&amp;gt; takes the value &amp;lt;f1&amp;gt;, in the second loop pass, &amp;lt;f2&amp;gt;, and so&lt;/P&gt;&lt;P&gt;on. If you change the value of the field &amp;lt;f&amp;gt; within the DO loop, the value of the current field &amp;lt;fi&amp;gt;&lt;/P&gt;&lt;P&gt;is also changed. You must ensure that there are not more loop passes than fields in the sequence, otherwise a runtime error occurs. You can nest DO loops and combine them with other loop forms. Simple example of a DO loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;WRITE SY-INDEX.&lt;/P&gt;&lt;P&gt;IF SY-INDEX = 3.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;The output is:&lt;/P&gt;&lt;P&gt;BC - ABAP Programming SAP AG&lt;/P&gt;&lt;P&gt;Loops&lt;/P&gt;&lt;P&gt;246 April 2001&lt;/P&gt;&lt;P&gt;1 2 3&lt;/P&gt;&lt;P&gt;The loop is processed three times. Here, the processing passes through the loop&lt;/P&gt;&lt;P&gt;three times and then leaves it after the EXIT statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Conditional Loops&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To repeat a statement block for as long as a certain condition is true, use the following control&lt;/P&gt;&lt;P&gt;structure:&lt;/P&gt;&lt;P&gt;WHILE &amp;lt;condition&amp;gt; [VARY &amp;lt;f&amp;gt; FROM &amp;lt;f1&amp;gt; NEXT &amp;lt;f2&amp;gt;].&lt;/P&gt;&lt;P&gt;&amp;lt;statement block&amp;gt;&lt;/P&gt;&lt;P&gt;ENDWHILE.&lt;/P&gt;&lt;P&gt;&amp;lt;condition&amp;gt; can be any logical expression [Page 225]. The statement block between WHILE and ENDWHILE is repeated as long as the condition is true or until a termination statement such as EXIT or STOP occurs. The system field SY-INDEX contains the number of loop passes,&lt;/P&gt;&lt;P&gt;including the current loop pass. The VARY option of the WHILE statement works in the same way as the VARYING option of the DO statement (see above). To avoid endless loops, you must ensure that the condition of a WHILE statement can be false, or that the statement block contains a termination statement such as EXIT or STOP.&lt;/P&gt;&lt;P&gt;You can nest WHILE loops to any depth, and combine them with other loop forms. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: LENGTH TYPE I VALUE 0,&lt;/P&gt;&lt;P&gt;STRL TYPE I VALUE 0,&lt;/P&gt;&lt;P&gt;STRING(30) TYPE C VALUE 'Test String'.&lt;/P&gt;&lt;P&gt;STRL = STRLEN( STRING ).&lt;/P&gt;&lt;P&gt;WHILE STRING NE SPACE.&lt;/P&gt;&lt;P&gt;WRITE STRING(1).&lt;/P&gt;&lt;P&gt;LENGTH = SY-INDEX.&lt;/P&gt;&lt;P&gt;SHIFT STRING.&lt;/P&gt;&lt;P&gt;ENDWHILE.&lt;/P&gt;&lt;P&gt;WRITE: / 'STRLEN: ', STRL.&lt;/P&gt;&lt;P&gt;WRITE: / 'Length of string:', LENGTH.&lt;/P&gt;&lt;P&gt;The output appears as follows:&lt;/P&gt;&lt;P&gt;T e s t S t r i n g&lt;/P&gt;&lt;P&gt;STRLEN: 11&lt;/P&gt;&lt;P&gt;Length of String: 11&lt;/P&gt;&lt;P&gt;Here, a WHILE loop is used to determine the length of a character string. This is done by shifting the string one position to the left each time the loop is processed&lt;/P&gt;&lt;P&gt;until it contains only blanks. This example has been chosen to demonstrate the WHILE statement. Of course, you can determine the length of the string far more&lt;/P&gt;&lt;P&gt;easily and efficiently using the STRLEN function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Terminating Loops&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;ABAP contains termination statements that allow you to terminate a loop prematurely. There are two categories of termination statement - those that only apply to the loop, and those that apply to the entire processing block in which the loop occurs. The STOP and REJECT statements belong to the latter group, and are described in more detail under Leaving Event Blocks The termination statements that apply only to the loop in which they occur are CONTINUE, CHECK, and EXIT. You can only use the CONTINUE statement in a loop. CHECK and EXIT, on the other hand, are context-sensitive. Within a loop, they only apply to the execution of the loop&lt;/P&gt;&lt;P&gt;itself. Outside of a loop, they terminate the entire processing block in which they occur (subroutine, dialog module, event block, and so on). CONTINUE, CHECK, and EXIT can be used in all four loop types in ABAP (DO, WHILE, LOOP, and SELECT).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Terminating a Loop Pass Unconditionally&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To terminate a single loop pass immediately and unconditionally, use the CONTINUE statement&lt;/P&gt;&lt;P&gt;in the statement block of the loop. After the statement, the system ignores any remaining statements in the current statement block, and starts the next loop pass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;IF SY-INDEX = 2.&lt;/P&gt;&lt;P&gt;CONTINUE.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WRITE SY-INDEX.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;The output is:&lt;/P&gt;&lt;P&gt;1 3 4&lt;/P&gt;&lt;P&gt;The second loop pass is terminated without the WRITE statement being processed. Terminating a Loop Pass Conditionally To terminate a single loop pass conditionally, use the CHECK &amp;lt;condition&amp;gt; statement in the&lt;/P&gt;&lt;P&gt;statement block of the loop. If the condition is not true, any remaining statements in the current statement block after the CHECK statement are ignored, and the next loop pass starts. &amp;lt;condition&amp;gt; can be any logical&lt;/P&gt;&lt;P&gt;expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;CHECK SY-INDEX BETWEEN 2 and 3.&lt;/P&gt;&lt;P&gt;WRITE SY-INDEX.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;The output is:&lt;/P&gt;&lt;P&gt;2 3&lt;/P&gt;&lt;P&gt;The first and fourth loop passes are terminated without the WRITE statement being processed, because SY-INDEX is not between 2 and 3. &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Exiting a Loop&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;To terminate an entire loop immediately and unconditionally, use the EXIT statement in the&lt;/P&gt;&lt;P&gt;statement block of the loop. After this statement, the loop is terminated, and processing resumes after the closing statement of the loop structure (ENDDO, ENDWHILE, ENDLOOP, ENDSELECT). In nested loops, only the&lt;/P&gt;&lt;P&gt;current loop is terminated.&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;IF SY-INDEX = 3.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;WRITE SY-INDEX.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;The output is:&lt;/P&gt;&lt;P&gt;1 2&lt;/P&gt;&lt;P&gt;In the third loop pass, the loop is terminated before the WRITE statement is&lt;/P&gt;&lt;P&gt;processed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward points if it helps.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2007 11:45:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement/m-p/2324764#M510811</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-31T11:45:47Z</dc:date>
    </item>
  </channel>
</rss>

