<?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: select inside loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969890#M398066</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will effect performance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of that first select all the data from A506 and KONP into 2 internal tables and then READ the data in the loop&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Feb 2007 11:51:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-19T11:51:46Z</dc:date>
    <item>
      <title>select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969886#M398062</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; i am new to abap as well as to this forum.pls help me....&lt;/P&gt;&lt;P&gt;i have code something like this..&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;CLEAR V_KNUMH.&lt;/P&gt;&lt;P&gt;SELECT SINGLE KNUMH FROM A506 INTO V_KNUMH WHERE MATNR = ITAB-MATNR.&lt;/P&gt;&lt;P&gt;SELECT SINGLE KBETR FROM KONP INTO ITAB-KBETR2 WHERE KNUMH = V_KNUMH.&lt;/P&gt;&lt;P&gt;MODIFY ITAB.&lt;/P&gt;&lt;P&gt;CLEAR ITAB.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will this SELECT INSIDE LOOP affects the performance? how to avoid this?&lt;/P&gt;&lt;P&gt;thanx in advance..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;maya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:47:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969886#M398062</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969887#M398063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welcome to SDN!!!&lt;/P&gt;&lt;P&gt;S it will affect the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change it like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF not itab[] is initial.
SELECT knumh from a506
             into table i_a506
             for all entries in itab
             where matnr = itab-matnr.
If sy-subrc = 0.
SELECT matnr KBETR FROM KONP 
             INTO table i_konp
             for all entries in i_a506
             WHERE KNUMH = i_a506-KNUMH.
ENDIF.
ENDIF.
LOOP AT ITAB.
READ TABLE i_konp WITH KEY ........
IF sy-subrc = 0.
itab-knmuh = i_konp-knmuh.
endif.
MODIFY ITAB.
CLEAR ITAB.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Judith Jessie Selvi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:50:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969887#M398063</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969888#M398064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Maya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Select Single statement inside a loop will not affect much from performance point of view. .. but tbetter try using it outside the loop .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:51:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969888#M398064</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969889#M398065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank u for ur response..&lt;/P&gt;&lt;P&gt;pls let me know how can i avoid this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;maya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:51:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969889#M398065</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969890#M398066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will effect performance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of that first select all the data from A506 and KONP into 2 internal tables and then READ the data in the loop&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:51:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969890#M398066</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969891#M398067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;  Welcome to SDN.&lt;/P&gt;&lt;P&gt;It will defintely affects the Performance.&lt;/P&gt;&lt;P&gt;Try to avoid selects inside the loop for good coding .&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;kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:54:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969891#M398067</guid>
      <dc:creator>sreeramkumar_madisetty</dc:creator>
      <dc:date>2007-02-19T11:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969892#M398068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;select knumh
         matnr into table it_knumh
         from A506.

select kbetr
          knumh 
          into table it_kbetr.
          from KONP.

LOOP AT ITAB.
CLEAR V_KNUMH.
read table it_knumh with key matnr eq itab-matnr.
v_knumh = it_knumh-knumh.
read table it_kbetr with key knumh eq v_knumh.
ITAB-KBETR2 = it_kbetr-kbetr.

MODIFY ITAB.
CLEAR ITAB.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Chandrasekhar Jagarlamudi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:55:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969892#M398068</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969893#M398069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi maya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;welcome to SDN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use two internal tables as itab1 and itab2 and then get the data in these tables basing on itab.and then use loop &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not itab is initial.&lt;/P&gt;&lt;P&gt; SELECT SINGLE KNUMH FROM A506 INTO table itab1&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN ITAB WHERE MATNR = ITAB-MATNR.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC EQ 0.&lt;/P&gt;&lt;P&gt;SELECT SINGLE KBETR FROM KONP INTO ITAB2for all entries in itab1 WHERE KNUMH = itab1-KNUMH.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;read table itab1 with key matnr = itab-matnr.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;move : itab1-kunmh to some variable&lt;/P&gt;&lt;P&gt;read table itab2 with key knumh = itab1-knumh.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;move itab2-kbetr to ....&lt;/P&gt;&lt;P&gt;endif. &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;&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>Mon, 19 Feb 2007 11:55:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969893#M398069</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2007-02-19T11:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969894#M398070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will definetly affect the performance.&lt;/P&gt;&lt;P&gt;First you have to select the complete data into internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_knumh occurs 0,&lt;/P&gt;&lt;P&gt;         matnr type matnr,&lt;/P&gt;&lt;P&gt;         knumh type knumh,&lt;/P&gt;&lt;P&gt;       end of t_knumh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_kbetr2 occurs 0,&lt;/P&gt;&lt;P&gt;              knumh type knumh,&lt;/P&gt;&lt;P&gt;              kbetr2 type kbetr&lt;/P&gt;&lt;P&gt;       end of t_kbetr2.&lt;/P&gt;&lt;P&gt;select matnr knumh from a506 into t_knumh for all entries in itab&lt;/P&gt;&lt;P&gt;where matnr = itab-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select knumh kbetr from konp into t_kbetr2 for all entries in t_knumh&lt;/P&gt;&lt;P&gt;where knumh = t_knumh-knumh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table t_knumh with key matnr = itab-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table t_kbetr2 with key knumh = t_knumh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move t_kbetr2-kbetr2 to itab-kbetr2.&lt;/P&gt;&lt;P&gt;modify itab.&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;endif.&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;Aravind&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:58:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969894#M398070</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969895#M398071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can avoid this looping using the below code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT konp~kbetr INTO CORRESPONDING FIELDS OF table itab FROM konp&lt;/P&gt;&lt;P&gt;inner join A506 ON konp&lt;SUB&gt;knumh = a506&lt;/SUB&gt;knumh&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN itab&lt;/P&gt;&lt;P&gt;WHERE  a506~matnr = itab-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 11:59:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969895#M398071</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T11:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: select inside loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969896#M398072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   A Select Statement inside a Loop definitely affects the performance. Instead try to use the following.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT knumh FROM a506 into table itab_a506 FOR ALL ENTRIES IN itab &lt;/P&gt;&lt;P&gt; WHERE matnr = itab-matnr.&lt;/P&gt;&lt;P&gt;SELECT  KBETR  FROM konp into table itab_konp FOR ALL ENTRIES IN &lt;/P&gt;&lt;P&gt;itab_a506 WHERE  knumh = itab_a506-knumh.&lt;/P&gt;&lt;P&gt;Now read the internal tables and modify the data in itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sowmya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2007 12:01:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-inside-loop/m-p/1969896#M398072</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-19T12:01:12Z</dc:date>
    </item>
  </channel>
</rss>

