<?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: for all in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336341#M514430</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check before  using For all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The table which is used for all entries should not be empty. If  it is empty then query pick all the record( which is wrong selection).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Ensure the key fields are included in select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Ensure the order fields used in select query. It should be in the order as in the table order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Ensure the Where condition given in the for all entries are also in the correct order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example for 'FOR ALL ENTRIES :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider table  t_vbak:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbeln     audat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001     12.05.07&lt;/P&gt;&lt;P&gt;0002     12.05.07&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if  u use t_vbak in for all entries :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln posnr from vbap into t_vbap&lt;/P&gt;&lt;P&gt;for all entries in t_vbap&lt;/P&gt;&lt;P&gt;where vbeln = t_vbak-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the resullt will be :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbeln posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001   x&lt;/P&gt;&lt;P&gt;0001   y&lt;/P&gt;&lt;P&gt;0001   z&lt;/P&gt;&lt;P&gt;0002  x&lt;/P&gt;&lt;P&gt;0002   y&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it will select the posnr only for 0001 and 0002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2007 14:01:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-18T14:01:42Z</dc:date>
    <item>
      <title>for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336336#M514425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi experts,&lt;/P&gt;&lt;P&gt;how can we design and use select for all entries.how can it work .explaine me brief.&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 13:54:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336336#M514425</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T13:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336337#M514426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Surendra,&lt;/P&gt;&lt;P&gt;For All Entries,&lt;/P&gt;&lt;P&gt;DBTAB1 &amp;lt;----&lt;/P&gt;&lt;HR originaltext="-------" /&gt;&lt;P&gt;&amp;gt; ITAB1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is not at all related to two DATABASE tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is related to INTERNAL table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If we want to fetch data &lt;/P&gt;&lt;P&gt;from some DBTABLE1&lt;/P&gt;&lt;P&gt;but we want to fetch&lt;/P&gt;&lt;P&gt;for only some records&lt;/P&gt;&lt;P&gt;which are contained in some internal table,&lt;/P&gt;&lt;P&gt;then we use for alll entries.&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;HR originaltext="-----------------" /&gt;&lt;P&gt;1. simple example of for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. NOTE THAT &lt;/P&gt;&lt;P&gt;In for all entries,&lt;/P&gt;&lt;P&gt;it is NOT necessary to use TWO DBTABLES.&lt;/P&gt;&lt;P&gt;(as against JOIN)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. use this program (just copy paste)&lt;/P&gt;&lt;P&gt;it will fetch data&lt;/P&gt;&lt;P&gt;from T001&lt;/P&gt;&lt;P&gt;FOR ONLY TWO COMPANIES (as mentioned in itab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.&lt;/P&gt;&lt;P&gt;You can check the below code -&lt;/P&gt;&lt;P&gt;SELECT BUKRS BELNR GJAHR AUGDT&lt;/P&gt;&lt;P&gt;FROM BSEG&lt;/P&gt;&lt;P&gt;INTO TABLE I_BSEG&lt;/P&gt;&lt;P&gt;WHERE BUKRS = ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BUKRS BELNR BLART BLDAT&lt;/P&gt;&lt;P&gt;FROM BKPF&lt;/P&gt;&lt;P&gt;INTO TABLE I_BKPF&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN I_BSEG&lt;/P&gt;&lt;P&gt;WHERE BUKRS = I_BSEG-BUKRS&lt;/P&gt;&lt;P&gt;AND BELNR = I_BSEG-BELNR&lt;/P&gt;&lt;P&gt;AND BLDAT IN SO_BLDAT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you understand the usage specified.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sapna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 13:56:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336337#M514426</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T13:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336338#M514427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Surendra,&lt;/P&gt;&lt;P&gt;    We use for all entries when there is a requirement to fetch values from databse table for the entries present in a internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main condition for "For all entries" is that the internal table using which data is selected should not be empty, otherwise it will select all the data from the database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;award forum points to helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 13:57:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336338#M514427</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T13:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336339#M514428</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;PRE&gt;&lt;CODE&gt;
... FOR ALL ENTRIES IN itab WHERE cond 


Effect 
Only selects the records that meet the logical condition cond when each replacement symbol itab-f is replaced with the value of component f of the internal table itab for at least one line of the table. SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result set. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records. 


Example 
Displaying the occupancy of flights on 28.02.1995: 


TYPES: BEGIN OF FTAB_TYPE, 
         CARRID LIKE SFLIGHT-CARRID, 
         CONNID LIKE SFLIGHT-CONNID, 
       END OF FTAB_TYPE. 

DATA:  FTAB TYPE STANDARD TABLE OF FTAB_TYPE WITH 
                 NON-UNIQUE DEFAULT KEY INITIAL SIZE 10, 
       RATIO TYPE P DECIMALS 3, 
       WA_SFLIGHT TYPE SFLIGHT. 

* Suppost FTAB is filled as follows: 
* 
* CARRID  CONNID 
* -------------- 
* LH      2415 
* SQ      0026 
* LH      0400 

SELECT * FROM SFLIGHT INTO WA_SFLIGHT 
    FOR ALL ENTRIES IN FTAB 
    WHERE CARRID = FTAB-CARRID AND 
          CONNID = FTAB-CONNID AND 
          FLDATE = '19950228'. 
  RATIO = WA_SFLIGHT-SEATSOCC / WA_SFLIGHT-SEATSMAX. 
  WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID, RATIO. 
