<?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 sy-index / sy-tabix wrong within loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194983#M468357</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i do a loop over a a table and am writing out the field contents like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.

        do.

      assign component sy-index
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
        if sy-subrc &amp;lt;&amp;gt; 0.
         EXIT.
        else.
* Here it gets the name of the field based on the sy-index of the component

        READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
      endif.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What now doesnt work is, that whenever i have the read statement uncommented the loop doesnt increment so i only get the first row but that n-times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any idea where the error is  ?&lt;/P&gt;&lt;P&gt;thank you! i am awarding points generously &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Apr 2007 08:30:06 GMT</pubDate>
    <dc:creator>former_member5350</dc:creator>
    <dc:date>2007-04-24T08:30:06Z</dc:date>
    <item>
      <title>sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194983#M468357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i do a loop over a a table and am writing out the field contents like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.

        do.

      assign component sy-index
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
        if sy-subrc &amp;lt;&amp;gt; 0.
         EXIT.
        else.
* Here it gets the name of the field based on the sy-index of the component

        READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.
      endif.

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What now doesnt work is, that whenever i have the read statement uncommented the loop doesnt increment so i only get the first row but that n-times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any idea where the error is  ?&lt;/P&gt;&lt;P&gt;thank you! i am awarding points generously &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:30:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194983#M468357</guid>
      <dc:creator>former_member5350</dc:creator>
      <dc:date>2007-04-24T08:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194984#M468358</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 the DO&lt;/P&gt;&lt;P&gt;ENDDO is missing.&lt;/P&gt;&lt;P&gt;Write it and see&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        do.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      assign component sy-index&lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;        if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;         EXIT.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here it gets the name of the field based on the sy-index of the component&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    ENDDO.&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;reward if useful&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;ANJI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:33:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194984#M468358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194985#M468359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is ur  loop statement correct??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i am not wrong shouldnt it be like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP AT &amp;lt;dyn_table&amp;gt; ASSIGNING &amp;lt;dyn_wa&amp;gt;.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:34:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194985#M468359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194986#M468360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to use SY-TABIX in LOOPS...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in DO etc you have to use SY-INDEX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's the only problem....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tabix as you are looping at an INTERNAL TABLE data...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:34:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194986#M468360</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194987#M468361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;    &amp;lt;b&amp;gt;lv_index = sy-tabix.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;        do.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      assign component sy-index&lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;        if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;         EXIT.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here it gets the name of the field based on the sy-index of the component&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        READ TABLE l_tab_fields INTO w_tab_fields INDEX&amp;lt;b&amp;gt; lv_index.&amp;lt;/b&amp;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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:35:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194987#M468361</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194988#M468362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, thank you for your immediate help. i debugged it once more and here is what i found:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="281226"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem was that with the read statement inside the loop, the sy-tabix that is used by the loop itself was overwritten with the new value ( and that is 1 every time).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:39:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194988#M468362</guid>
      <dc:creator>former_member5350</dc:creator>
      <dc:date>2007-04-24T08:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194989#M468363</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;Your code seems to be right, if LOOP doesn't increment the index it means there's only one record (?): let's know how many and which records are in DYN_TABLE and l_tab_fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway you should use a variable to store the index of the first table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: TABIX TYPE SY-TABIX.

LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.
    
   TABIX = SY-TABIX.

   DO.
     assign component sy-index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
     if sy-subrc &amp;lt;&amp;gt; 0.
       EXIT.
     else.
* Here it gets the name of the field based on the sy-index of the component
        READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.

*---&amp;gt; Here if sy-subrc = 0, the SY-TABIX is equal to SY-INDEX.
      endif.
   ENDDO.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:39:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194989#M468363</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: sy-index / sy-tabix wrong within loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194990#M468364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        do.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      assign component sy-index&lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;        if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;         EXIT.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here it gets the name of the field based on the sy-index of the component&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        READ TABLE l_tab_fields INTO w_tab_fields INDEX sy-index.&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; &lt;/P&gt;&lt;P&gt;If i gt you rite..i would suggest this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data: l_tabix type sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;dyn_table&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  l_tabix - sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;      assign component l_tabix&lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;        if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;         EXIT.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here it gets the name of the field based on the sy-index of the component&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;        READ TABLE l_tab_fields INTO w_tab_fields INDEX l_tabix.&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;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:40:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sy-index-sy-tabix-wrong-within-loop/m-p/2194990#M468364</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-24T08:40:33Z</dc:date>
    </item>
  </channel>
</rss>

