<?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: Splittin table by values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204444#M131742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Declare sub internal tables with same structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg - ITAB is main internal table. IT1, IT2, IT3, IT4  are sub internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'X'.&lt;/P&gt;&lt;P&gt;    IT1 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT1.&lt;/P&gt;&lt;P&gt;    CLEAR IT1.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'Y'.&lt;/P&gt;&lt;P&gt;    IT2 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT2.&lt;/P&gt;&lt;P&gt;    CLEAR IT2.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'Z'.&lt;/P&gt;&lt;P&gt;    IT3 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT3.&lt;/P&gt;&lt;P&gt;    CLEAR IT3.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'W'.&lt;/P&gt;&lt;P&gt;    IT4 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT4.&lt;/P&gt;&lt;P&gt;    CLEAR IT4.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Mar 2006 15:19:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-03-23T15:19:54Z</dc:date>
    <item>
      <title>Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204442#M131740</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;I have a short question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the best way to split a table into sub-tables of the same structure where each sub-tables has the same value for an element X. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;I forgot to mention:&lt;/P&gt;&lt;P&gt;the amount of values for element X vary and are unknown beforehand!&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your ideas. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nana&amp;lt;b&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Nana Lohmanns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 15:11:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204442#M131740</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T15:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204443#M131741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;u have the internal table. say it1.&lt;/P&gt;&lt;P&gt;now, create tables with same structure as above. say it2, it3, it4.&lt;/P&gt;&lt;P&gt;now, u need to have same value for element x.&lt;/P&gt;&lt;P&gt;so, u need to do it as&lt;/P&gt;&lt;P&gt;it2[] = it3[] = it4[] = it1[].&lt;/P&gt;&lt;P&gt;this solves ur problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 15:14:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204443#M131741</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T15:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204444#M131742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Declare sub internal tables with same structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg - ITAB is main internal table. IT1, IT2, IT3, IT4  are sub internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'X'.&lt;/P&gt;&lt;P&gt;    IT1 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT1.&lt;/P&gt;&lt;P&gt;    CLEAR IT1.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'Y'.&lt;/P&gt;&lt;P&gt;    IT2 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT2.&lt;/P&gt;&lt;P&gt;    CLEAR IT2.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'Z'.&lt;/P&gt;&lt;P&gt;    IT3 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT3.&lt;/P&gt;&lt;P&gt;    CLEAR IT3.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  IF ITAB-ELEMENT = 'W'.&lt;/P&gt;&lt;P&gt;    IT4 = ITAB.&lt;/P&gt;&lt;P&gt;    APPEND IT4.&lt;/P&gt;&lt;P&gt;    CLEAR IT4.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 15:19:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204444#M131742</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T15:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204445#M131743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nana,&lt;/P&gt;&lt;P&gt; if you want to split a table into sub-tables .. &lt;/P&gt;&lt;P&gt; you can do this..&lt;/P&gt;&lt;P&gt; assume having four tables of the same type.. tbl1&lt;/P&gt;&lt;P&gt; tbl2 tbl3 and tbl from which data is fetched..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; data : it_1 like table of tbl with header line.
 data : it_2 like table of tbl with header line.
 data : it_3 like table of tbl with header line.
 data : it_4 like table of tbl with header line.

 select * from tbl into table it_1.
 loop at it_1 where &amp;lt;f&amp;gt; = val1.
  move it_1 to it_2.
  append it_2.
 endloop.
 loop at it_1 where &amp;lt;f&amp;gt; = val2.
  move it_1 to it_3.
  append it_2.
 endloop.
