<?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: Internal table help in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881085#M51660</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a) There is no generic access with read tables.&lt;/P&gt;&lt;P&gt;b) You can copy whole table and delete entries not matching your requirements - 2 statements, but in one step you will have twice the amount of data.&lt;/P&gt;&lt;P&gt;c) Something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;read inttable1 with key ....
loop at inttable1 from sy-tabix into wa.
if wa-key &amp;lt;&amp;gt; wa2-key.
exit.
endif.
append wa to inttable2.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Advantage: you will only loop over required entries.&lt;/P&gt;&lt;P&gt;Disadvantage: more lines of coding (but fast and small memory usage).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Feb 2005 15:18:40 GMT</pubDate>
    <dc:creator>christian_wohlfahrt</dc:creator>
    <dc:date>2005-02-02T15:18:40Z</dc:date>
    <item>
      <title>Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881083#M51658</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 an internal table and i would like to read a bunch of records that matches the selection criteria in one step (without using a loop), just like we do using select statement from a DB table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I currently have...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INTTABLE1 IS A SORTED TABLE WITH KEY F1 F2 F3 F4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT INTTABLE1 INTO S_WORKAREA.&lt;/P&gt;&lt;P&gt;   IF S_WORKAREA-F1 = INTTABLE2-F1  AND&lt;/P&gt;&lt;P&gt;      S_WORKAREA-F2 = INTTABLE2-F2  AND&lt;/P&gt;&lt;P&gt;      S_WORKAREA-F3 = INTTABLE2-F3  AND&lt;/P&gt;&lt;P&gt;      S_WORKAREA-F4 = INTTABLE2-F4.&lt;/P&gt;&lt;P&gt;    APPEND S_WORKAREA-F5 TO INTTABLE3.&lt;/P&gt;&lt;P&gt;   ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I would like to get rid of this LOOP and still be able to append all the matching records to INTTABLE3. Is there any functionality like that, which lets me do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks alot&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 14:45:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881083#M51658</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-02T14:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881084#M51659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm afraid there's no such ABAP statement. But there is indeed a trick you can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- First of all, define an itab with the same structure as INTTABLE1, say INTTABLE1_COPY.&lt;/P&gt;&lt;P&gt;- Then, write INTTABLE1_COPY[] = INTTABLE1[].&lt;/P&gt;&lt;P&gt;- Finally, write DELETE INTTABLE1_COPY WHERE NOT (your_condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...and that's it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please tell me if it worked. BR,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 15:15:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881084#M51659</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-02T15:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881085#M51660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a) There is no generic access with read tables.&lt;/P&gt;&lt;P&gt;b) You can copy whole table and delete entries not matching your requirements - 2 statements, but in one step you will have twice the amount of data.&lt;/P&gt;&lt;P&gt;c) Something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;read inttable1 with key ....
loop at inttable1 from sy-tabix into wa.
if wa-key &amp;lt;&amp;gt; wa2-key.
exit.
endif.
append wa to inttable2.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Advantage: you will only loop over required entries.&lt;/P&gt;&lt;P&gt;Disadvantage: more lines of coding (but fast and small memory usage).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 15:18:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881085#M51660</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-02-02T15:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881086#M51661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the only possibility I can imagine is doing some reads instead of looping.&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;P&gt;read table inttable1 into s_workarea with key ...&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  l_tabix = sy-tabix.&lt;/P&gt;&lt;P&gt;  while sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    l_tabix = l_tabix + 1.&lt;/P&gt;&lt;P&gt;    read table inttable1 into s_workarea index l_tabix.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;check the keyfields now and exit if not ok.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  endwhile.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not very nice too, but may be a bit faster as you are dealing with a sorted or may be better a hashed table.&lt;/P&gt;&lt;P&gt;Another option (if you know the index of the first and the last relevant row) is doing a:&lt;/P&gt;&lt;P&gt;append lines of inttable1 from index1 to indexl to inttable3.&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;Siggi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 15:25:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881086#M51661</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-02T15:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881087#M51662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are going to have to read thru the internal table somehow so try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT INTTABLE1 ASSIGNING &amp;lt;S_WORKAREA&amp;gt;
  WHERE F1 = INTTABLE2-F1 and
        F2 = ...

  APPEND &amp;lt;S_WORKAREA-F5&amp;gt; to INTTABLE3.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will allow you to take advantage of the fact that you have a sorted table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your key is unique in your sorted table then try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  READ TABLE INTTABLE1 ASSIGNING &amp;lt;S_WORKAREA&amp;gt;
    WITH TABLE KEY
      F1 = INTTABLE2-F1
      F2 = ...

  APPEND &amp;lt;S_WORKAREA-F5&amp;gt; to INTTABLE3.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field symbol &amp;lt;S_WORKAREA&amp;gt; is type line of INTTABLE1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 15:29:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881087#M51662</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-02T15:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881088#M51663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alvaro and everyone else,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for your inputs....I used Alvaro's code...it works fine and gets rid of the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2005 18:21:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-help/m-p/881088#M51663</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-02-02T18:21:04Z</dc:date>
    </item>
  </channel>
</rss>

