<?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 stmt in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175262#M461867</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Balu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use &lt;/P&gt;&lt;P&gt;READ TABLE itab WITH KEY k1 = v1 ... kn = vn BINARY SEARCH.&lt;/P&gt;&lt;P&gt;Before that u have to SORT the internal table with keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Apr 2007 09:23:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-30T09:23:46Z</dc:date>
    <item>
      <title>read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175257#M461862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;read itab index i..&lt;/P&gt;&lt;P&gt;except this statement can i use read stmt in another way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:20:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175257#M461862</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175258#M461863</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 doesn't allow ne operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It reads only one record...Either by index or key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE MY_TAB INDEX 1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;READ TABLE MY_TAB WITH KEY CODE = 'ATG'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;these are the results for SY-SUBRC checks after read table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 0: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An entry was read. &lt;/P&gt;&lt;P&gt;SY-TABIX is set to the index of the entry. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 2: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An entry was read. &lt;/P&gt;&lt;P&gt;SY-TABIX is set to the index of the entry. This return code can only occur when you use the COMPARING addition. For further detauls, refer to the COMPARING section of the additions &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 4: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No entry was read. &lt;/P&gt;&lt;P&gt;The value of SY-TABIX depends on the table type and whether the BINARY SEARCH addition was specified. &lt;/P&gt;&lt;P&gt;If the table is a SORTED TABLE or a table sorted in ascending order of the type STANDARD TABLE with the BINARY SEARCH addition, SY-TABIX refers to the next-highest index. &lt;/P&gt;&lt;P&gt;Otherwise, SY-TABIX is undefined. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC = 8: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No entry was read. &lt;/P&gt;&lt;P&gt;This return code only occurs with a SORTED TABLE or a STANDARD TABLE with the BINARY SEARCH addition. SY-TABIX is set to the number of all entries plus 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reading records with keys&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reading lines with Index&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3730358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3730358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Reshma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175258#M461863</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175259#M461864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab1.

