<?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 from Internal Table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010894#M1496632</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bernhard,&lt;/P&gt;&lt;P&gt;you have a problem with your select statement..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1st error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;INTO CORRESPONDING FIELDS OF itab "here it should be FIELDS OF TABLE itab&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2nd error.&lt;/P&gt;&lt;P&gt;your selecting logic is not correct.. dont you think so.. please check the below sample&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select x y z from table a into corr fields of table itab_A where .... "=&amp;gt;here we are fetching to itab_a
if sy-subrc =0."=&amp;gt;records found.
  select d e f from table b into corr fields of table itab_B 
                     FOR ALL ENTRIES in itab_A "==&amp;gt;using the entries in A
                     WHERE x = itab_A-x. "etc etc
" now loop.
   loop at itab_B into is_b.
     sum = sum + is_b-d.
   endloop.
 endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use this sample logic in your code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jun 2010 01:45:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-16T01:45:38Z</dc:date>
    <item>
      <title>Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010892#M1496630</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 have this littel code and for the moment i get a littel problem with this internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use this code in an infoset. Thats why not all tables are showen here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: VBEP,
                VBUP.
DATA:   zamount like vbep-bmeng.
DATA:    BEGIN OF i_tab,
           besta   like vbup-besta,
           vbeln   like vbak-vbeln,
           posnr   like vbap-posnr,
           bmeng   like vbep-bmeng,
           etenr   like vbep-etenr,
         END OF i_tab.
DATA: itab LIKE STANDARD TABLE OF i_tab WITH HEADER LINE.

CLEAR itab.
SELECT besta vbeln posnr INTO CORRESPONDING FIELDS OF itab FROM  vbup
       WHERE  VBELN  = vbak-vbeln
       AND    POSNR  = vbap-posnr
       AND    BESTA  &amp;lt;&amp;gt; 'C'.
ENDSELECT.
SELECT bmeng etenr INTO CORRESPONDING FIELDS OF itab FROM vbep
      WHERE VBELN =  itab-vbeln
      AND   POSNR =  itab-posnr.
ENDSELECT.
clear zamount.
LOOP AT itab INTO i_tab.
   zamount = i_tab-bmeng + zamount.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i debug this i can see the right values in the itab table. But at the LOOP the value from the table is not &lt;/P&gt;&lt;P&gt;assign to "zamount".&lt;/P&gt;&lt;P&gt;Where is my error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;kind regards,&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jun 2010 22:47:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010892#M1496630</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-15T22:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010893#M1496631</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 selects are wrong. You select line and store it into header of the table itab. So you first select select one line but it does not insert into table itab. The second select overwrites values in the header table but again it does not insert any row into table itab. After that you do loop over empty table so obviously you don't get any values. Don't use tables with header lines if you don't have to. It's obsolete and as you can see it's confusing.  I would suggest to chan ge it to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA line LIKE i_tab.

SELECT SINGLE besta vbeln posnr INTO CORRESPONDING FIELDS OF line FROM  vbup
       WHERE  VBELN  = vbak-vbeln
       AND    POSNR  = vbap-posnr
       AND    BESTA   'C'.
IF sy-subrc EQ 0.
  APPEND line TO itab.
ENDIF.

CLEAR line.
SELECT SINGLE bmeng etenr INTO CORRESPONDING FIELDS OF line FROM vbep
      WHERE VBELN =  itab-vbeln
      AND   POSNR =  itab-posnr.
IF sy-subrc EQ 0.
  APPEND line TO itab.
ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 00:58:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010893#M1496631</guid>
      <dc:creator>mvoros</dc:creator>
      <dc:date>2010-06-16T00:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010894#M1496632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bernhard,&lt;/P&gt;&lt;P&gt;you have a problem with your select statement..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1st error:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;INTO CORRESPONDING FIELDS OF itab "here it should be FIELDS OF TABLE itab&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2nd error.&lt;/P&gt;&lt;P&gt;your selecting logic is not correct.. dont you think so.. please check the below sample&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select x y z from table a into corr fields of table itab_A where .... "=&amp;gt;here we are fetching to itab_a
if sy-subrc =0."=&amp;gt;records found.
  select d e f from table b into corr fields of table itab_B 
                     FOR ALL ENTRIES in itab_A "==&amp;gt;using the entries in A
                     WHERE x = itab_A-x. "etc etc
