<?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 with key field - question in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564344#M584933</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;Try this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table itab with key wekrs = 'A001'
                         binary search.
if sy-subrc eq 0.
  read table itab with key werks = 'A002'
                         binary search.
  if sy-subrc eq 0.
*   &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; do your coding  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
  endif.
endif.
  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jul 2007 15:12:05 GMT</pubDate>
    <dc:creator>former_member194669</dc:creator>
    <dc:date>2007-07-23T15:12:05Z</dc:date>
    <item>
      <title>Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564336#M584925</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;Can you use the same key field more than once?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'&lt;/P&gt;&lt;P&gt;                                                                                Werks = '1002'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error when trying this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there an alternative?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:52:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564336#M584925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T14:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564337#M584926</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 need to use READ TABLE Twice&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; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:53:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564337#M584926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T14:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564338#M584927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you mean?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:55:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564338#M584927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T14:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564339#M584928</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 this requirement you can use loop at where condion ...Instead of read &lt;/P&gt;&lt;P&gt;   Loop at Internal table where werks = '1002' and '1004'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;varma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:57:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564339#M584928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T14:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564340#M584929</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;Use Loop with where condition. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at itab where werks eq 'A001' and werks eq 'A002'.
  exit.
endloop.
if sy-subrc eq 0.
  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;           &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:58:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564340#M584929</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2007-07-23T14:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564341#M584930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    I guess you are trying to use OR condition here which will not work with READ statment, you have to use loop for that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab where werks = '1004' or
                           werks = '1002'.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 14:58:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564341#M584930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T14:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564342#M584931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can not use KEY FIELD in READ statement more than once by giving different values. You need to use LOOP AT with WHERE condition and specify the condition in the WHERE clause only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT I_TVKWZ &amp;lt;b&amp;gt;WHERE WERKS = '1004' OR WERKS = '1002'&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt;DO AS PER REQUIREMENT&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try as follows if you want only with READ statement&lt;/P&gt;&lt;P&gt;DATA V_SUBRC1 TYPE SY-SUBRC.&lt;/P&gt;&lt;P&gt;DATA V_SUBRC2 TYPE SY-SUBRC.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'.&lt;/P&gt;&lt;P&gt;V_SUBRC1 = SY-SUBRC.&lt;/P&gt;&lt;P&gt;READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'.&lt;/P&gt;&lt;P&gt;V_SUBRC2 = SY-SUBRC.&lt;/P&gt;&lt;P&gt;IF V_SUBRC1 = 0 OR V_SUBRC2 = 0.&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt;DO ACCORDINLGY&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 15:01:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564342#M584931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T15:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564343#M584932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;        werks like mseg-werks,&lt;/P&gt;&lt;P&gt;        i     type i,&lt;/P&gt;&lt;P&gt;      end   of itab.&lt;/P&gt;&lt;P&gt;itab-werks = '1000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '1000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '2000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '3000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '5000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '5000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '7000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '7000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '9000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '9000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;itab-werks = '9000'. itab-i = itab-i + 1. append itab.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;loop at itab where werks = '1000' or werks = '9000'.&lt;/P&gt;&lt;P&gt;write: / itab-werks, itab-i.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 15:03:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564343#M584932</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-23T15:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564344#M584933</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;Try this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
read table itab with key wekrs = 'A001'
                         binary search.
if sy-subrc eq 0.
  read table itab with key werks = 'A002'
                         binary search.
  if sy-subrc eq 0.
*   &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; do your coding  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
  endif.
endif.
  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2007 15:12:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564344#M584933</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2007-07-23T15:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Read Table with key field - question</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564345#M584934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2007 07:27:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key-field-question/m-p/2564345#M584934</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-24T07:27:04Z</dc:date>
    </item>
  </channel>
</rss>