read table itab with key  field1 eq itab1-field1 binary search.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Pls reward points for helpful answers and close all your threads&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:23:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175259#M461864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175260#M461865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You have to use some index or fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INDEX SY-TABIX.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INDEX 2.&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY KUNNR = ITAB1-KUNNR BINARY SEARCH.&lt;/P&gt;&lt;P&gt;(IN THE LOOP OF itab1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:23:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175260#M461865</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175261#M461866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See the READ statement in ABAP documentation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:23:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175261#M461866</guid>
      <dc:creator>alex_m</dc:creator>
      <dc:date>2007-04-30T09:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175262#M461867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Balu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use &lt;/P&gt;&lt;P&gt;READ TABLE itab WITH KEY k1 = v1 ... kn = vn BINARY SEARCH.&lt;/P&gt;&lt;P&gt;Before that u have to SORT the internal table with keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:23:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175262#M461867</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175263#M461868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Balu&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;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;To read a single line of any table, use the statement: &amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&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;&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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Specifying the Search Key&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The search key may be either the table key or another key. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Using the Table Key&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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;&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;&lt;/P&gt;&lt;P&gt;or as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE &amp;lt;itab&amp;gt; WITH TABLE KEY &amp;lt;k1&amp;gt; = &amp;lt;f 1&amp;gt; ... &amp;lt;k n&amp;gt; = &amp;lt;f n&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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;n i &amp;gt; using the form (&amp;lt;n i &amp;gt;) = &amp;lt;f i &amp;gt;. If the data types of &amp;lt;f i &amp;gt; are not compatible with the key fields, the system converts them. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The system searches for the relevant lines as follows: &lt;/P&gt;&lt;P&gt;&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;&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;&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 independent of the number of table entries. &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Using a Different Search Key&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&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;&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;&lt;/P&gt;&lt;P&gt;or as follows&lt;/P&gt;&lt;P&gt;&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;k n&amp;gt; = &amp;lt;f n&amp;gt; &amp;lt;result&amp;gt;.&lt;/P&gt;&lt;P&gt;&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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the second case, the search key can consist of any of the table fields &amp;lt;k 1 &amp;gt;...&amp;lt;k n &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;n i &amp;gt; using the form (&amp;lt;n i &amp;gt;) = &amp;lt;f i &amp;gt;. If &amp;lt;n i &amp;gt; is empty when the statement is executed, the search field is ignored. If the data types of &amp;lt;f i &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 specifying offset and length. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The search is linear for all table types. The runtime is in linear relation to the number of table lines. &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Specifying the Extra Processing Option&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify an option that specifies what the system does with the table entry that it finds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Using a Work Area&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;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;&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;f 2&amp;gt; ... &lt;/P&gt;&lt;P&gt;                                             |ALL FIELDS] &lt;/P&gt;&lt;P&gt;                                  [TRANSPORTING &amp;lt;f1&amp;gt; &amp;lt;f 2&amp;gt; ... &lt;/P&gt;&lt;P&gt;                                                 |ALL FIELDS &lt;/P&gt;&lt;P&gt;                                                |NO FIELDS].&lt;/P&gt;&lt;P&gt;&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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use the COMPARING addition, the specified table fields &amp;lt;f i &amp;gt; of the structured line type are compared with the corresponding fields of the work area before being transported. If you use 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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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 TRANSPORTING, 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 SY-SUBRC 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;&lt;/P&gt;&lt;P&gt;In both additions, you can specify a field &amp;lt;f i &amp;gt; dynamically as the contents of a field &amp;lt;n i &amp;gt; in the form (&amp;lt;n i &amp;gt;). If &amp;lt;n i &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;&amp;lt;b&amp;gt;Using a Field Symbol&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can assign the table entry read from the table to a field symbol by specifying &amp;lt;result&amp;gt; as follows: &lt;/P&gt;&lt;P&gt;&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;&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. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For further information about assigning table lines to field symbols, refer to Access Using Field Symbols.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Examples&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COL1 TYPE I,&lt;/P&gt;&lt;P&gt;COL2 TYPE I,&lt;/P&gt;&lt;P&gt;END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;  LINE-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;  LINE-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;INSERT LINE INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LINE-COL1 = 2. LINE-COL2 = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB FROM LINE INTO LINE COMPARING COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE: 'SY-SUBRC =', SY-SUBRC.&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;WRITE: / LINE-COL1, LINE-COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC =    2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         2        4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program fills a hashed table with a list of square numbers. The work area LINE, which is compatible with the line type, is filled with the numbers 2 and 3. The READ statement reads the line of the table in which the key field COL1 has the same value as in the work area and copies it into the work area. SY-SUBRC is set to 2, because the contents of field COL2 were different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COL1 TYPE I,&lt;/P&gt;&lt;P&gt;COL2 TYPE I,&lt;/P&gt;&lt;P&gt;END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;  LINE-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;  LINE-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;INSERT LINE INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH TABLE KEY COL1 = 3 &lt;/P&gt;&lt;P&gt;                INTO LINE TRANSPORTING COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE:   'SY-SUBRC =', SY-SUBRC,&lt;/P&gt;&lt;P&gt;       / 'SY-TABIX =', SY-TABIX.&lt;/P&gt;&lt;P&gt;SKIP.&lt;/P&gt;&lt;P&gt;WRITE: / LINE-COL1, LINE-COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC =    0&lt;/P&gt;&lt;P&gt;SY-TABIX =       3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         0        9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program fills a sorted table with a list of square numbers. The READ statement reads the line of the table in which the key field COL1 has the same value as in the work area and copies it into the work area. Only the contents of COL2 are copied into the work area LINE. SY-SUBRC is zero, and SY-TABIX is 3, because ITAB is an index table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;        COL1 TYPE I,&lt;/P&gt;&lt;P&gt;        COL2 TYPE I,&lt;/P&gt;&lt;P&gt;      END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;  LINE-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;  LINE-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;  INSERT LINE INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH KEY COL2 = 16  TRANSPORTING NO FIELDS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE:   'SY-SUBRC =', SY-SUBRC,&lt;/P&gt;&lt;P&gt;       / 'SY-TABIX =', SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SY-SUBRC =    0&lt;/P&gt;&lt;P&gt;SY-TABIX =       4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program fills a sorted table with a list of square numbers. The READ statement reads the line of the table in which the key field COL1 has the value 16. It does not use the table key. No fields are copied to a work area or assigned to a field symbol. Instead, only the system fields are set. SY-SUBRC is zero, since a line was found, and SY-TABIX is four.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COL1 TYPE I,&lt;/P&gt;&lt;P&gt;COL2 TYPE I,&lt;/P&gt;&lt;P&gt;END OF LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS &amp;lt;FS&amp;gt; LIKE LINE OF ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO 4 TIMES.&lt;/P&gt;&lt;P&gt;  LINE-COL1 = SY-INDEX.&lt;/P&gt;&lt;P&gt;  LINE-COL2 = SY-INDEX ** 2.&lt;/P&gt;&lt;P&gt;INSERT LINE INTO TABLE ITAB.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;FS&amp;gt;-COL2 = 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO LINE.&lt;/P&gt;&lt;P&gt;  WRITE: / LINE-COL1, LINE-COL2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         1        1&lt;/P&gt;&lt;P&gt;         2      100&lt;/P&gt;&lt;P&gt;         3        9&lt;/P&gt;&lt;P&gt;         4       16&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program fills a hashed table with a list of square numbers. The READ statement reads the line of the table in which the key field COL1 has the value 2 and assigns it to the field symbol &amp;lt;FS&amp;gt;. The program then assigns the value 100 to component COL2 of &amp;lt;FS&amp;gt;. This also changes the corresponding table field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Regards Rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:28:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175263#M461868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175264#M461869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Balu, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the definition of READ statement from SAP:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
