<?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: Read table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608166#M272929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE is used specifically if you want to read a particular row with key element. This statement can also be used inside loop statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 1:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;Consider there are two internal tables ITAB and ITAB2. For every entry in ITAB3 ( depending up on key field F1) assume that there are many entries in ITAB. So in this case if you want to read ITAB2 with respect to ITAB then,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB into WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE ITAB2 into WA WITH KEY F1 = WA-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;Case 2:&lt;/P&gt;&lt;P&gt;======= &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In some cases you may wish to read a particular row in the internal table. Assume that you want to read 9th row,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB into WA index 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above statement no need to mention the key because you directly want the 9th row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 3:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In some cases depending up on the internal table you may have to read,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB into WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF WA-F1 EQ 'A'.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;     READ TABLE ITAB2 into WA index sy-tabix&lt;/P&gt;&lt;P&gt;          with key f1 = WA-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;&lt;/P&gt;&lt;P&gt;LIke these it all depends on how u do your logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regs,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Sep 2006 13:24:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-22T13:24:25Z</dc:date>
    <item>
      <title>Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608159#M272922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear SDN Members,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please explain me the diff between read table &amp;amp; loop at itab.&lt;/P&gt;&lt;P&gt;Diff between read table with index &amp;amp; with key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx in Advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Johnn.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:14:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608159#M272922</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608160#M272923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let me explain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;both &amp;lt;b&amp;gt;loop&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;read&amp;lt;/b&amp;gt; are used to access internal table records from body to header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;loop..endloop&amp;lt;/b&amp;gt; gets the records one by one.&lt;/P&gt;&lt;P&gt;read.. statement gets only one record from internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in read option,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;READ TABLE &amp;lt;ITAB&amp;gt; INDEX &amp;lt;I&amp;gt;.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;here u r trying to read row number I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;READ TABLE &amp;lt;ITAB&amp;gt; WITH KEY &amp;lt;x1&amp;gt; = &amp;lt;x2&amp;gt;.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;here u r accessing internal table record based on a condition. in the condition only &amp;lt;b&amp;gt;EQUALITY&amp;lt;/b&amp;gt; can be checked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if useful....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:18:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608160#M272923</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608161#M272924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT&amp;lt;/b&amp;gt; sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;READ TABLE&amp;lt;/b&amp;gt; sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note you have to sort the table before using READ with binary search ( This improves performance a lot)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vivek &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward points for all the useful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:18:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608161#M272924</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608162#M272925</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;READ TABLE: reads the table where condition satisfies and return the single record.&lt;/P&gt;&lt;P&gt; read table at index 1 or 2 ( sy-tabix or sy-index) or with key like matnr = '000000000000023455'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns the record from table where matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab.&lt;/P&gt;&lt;P&gt;it starts the loop from the first record to last record in itab where the condition satisfies or without condition too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;UR STATEMENTS.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab where matnr = '000000000000002345'.&lt;/P&gt;&lt;P&gt;UR STATEMENTS.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:20:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608162#M272925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608163#M272926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;READ TABLE :&lt;/P&gt;&lt;P&gt;to read ONLY ONE record from the internal table we use this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;option 1:&lt;/P&gt;&lt;P&gt;  you can give WHERE clause to fetch the record&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY F1 = V1&lt;/P&gt;&lt;P&gt;                         F2 = V2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will get only 1 record into ITAB (header of that internal table).&lt;/P&gt;&lt;P&gt;OPTION 2:&lt;/P&gt;&lt;P&gt; read table itab INDEX 1.&lt;/P&gt;&lt;P&gt;read the first record. you can give any index here.&lt;/P&gt;&lt;P&gt;like &lt;/P&gt;&lt;P&gt;  READ TABLE ITAB INDEX V_TABIX.&lt;/P&gt;&lt;P&gt;Here V_TABIX is of type SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT and ENDLOOP.&lt;/P&gt;&lt;P&gt;to process all the records of the internal table we use this.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB&lt;/P&gt;&lt;P&gt;*--This will loops thru all the records of the internal table ITAB.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB WHERE F1 = V1&lt;/P&gt;&lt;P&gt;                   F2 = V2.&lt;/P&gt;&lt;P&gt;*--records comes in which satisfying the above where clause.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These many ways we can use this statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:20:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608163#M272926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608164#M272927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read Table is used to get one record that matches a key or index reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP at table is used to process all or multiple records within the int table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:21:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608164#M272927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608165#M272928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Johnn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at table gets the each record into the header depends on the no. of records in the table.&lt;/P&gt;&lt;P&gt;in this case &lt;/P&gt;&lt;P&gt;sy-tabix = current index of the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table will give a single record depend on the condition u are going to give.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt; means u got the record with the satisfied condition.&lt;/P&gt;&lt;P&gt;sy-tabix = current index of the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can read table with index or usign key values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:21:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608165#M272928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Read table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608166#M272929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE is used specifically if you want to read a particular row with key element. This statement can also be used inside loop statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 1:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;Consider there are two internal tables ITAB and ITAB2. For every entry in ITAB3 ( depending up on key field F1) assume that there are many entries in ITAB. So in this case if you want to read ITAB2 with respect to ITAB then,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB into WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE ITAB2 into WA WITH KEY F1 = WA-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;Case 2:&lt;/P&gt;&lt;P&gt;======= &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In some cases you may wish to read a particular row in the internal table. Assume that you want to read 9th row,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB into WA index 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above statement no need to mention the key because you directly want the 9th row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Case 3:&lt;/P&gt;&lt;P&gt;=======&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In some cases depending up on the internal table you may have to read,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB into WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF WA-F1 EQ 'A'.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;     READ TABLE ITAB2 into WA index sy-tabix&lt;/P&gt;&lt;P&gt;          with key f1 = WA-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;&lt;/P&gt;&lt;P&gt;LIke these it all depends on how u do your logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regs,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Sep 2006 13:24:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table/m-p/1608166#M272929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-22T13:24:25Z</dc:date>
    </item>
  </channel>
</rss>