loop at it_1 where &amp;lt;f&amp;gt; = val3.
  move it_1 to it_4.
  append it_2.
 endloop.
 
 modify tbl1 from table it_2.
 modify tbl1 from table it_3.
 modify tbl1 from table it_4.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;satesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 15:43:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204445#M131743</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T15:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204446#M131744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, first thanks for all the help but I think maybe I need to be more specific... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with a field USERID. For each USERID there might be several lines with the same structure but except of USERID with different data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get a loop function that moves all lines associated to one USERID into a sub-table which I can use for processing. After processing the loop function is supposed to jump to the next USERID and create a sub-table containing the associated data again, until all USERIDs have been processed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As such I am looking for a way in order to loop through a table and split it into sub-tables by the field USERID. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anybody got a 10 point idea for this one? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:10:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204446#M131744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204447#M131745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can achieve this requirement using CONTROL BREAK Statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding is you need to store all entries related to 1 user id in one sub internal table.....right?&lt;/P&gt;&lt;P&gt;How many user ids you will have?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can sort main internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab by userid. (This should be first field in internal table)&lt;/P&gt;&lt;P&gt;&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;  at new userid.&lt;/P&gt;&lt;P&gt;    refresh table&lt;/P&gt;&lt;P&gt;  endat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  itab1 = itab.&lt;/P&gt;&lt;P&gt;  append itab1.&lt;/P&gt;&lt;P&gt;  clear itab1.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  at end of userid.&lt;/P&gt;&lt;P&gt;    populate su internal table for userid using ITAB1.&lt;/P&gt;&lt;P&gt;    Refresh ITAB1 for storing next userid data.&lt;/P&gt;&lt;P&gt;  endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:20:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204447#M131745</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204448#M131746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Nana,&lt;/P&gt;&lt;P&gt; Is this what you ask for..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
loop at itab.
move itab to it1.
append it1.
at end of userid.
*move to sub table.
it2[] = it1[].
*clears the it1 for new userid
refresh it1.
append it2.
endat.
*now use it2.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;satesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:22:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204448#M131746</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204449#M131747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like what I was looking for, but I can't try it right now.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will it move through all ID's in the list?&lt;/P&gt;&lt;P&gt;(Where will the loop resume?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try it when I get home....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:28:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204449#M131747</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204450#M131748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this workaround...&lt;/P&gt;&lt;P&gt;append lines of itab to itab1 " appending all entries into another table"&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;at new userid.&lt;/P&gt;&lt;P&gt;g_count = sy-tabix.&lt;/P&gt;&lt;P&gt;loop at itab1 where userid = itab-userid.&lt;/P&gt;&lt;P&gt;case g_count.&lt;/P&gt;&lt;P&gt;when '1'.&lt;/P&gt;&lt;P&gt;move itab1 to subtab1.&lt;/P&gt;&lt;P&gt;append subtab1.&lt;/P&gt;&lt;P&gt;clear subtab1.&lt;/P&gt;&lt;P&gt;when '2'.&lt;/P&gt;&lt;P&gt;move itab1 to subtab2.&lt;/P&gt;&lt;P&gt;append subtab2.&lt;/P&gt;&lt;P&gt;clear subtab2.&lt;/P&gt;&lt;P&gt;when '3'.&lt;/P&gt;&lt;P&gt;move itab1 to subtab3.&lt;/P&gt;&lt;P&gt;append subtab3.&lt;/P&gt;&lt;P&gt;clear subtab3.   " n so on&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;doesnt seem very efficient but hope it gives a little idea..&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bikash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:33:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204450#M131748</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204451#M131749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nana,&lt;/P&gt;&lt;P&gt; it is moving thru all ids..&lt;/P&gt;&lt;P&gt; when a new userid is upcoming at end of userid is  triggered..&lt;/P&gt;&lt;P&gt; for every new userid it1 is cleared .. which means it has fields for only one value of the userid.. which is moved to it2..&lt;/P&gt;&lt;P&gt;hope you got it..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;move itab to it1.&lt;/P&gt;&lt;P&gt;append it1.&lt;/P&gt;&lt;P&gt;at end of userid.&lt;/P&gt;&lt;P&gt;*move to sub table.&lt;/P&gt;&lt;P&gt;it2[] = it1[].&lt;/P&gt;&lt;P&gt;*clears the it1 for new userid&lt;/P&gt;&lt;P&gt;refresh it1.&lt;/P&gt;&lt;P&gt;append it2.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;*now use it2.&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;satesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:37:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204451#M131749</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Splittin table by values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204452#M131750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this what you are looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
unique_users_itab[] = all_users_itab[].
SORT unique_users_itab BY uname.
DELETE ADJACENT DUPLICATES FROM unique_users_itab COMPARING uname.
LOOP AT unique_users_itab.
  LOOP AT all_users_itab WHERE uname = unique_users_itab-uname.
*-- do whatever
  ENDLOOP.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2006 16:40:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/splittin-table-by-values/m-p/1204452#M131750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-23T16:40:49Z</dc:date>
    </item>
  </channel>
</rss>

