<?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: Using Read Statements in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217894#M767411</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   First  if you do like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab into wa_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single field1&lt;/P&gt;&lt;P&gt;from dbtab&lt;/P&gt;&lt;P&gt;into l_var&lt;/P&gt;&lt;P&gt;where field1 eq wa_tab-field1.&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;Every time it will over write your internal table  l_var .Finally you will have only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT it_tab[] IS INITIAL.&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;select field1, field2 ...&lt;/P&gt;&lt;P&gt;from dbtab&lt;/P&gt;&lt;P&gt;into table l_var&lt;/P&gt;&lt;P&gt;for all entries in it_tab&lt;/P&gt;&lt;P&gt;where field1 eq it_tab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward if useful...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jan 2008 08:16:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-10T08:16:49Z</dc:date>
    <item>
      <title>Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217890#M767407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone provide me an alternative for the following statement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab into wa_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single field1&lt;/P&gt;&lt;P&gt;  from dbtab&lt;/P&gt;&lt;P&gt;  into  l_var&lt;/P&gt;&lt;P&gt;where field1 eq wa_tab-field1.&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;In the above statement i am accessing the database table for every loop....cn anyone suggest a code for better performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:04:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217890#M767407</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217891#M767408</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;Select single is fine in a loop..endloop..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can do one thing use for all entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_tab[] is initial..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select field1 from dbtable into table itab&lt;/P&gt;&lt;P&gt;for all entries in it_tab&lt;/P&gt;&lt;P&gt;where field1 = it_tab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:07:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217891#M767408</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2008-01-10T08:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217892#M767409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

if not itab1[] is initial.
   select single fld into itab2
          from tab2
          for all entries in itab1
          where fld = itab1-fld.
endif.
       
loop at itab1 into wa1.
   read table itab2 with key fld = itab1-fld.
   if sy-subrc eq 0.
      &amp;lt;code...&amp;gt;
   else.
      &amp;lt;code...&amp;gt;
   endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:09:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217892#M767409</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217893#M767410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of it_tab2,  &lt;/P&gt;&lt;P&gt;        field1,&lt;/P&gt;&lt;P&gt;        field2,&lt;/P&gt;&lt;P&gt;        end of it_tab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not  it_tab[] is initial.&lt;/P&gt;&lt;P&gt;select field1 field2&lt;/P&gt;&lt;P&gt;          from dbtab2 into table it_tab2 for all entries in it_tab &lt;/P&gt;&lt;P&gt;          where field1 = it_tab-field1.&lt;/P&gt;&lt;P&gt;endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab into wa_tab.&lt;/P&gt;&lt;P&gt;read table it_tab2 into wa_tab2 with key field1 = wa_tab-field1.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------" /&gt;&lt;P&gt;endif.&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;Rewards points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Srinivas Ch&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:12:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217893#M767410</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217894#M767411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   First  if you do like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab into wa_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single field1&lt;/P&gt;&lt;P&gt;from dbtab&lt;/P&gt;&lt;P&gt;into l_var&lt;/P&gt;&lt;P&gt;where field1 eq wa_tab-field1.&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;Every time it will over write your internal table  l_var .Finally you will have only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do like below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT it_tab[] IS INITIAL.&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;select field1, field2 ...&lt;/P&gt;&lt;P&gt;from dbtab&lt;/P&gt;&lt;P&gt;into table l_var&lt;/P&gt;&lt;P&gt;for all entries in it_tab&lt;/P&gt;&lt;P&gt;where field1 eq it_tab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward if useful...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:16:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217894#M767411</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217895#M767412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi frank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of lt_temp occurs 0,&lt;/P&gt;&lt;P&gt;field1  type dbtab-field1,&lt;/P&gt;&lt;P&gt;end of lt_temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols : &amp;lt;f_tab&amp;gt; like line of it_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select field1 &lt;/P&gt;&lt;P&gt;into table lt_temp &lt;/P&gt;&lt;P&gt;from dbtab&lt;/P&gt;&lt;P&gt;for all entries in it_tab&lt;/P&gt;&lt;P&gt;where field1 eq it_tab-field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_temp by field1.&lt;/P&gt;&lt;P&gt;delete adjacent duplicate from lt_temp comparing field1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at it_tab assigning &amp;lt;f_tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table lt_temp with key field1 = &amp;lt;f_tab&amp;gt;-field1 binary search&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;....&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;Mohaiyuddin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:18:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217895#M767412</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using Read Statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217896#M767413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In cases like the one you have asked, its always good to use 'For all Entries' concept.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all get all the records for which you are selecting inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ie... select * from &amp;lt;dbtab&amp;gt; for all entries in &amp;lt;itab&amp;gt; where &amp;lt;db_field&amp;gt; = &amp;lt;itab-field&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then you can go for reading teh individual record from the selected entries in the new table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thsi will minimise the access to the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Basha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Award points if found useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2008 08:30:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-read-statements/m-p/3217896#M767413</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-10T08:30:07Z</dc:date>
    </item>
  </channel>
</rss>