" now loop.
   loop at itab_B into is_b.
     sum = sum + is_b-d.
   endloop.
 endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use this sample logic in your code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 01:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010894#M1496632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-16T01:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010895#M1496633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i changed my code to this. If i execute the Query i get the right result. But if i debug it i saw that i now get two lines in ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What must i do that i onyl get one line out of my selection in ITAB?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: VBEP,
        VBUP.
DATA:   zamount like vbep-bmeng.
TYPES:    BEGIN OF i_tab,
           besta   like vbup-besta,
           vbeln   like vbak-vbeln,
           posnr   like vbap-posnr,
           bmeng   like vbep-bmeng,
           etenr   like vbep-etenr,
         END OF i_tab.

DATA: itab TYPE TABLE OF i_tab,
      line LIKE LINE OF itab,
      wa Type i_tab.

SELECT besta vbeln posnr FROM  vbup INTO CORRESPONDING FIELDS OF line
       WHERE  VBELN  = vbak-vbeln
       AND    POSNR  = vbap-posnr
       AND    BESTA  &amp;lt;&amp;gt; 'C'.
IF sy-subrc EQ 0.
  APPEND line TO itab.
ENDIF.
ENDSELECT.

CLEAR line.
IF sy-subrc EQ 0.
SELECT bmeng etenr FROM vbep INTO CORRESPONDING FIELDS OF line
      FOR ALL ENTRIES in itab
      WHERE VBELN =  itab-vbeln
      AND   POSNR =  itab-posnr.
IF sy-subrc EQ 0.
  APPEND line TO itab.
ENDIF.
ENDSELECT.
ENDIF.

clear zamount.
LOOP AT itab into wa.
   zamount = wa-bmeng + zamount.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for you help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;kind regards,&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 08:58:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010895#M1496633</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-16T08:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010896#M1496634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get rid of the endselects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
try this

TABLES: VBEP,
        VBUP.
DATA:   zamount like vbep-bmeng.
data:in type i.
TYPES:    BEGIN OF i_tab,
           besta   like vbup-besta,
           vbeln   like vbak-vbeln,
           posnr   like vbap-posnr,
           bmeng   like vbep-bmeng,
           etenr   like vbep-etenr,
         END OF i_tab.

TYPES:    BEGIN OF i_tab1,
           vbeln   like vbak-vbeln,
           posnr   like vbap-posnr,
           bmeng   like vbep-bmeng,
           etenr   like vbep-etenr,
         END OF i_tab1.
 
DATA: itab TYPE TABLE OF i_tab,
      itab1 type table of i_tab1,
      line2 type i_tab1.

field-symbols:&amp;lt;fs&amp;gt; type i_tab.
 
SELECT besta vbeln posnr FROM  vbup INTO table itab
       WHERE  VBELN  = vbak-vbeln
       AND    POSNR  = vbap-posnr
       AND    BESTA   'C'.
 
IF sy-subrc EQ 0.
sort itab by vbeln posnr.
SELECT vbeln posnr sum( bmeng ) etenr FROM vbep INTO table i_itab1
      FOR ALL ENTRIES in itab
      WHERE VBELN =  itab-vbeln
      AND   POSNR =  itab-posnr
      group by vbeln posnr etenr.
if sy-subrc = 0.
sort i_itab1 by vbeln posnr.
endif.
ENDIF.
 

LOOP AT itab assigning &amp;lt;fs&amp;gt;.
read table i_itab1 into line2 with key vebln = line-vbeln
			    posnr = line-posnr
			    binary serach.
if sy-subrc = 0.
&amp;lt;fs&amp;gt;-bmeng = line2-bmeng.
endif.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 09:33:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010896#M1496634</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-06-16T09:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010897#M1496635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Put a break point  at loop at itab into wa.&lt;/P&gt;&lt;P&gt;and there put one f5 and see , whter value is coming to wa.&lt;/P&gt;&lt;P&gt;if it is coming then chk wht is the value for the field u need of wa.&lt;/P&gt;&lt;P&gt;then u can do the addition .&lt;/P&gt;&lt;P&gt;and after adding cklear wa also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 09:33:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010897#M1496635</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-16T09:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010898#M1496636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use Zamount = zamount  + itab-&amp;lt;fieldname&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jun 2010 09:49:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010898#M1496636</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-16T09:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Read from Internal Table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010899#M1496637</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 the collect &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Raul Natu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Raul Natu on Jun 18, 2010 11:46 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jun 2010 09:43:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-from-internal-table/m-p/7010899#M1496637</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-18T09:43:43Z</dc:date>
    </item>
  </channel>
</rss>

