<?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: avoiding select in  loop....endloop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477448#M1060256</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do one think, first fetch all the data into internal tables and then process the required data.&lt;/P&gt;&lt;P&gt;Hitting the data base once is better than hitting several times.&lt;/P&gt;&lt;P&gt; First select all the required data from the database, then process the data using READ or LOOP statement inside the LOOP statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Sep 2008 04:21:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-05T04:21:21Z</dc:date>
    <item>
      <title>avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477443#M1060251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;select MARA~matnr&lt;/P&gt;&lt;P&gt;        MAKTX&lt;/P&gt;&lt;P&gt;from mara join marc on mara&lt;SUB&gt;matnr = marc&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;          JOIN makt on mara&lt;SUB&gt;matnr = makt&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;where mtart = 'FERT' AND&lt;/P&gt;&lt;P&gt;WERKS  = P_PLANT .&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;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; CALCULATING PENDING ORDERS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;select SUM( EKET~MENGE )&lt;/P&gt;&lt;P&gt;       SUM( EKET~GLMNG )&lt;/P&gt;&lt;P&gt;INTO (ITAB-MENGE ,ITAB-GLMNG )&lt;/P&gt;&lt;P&gt;       from&lt;/P&gt;&lt;P&gt;	EKKO JOIN EKPO ON EKPO&lt;SUB&gt;EBELN = EKKO&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;            JOIN EKET ON EKKO&lt;SUB&gt;EBELN = EKET&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;EKET~EINDT LE ZFDATE and&lt;/P&gt;&lt;P&gt;EKET~EINDT GE P_DATE AND&lt;/P&gt;&lt;P&gt;EKPO~MATNR = ITAB-MATNR and&lt;/P&gt;&lt;P&gt;EKPO~WERKS = P_PLANT and&lt;/P&gt;&lt;P&gt;EKKO~BSART = 'UB' .&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;*******************************************&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt; UNIT CONVERSION OF  PENDING ORDERS        added by k srinivas&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;select SINGLE EKPO~MEINS              "ORDER UNIT&lt;/P&gt;&lt;P&gt;             EKPO~UMREZ              "1 PACK = 'UMREZ' LITRES&lt;/P&gt;&lt;P&gt;              EKPO~LMEIN               "BASE UNIT OF MEASURE&lt;/P&gt;&lt;P&gt;INTO (V_ORDER_UNIT,V_CONVERSION,V_BASE_UNIT)&lt;/P&gt;&lt;P&gt;       from&lt;/P&gt;&lt;P&gt;	EKKO JOIN EKPO ON EKPO&lt;SUB&gt;EBELN = EKKO&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;            JOIN EKET ON EKKO&lt;SUB&gt;EBELN = EKET&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;EKET~EINDT LE ZFDATE and&lt;/P&gt;&lt;P&gt;EKET~EINDT GE P_DATE AND&lt;/P&gt;&lt;P&gt;EKPO~MATNR = ITAB-MATNR and&lt;/P&gt;&lt;P&gt;EKPO~WERKS = P_PLANT and&lt;/P&gt;&lt;P&gt;EKKO~BSART = 'UB' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*CONVERSION OF QUANTITY INTO LITRES&lt;/P&gt;&lt;P&gt;IF V_ORDER_UNIT = 'PAK' AND V_BASE_UNIT = 'L'.&lt;/P&gt;&lt;P&gt;ITAB-MENGE = ITAB-MENGE  * V_CONVERSION.&lt;/P&gt;&lt;P&gt;ITAB-GLMNG  = ITAB-GLMNG  * V_CONVERSION.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ITAB-MENGE &amp;gt; ITAB-GLMNG .&lt;/P&gt;&lt;P&gt;ITAB-PENDO = ITAB-MENGE - ITAB-GLMNG.&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;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;Because of the 'Select' statement inside the loop im getting &lt;/P&gt;&lt;P&gt;Performance issue and going to dump.&lt;/P&gt;&lt;P&gt;Please suggest how to bring the Select statement outside the loop and still get the same output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;K Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 05:42:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477443#M1060251</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T05:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477444#M1060252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use for all entries instead of select statement in loop and get the values from the second and third select statement to other internal tables and loop the first internal table in the loop read the second and third internal table update your first internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naresh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 07:13:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477444#M1060252</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T07:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477445#M1060253</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;You need not to SUM while retriving the data from the database.That makes the database server more burden.So Delete select statement with SUM.(Instead use AT END of fileds SUM.).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And coming to One more select,in the LOOP eliminate it by using READ statement and writing the select outside the loop with for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  begin of itab2 occurs 0 with header line.&lt;/P&gt;&lt;P&gt;  meins  like ekpo-meins,&lt;/P&gt;&lt;P&gt;  umrez llike  ekpo-umrez,&lt;/P&gt;&lt;P&gt; lmein  like ekpo~lmein ,&lt;/P&gt;&lt;P&gt;eindt type d,&lt;/P&gt;&lt;P&gt; end of itab2.&lt;/P&gt;&lt;P&gt;SELECT  ekpo~meins "ORDER UNIT&lt;/P&gt;&lt;P&gt;    ekpo~umrez "1 PACK = 'UMREZ' LITRES&lt;/P&gt;&lt;P&gt;    ekpo~lmein "BASE UNIT OF MEASURE&lt;/P&gt;&lt;P&gt;    INTO table itab2&lt;/P&gt;&lt;P&gt;    FROM&lt;/P&gt;&lt;P&gt;    ekko JOIN ekpo ON ekpo&lt;SUB&gt;ebeln = ekko&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;    JOIN eket ON ekko&lt;SUB&gt;ebeln = eket&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;    WHERE&lt;/P&gt;&lt;P&gt;    eket~eindt LE zfdate AND&lt;/P&gt;&lt;P&gt;    eket~eindt GE p_date AND&lt;/P&gt;&lt;P&gt;    ekpo~matnr = itab-matnr AND&lt;/P&gt;&lt;P&gt;    ekpo~werks = p_plant AND&lt;/P&gt;&lt;P&gt;    ekko~bsart = 'UB' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;read itab2 with key eindt between p_date and zfdate.&lt;/P&gt;&lt;P&gt;if sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; *do you action here&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;Rama.P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 09:12:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477445#M1060253</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T09:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477446#M1060254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using of joins inside or outside the loop can largely affect the performance of a program, So always prefer selecting data from each table,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First select from the header table based on the condition as per your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then by using ' for all entries' clause, fetch from the other tables relating to that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) select MARA~matnr&lt;/P&gt;&lt;P&gt;MAKTX&lt;/P&gt;&lt;P&gt;from mara join marc on mara&lt;SUB&gt;matnr = marc&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;JOIN makt on mara&lt;SUB&gt;matnr = makt&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;where mtart = 'FERT' AND&lt;/P&gt;&lt;P&gt;WERKS = P_PLANT .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This select query can be replaced by doing the following,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT MATNR&lt;/P&gt;&lt;P&gt;  FROM MARA INTO TABLE T_MARA&lt;/P&gt;&lt;P&gt;  WHERE MTART EQ FERT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort t_mara by matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not t_mara is initial.&lt;/P&gt;&lt;P&gt;SELECT MATNR&lt;/P&gt;&lt;P&gt;       WERKS&lt;/P&gt;&lt;P&gt;  FROM MARC&lt;/P&gt;&lt;P&gt;  INTO TABLE T_MARC&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN T_MARA&lt;/P&gt;&lt;P&gt;  WHERE MATNR EQ T_MARA-MATNR&lt;/P&gt;&lt;P&gt;  AND   WERKS EQ P_PLANT.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;sort t_marc by matnr werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not t_marc is initial.&lt;/P&gt;&lt;P&gt;SELECT MATNR&lt;/P&gt;&lt;P&gt;       SPRAS&lt;/P&gt;&lt;P&gt;       MAKTX&lt;/P&gt;&lt;P&gt;       FROM MAKT&lt;/P&gt;&lt;P&gt;  INTO TABLE T_MAKT&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN T_MARC&lt;/P&gt;&lt;P&gt;  WHERE MATNR EQ T_MARC-MATNR.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT T_MAKT INTO WA_MAKT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE T_MARA INTO WA_MARA WITH KEY  MATNR = WA_MAKT-MATNR.&lt;/P&gt;&lt;P&gt;  WA_ITAB-MAKTX = WA_MAKT-MAKTX.&lt;/P&gt;&lt;P&gt;  WA_ITAB-MATNR = WA_MARA-MATNR.&lt;/P&gt;&lt;P&gt;  APPEND WA_ITAB TO T_ITAB.&lt;/P&gt;&lt;P&gt;  CLEAR: WA_ITAB,&lt;/P&gt;&lt;P&gt;  WA_MAKT,&lt;/P&gt;&lt;P&gt;  WA_MARA.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in this query from mara, we are giving the primary key in the where condition, so its better you can have the material number in the selection screen or you can create a index on the mtart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) select SUM( EKET~MENGE )&lt;/P&gt;&lt;P&gt;SUM( EKET~GLMNG )&lt;/P&gt;&lt;P&gt;INTO (ITAB-MENGE ,ITAB-GLMNG )&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;EKKO JOIN EKPO ON EKPO&lt;SUB&gt;EBELN = EKKO&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;JOIN EKET ON EKKO&lt;SUB&gt;EBELN = EKET&lt;/SUB&gt;EBELN&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;EKET~EINDT LE ZFDATE and&lt;/P&gt;&lt;P&gt;EKET~EINDT GE P_DATE AND&lt;/P&gt;&lt;P&gt;EKPO~MATNR = ITAB-MATNR and&lt;/P&gt;&lt;P&gt;EKPO~WERKS = P_PLANT and&lt;/P&gt;&lt;P&gt;EKKO~BSART = 'UB' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT EBELN&lt;/P&gt;&lt;P&gt;       BSART&lt;/P&gt;&lt;P&gt;FROM EKKO&lt;/P&gt;&lt;P&gt;INTO TABLE T_EKKO&lt;/P&gt;&lt;P&gt;WHERE BSART EQ 'UB'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT EBELN&lt;/P&gt;&lt;P&gt;       EBELP&lt;/P&gt;&lt;P&gt;       MATNR&lt;/P&gt;&lt;P&gt;       WERKS&lt;/P&gt;&lt;P&gt;FROM EKPO&lt;/P&gt;&lt;P&gt;INTO TABLE T_EKPO1&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN T_ITAB&lt;/P&gt;&lt;P&gt;WHERE MATNR = T_ITAB-MATNR&lt;/P&gt;&lt;P&gt;AND   WERKS = P_PLANT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT T_EKPO1 INTO WA_EKPO1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE T_EKKO INTO WA_EKKO WITH KEY EBELN = WA_EKPO1-EBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC EQ 0.&lt;/P&gt;&lt;P&gt;    APPEND WA_EKPO1 TO T_EKPO2.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR: WA_EKPO1,&lt;/P&gt;&lt;P&gt;         WA_ITAB,&lt;/P&gt;&lt;P&gt;         WA_EKKO.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT EBELN&lt;/P&gt;&lt;P&gt;       EBELP&lt;/P&gt;&lt;P&gt;       ETENR&lt;/P&gt;&lt;P&gt;       EINDT&lt;/P&gt;&lt;P&gt;       MENGE&lt;/P&gt;&lt;P&gt;       GLMNG&lt;/P&gt;&lt;P&gt;FROM EKET&lt;/P&gt;&lt;P&gt;INTO TABLE T_EKET&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN T_EKPO2&lt;/P&gt;&lt;P&gt;WHERE EBELN = T_EKPO2-EBELN&lt;/P&gt;&lt;P&gt;AND   EINDT LE '01.01.9999' "ZFDATE&lt;/P&gt;&lt;P&gt;AND   EINDT GE '01.01.2000'. "P_DATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT T_ITAB INTO WA_ITAB .&lt;/P&gt;&lt;P&gt;  READ TABLE T_EKPO2 INTO WA_EKPO1 WITH KEY MATNR = WA_ITAB-MATNR&lt;/P&gt;&lt;P&gt;                                           WERKS = P_PLANT.&lt;/P&gt;&lt;P&gt;  "WA_ITAB-WERKS.&lt;/P&gt;&lt;P&gt;  LOOP AT T_EKET INTO WA_EKET WHERE EBELN = WA_EKPO1-EBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    GV_MENGE = GV_MENGE + WA_EKET-MENGE.&lt;/P&gt;&lt;P&gt;    GV_GLMNG = GV_GLMNG + WA_EKET-GLMNG.&lt;/P&gt;&lt;P&gt;    AT END OF EBELN.&lt;/P&gt;&lt;P&gt;      WA_ITAB-MENGE = GV_MENGE.&lt;/P&gt;&lt;P&gt;      WA_ITAB-GLMNG = GV_GLMNG.&lt;/P&gt;&lt;P&gt;      CLEAR: GV_GLMNG,&lt;/P&gt;&lt;P&gt;      GV_MENGE.&lt;/P&gt;&lt;P&gt;    ENDAT.&lt;/P&gt;&lt;P&gt;    CLEAR: WA_EKET.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  CLEAR: WA_ITAB,&lt;/P&gt;&lt;P&gt;  WA_EKPO1.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please follow the same methodology for the other query also.&lt;/P&gt;&lt;P&gt;Hope this code should help you to get the problem resolved&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Shobana k on Sep 4, 2008 12:59 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 10:58:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477446#M1060254</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T10:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477447#M1060255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As others said using inner join  in the program code is time consuming. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So u can go for FOR ALL ENTRIES. or if required create a views, because it handle the data in external buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;retrieve only those fields required for further processing, and specify maximum fields in the WHERE condition to reduces the number of records retrieved from the database level. also as you specified u can use aggreagte function for the fields required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;GP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 04:14:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477447#M1060255</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T04:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477448#M1060256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do one think, first fetch all the data into internal tables and then process the required data.&lt;/P&gt;&lt;P&gt;Hitting the data base once is better than hitting several times.&lt;/P&gt;&lt;P&gt; First select all the required data from the database, then process the data using READ or LOOP statement inside the LOOP statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2008 04:21:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477448#M1060256</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-05T04:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477449#M1060257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Srinivas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first fetch the data for mara based on WERKS and MTART&lt;/P&gt;&lt;P&gt;then use for all entries to fetch data from MAKT,&lt;/P&gt;&lt;P&gt;after that use for all entries to fetch data from EKKO &amp;amp; EKPO respectively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now run a loop on EKPO internal tables.&lt;/P&gt;&lt;P&gt;inside that loop read all the tables one by one and populate the data.&lt;/P&gt;&lt;P&gt;you can also calculate all the values in the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the end of loop modify the internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i hope this will work well for you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rajnesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2008 12:57:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477449#M1060257</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-09T12:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: avoiding select in  loop....endloop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477450#M1060258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;answered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Feb 2011 06:30:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoiding-select-in-loop-endloop/m-p/4477450#M1060258</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-02-18T06:30:27Z</dc:date>
    </item>
  </channel>
</rss>