READ TABLE itab 



Syntax 
READ TABLE itab { table_key 
                | free_key 
                | index } result. 



Effect 
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read. 

If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows. 



System Fields 

The statement READ TABLE sets system fields sy-subrc and sy-tabix. 

sy-subrc Relevance 
0 Row found. sy-tabix is set to the table index of the entry for index tables, and to the value 0 for hashed-tables. 
2 Like sy-subrc equals 0. Differentiates cases that use the addition COMPARING in result. 
4 Row not found. For sorted tables and when the BINARY SEARCH in free_key addition is used, sy-tabix is set to the table index of the entry before it was inserted with INSERT. Otherwise, sy-tabix is not defined. 
8 Like sy-subrc equals 4. For sorted tables, however, and when the addition BINARY SEARCH is used, the end of the table was reached, and sy-tabix is set to the number of rows + 1. 
 


The system fields sy-tfill and sy-tleng are also supplied with data. 



Note 
Besides the alternatives shown above for specifying the row to be read, there is another obsolete key specification obsolete_key possible. 



Exceptions 
Non-Catchable Exceptions 



Cause: When reading a table with READ ... WITH [TABLE] KEY, duplicative and overlapping key specifications were used. 
Runtime Error: DYN_KEY_DUPLICATE 

Cause: When reading a table of the type SORTED, the specified key fields have to be a beginning part of the table key when you specify BINARY_SEARCH. 
Runtime Error: ITAB_ILLEGAL_BINARY_SEARCH 

Cause: Missing key specification. 
Runtime Error: ITAB_KEY_COMPONENT_MISSING 

Cause: Illegal key specification when accessing a key table. 
Runtime Error: ITAB_KEY_ILLEGAL_COMPONENT 

Cause: Illegal implicit key specification in the Unicode context. 
Runtime Error: READ_ITAB_UC_KEY_ERROR 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Please award points if it helps...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:37:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175264#M461869</guid>
      <dc:creator>aris_hidalgo</dc:creator>
      <dc:date>2007-04-30T09:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: read stmt</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175265#M461870</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;&lt;/P&gt;&lt;P&gt; READ - Read an internal table                                                                                &lt;/P&gt;&lt;P&gt;Basic form    READ TABLE itab.                            &lt;/P&gt;&lt;P&gt;               READ TABLE itab INTO wa.                                                                                &lt;/P&gt;&lt;P&gt;Additions:                                                                                &lt;/P&gt;&lt;P&gt;1a. ... WITH KEY k1 = v1 ... kn = vn        &lt;/P&gt;&lt;P&gt;               1b. ... WITH KEY = value                    &lt;/P&gt;&lt;P&gt;               1c. ... WITH KEY key                        &lt;/P&gt;&lt;P&gt;       &amp;lt;b&amp;gt;        2.  ... BINARY SEARCH                      &amp;lt;/b&amp;gt;                3.  ... INDEX idx                           &lt;/P&gt;&lt;P&gt;               4a. ... COMPARING f1 f2 ...                 &lt;/P&gt;&lt;P&gt;               4b. ... COMPARING ALL FIELDS                &lt;/P&gt;&lt;P&gt;               5a. ... TRANSPORTING f1 f2 ...              &lt;/P&gt;&lt;P&gt;               5b. ... TRANSPORTING NO FIELDS              &lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2007 09:47:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-stmt/m-p/2175265#M461870</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-30T09:47:01Z</dc:date>
    </item>
  </channel>
</rss>