ENDSELECT. 

* The statement has the same effect as: 

SELECT DISTINCT * FROM SFLIGHT INTO WA_SFLIGHT 
    WHERE ( CARRID = 'LH'   AND 
            CONNID = '2415' AND 
            FLDATE = '19950228' ) OR 
          ( CARRID = 'SQ'   AND 
            CONNID = '0026' AND 
            FLDATE = '19950228' ) OR 
          ( CARRID = 'LH'   AND 
            CONNID = '0400' AND 
            FLDATE = '19950228' ). 
  RATIO = WA_SFLIGHT-SEATSOCC / WA_SFLIGHT-SEATSMAX. 
  WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID, RATIO. 
ENDSELECT. 


Notes 
You can only use ... FOR ALL ENTRIES IN itab WHERE cond in a SELECT statement. 



In the logical condition cond, the symbol itab-f is always a replacement symbol, and should not be confused with the component f of the header line of the internal table itab. The internaln table itab does not have to have a header line. 



The line structure of the internal table iab must be a structure. Each component of the structure that appears in the WHERE condition as a replacement symbol must have exactly the same type and length as the corresponding component of the table work area (see TABLES). 



You cannot use replacement symbols in comparisons in LIKE, BETWEEN, or IN expressions. 



If you use FOR ALL ENTRIES IN itab, you cannot use ORDER BY f1 ... fn in the ORDER-BY clause. 



You cannot use the internal table itab in the INTO clause as well. 


Notes 
Performance: 



Specify all conditions in the WHERE clause. This means that you do not transport redundant data over the network only to filter it out in your program (using CHECK, for example). 


If you regularly use a SELECT statement, you should create an index. In the WHERE clause, you should use the fields of the index, linked using AND, and checking for equality. Fields of an index that occur after a field for which you do not use an equality comparison in the WHERE clause (EQ or =) cannot be used to restrict the search. 


The logical expression NOT in a WHERE clause is not supported by indexes. For example, WHERE FLDATE &amp;gt;= '19950228' is better than WHERE NOT FLDATE &amp;lt; '19950228'. 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If useful reward.&lt;/P&gt;&lt;P&gt;Vasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 13:58:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336339#M514428</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T13:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336340#M514429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For all entries is a substitute for a select statement with in a loop.&lt;/P&gt;&lt;P&gt;It fetches data from a table for a set values for a particular field in the table.&lt;/P&gt;&lt;P&gt;ITAB contains the Sales Order Nos.&lt;/P&gt;&lt;P&gt;You need to get the QTY, PRICE for all the sales orders for its items&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select &amp;lt;SONum&amp;gt; &amp;lt;SOItem&amp;gt; &amp;lt;QTY&amp;gt; &amp;lt;PRICE&amp;gt; from VBAP&lt;/P&gt;&lt;P&gt;for all entries in ITAB&lt;/P&gt;&lt;P&gt;where VBELN = ITAB-VBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at ITAB.&lt;/P&gt;&lt;P&gt;select &amp;lt;SONum&amp;gt; &amp;lt;SOItem&amp;gt; &amp;lt;QTY&amp;gt; &amp;lt;PRICE&amp;gt; from VBAP&lt;/P&gt;&lt;P&gt;where VBELN = ITAB-VBELN.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the above statement does the same but peformance wise we prefer FOR ALL ENTRIES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 14:01:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336340#M514429</guid>
      <dc:creator>gopi_narendra</dc:creator>
      <dc:date>2007-06-18T14:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336341#M514430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check before  using For all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The table which is used for all entries should not be empty. If  it is empty then query pick all the record( which is wrong selection).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Ensure the key fields are included in select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Ensure the order fields used in select query. It should be in the order as in the table order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Ensure the Where condition given in the for all entries are also in the correct order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example for 'FOR ALL ENTRIES :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider table  t_vbak:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbeln     audat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001     12.05.07&lt;/P&gt;&lt;P&gt;0002     12.05.07&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if  u use t_vbak in for all entries :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln posnr from vbap into t_vbap&lt;/P&gt;&lt;P&gt;for all entries in t_vbap&lt;/P&gt;&lt;P&gt;where vbeln = t_vbak-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the resullt will be :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbeln posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0001   x&lt;/P&gt;&lt;P&gt;0001   y&lt;/P&gt;&lt;P&gt;0001   z&lt;/P&gt;&lt;P&gt;0002  x&lt;/P&gt;&lt;P&gt;0002   y&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it will select the posnr only for 0001 and 0002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 14:01:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336341#M514430</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T14:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: for all</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336342#M514431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;For all entries is used in order to avoid a select inside a loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose you want to select some values from a database table depending upon some valiues in an internal table.One way to do so is to use a select in a loop.&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select.....where &amp;lt;f1&amp;gt; = itab1-f2.&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;But to avoid this and have better performance we must first select in an internal table values for all entries in the first internal table&amp;lt;itab1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select ......into &amp;lt;itab2&amp;gt; for all entries in itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then in the loop read the table itab2 depending on value of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab2 where &amp;lt;f1&amp;gt; = itab2-f2.&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;Hope it is useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sandeep.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2007 14:04:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/for-all/m-p/2336342#M514431</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-18T14:04:36Z</dc:date>
    </item>
  </channel>
</rss>

