<?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 table inside a loop . in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699426#M31723</link>
    <description>&lt;P&gt;What is the reason of this question? ABAP has its statement to read multiple rows from internal table.&lt;/P&gt;&lt;P&gt;And the answer to your question is "maybe", because if the read condition doesn't change, you can have a 100000000 cycles loop and still read the same record.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Oct 2018 10:25:50 GMT</pubDate>
    <dc:creator>SimoneMilesi</dc:creator>
    <dc:date>2018-10-17T10:25:50Z</dc:date>
    <item>
      <title>Read table inside a loop .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699425#M31722</link>
      <description>&lt;P&gt;I know that the instruction read table reads only one row but if I put it inside a loop it will read multiple rows right ? &lt;/P&gt;
  &lt;P&gt;refer to my code below :&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;
select vbpa~parvw kna1~kunnr vbap~netwr from vbap

    inner join vbpa on vbap~vbeln = vbpa~vbeln

    inner join kna1 on vbpa~kunnr = kna1~kunnr

    into corresponding fields of table gt_local

    where ( vbpa~parvw = 'AG' ) and

    kna1~kunnr in s_kunnr .



  loop at gt_local into gs_local .

    collect gs_local into gt_local2 .

  endloop .



  select  *

  from vbpa as a inner join vbap as b on ( a~vbeln = b~vbeln )

     inner join vbfa as c on ( c~vbelv = b~vbeln  )

    inner join lips as d on ( d~vbeln = c~vbeln and d~posnr = c~posnn  )

    into corresponding fields of table gt_local3

  where ( a~parvw = 'WE'  )

  and c~vbtyp_n = 'J' or c~vbtyp_n = 'R' .



  clear gt_local .

  clear gs_local .

  loop at gt_local3 into gs_local3 where vbtyp_n = 'J'.

    collect gs_local3 into gt_local.

  endloop.

*

  loop at gt_local2 into gs_local2  .

    move sy-tabix to lv_index .

    read table gt_local into gs_local with key kunnr = gs_local2-kunnr  .

    gs_local2-lfimg = gs_local-lfimg.

    modify  gt_local2 from gs_local2 index lv_index .

  endloop.

*

  clear gt_local .

  clear gs_local .



    loop at gt_local3 into gs_local3 where vbtyp_n ='R'.

    collect gs_local3 into gt_local.

  endloop.





  loop at gt_local2 into gs_local2 .

    move sy-tabix to idx .

    read table gt_local into gs_local with key kunnr = gs_local2-kunnr  .

    gs_local2-rfmng = gs_local-rfmng.

    modify  gt_local2 from gs_local2 index idx .

  endloop.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 09:13:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699425#M31722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-17T09:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Read table inside a loop .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699426#M31723</link>
      <description>&lt;P&gt;What is the reason of this question? ABAP has its statement to read multiple rows from internal table.&lt;/P&gt;&lt;P&gt;And the answer to your question is "maybe", because if the read condition doesn't change, you can have a 100000000 cycles loop and still read the same record.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 10:25:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699426#M31723</guid>
      <dc:creator>SimoneMilesi</dc:creator>
      <dc:date>2018-10-17T10:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read table inside a loop .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699427#M31724</link>
      <description>&lt;P&gt;Edited my question.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 10:37:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699427#M31724</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-10-17T10:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Read table inside a loop .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699428#M31725</link>
      <description>&lt;P&gt;Apart the naming convention totally &lt;EM&gt;scarying &lt;/EM&gt;from my point of view (G... for global and name local, local2, local3)  which makes really hard for me trying to understand what are you trying to achieve, the first question i have is: did you set a breakpoint on the read and debug it?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 11:16:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699428#M31725</guid>
      <dc:creator>SimoneMilesi</dc:creator>
      <dc:date>2018-10-17T11:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Read table inside a loop .</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699429#M31726</link>
      <description>&lt;P&gt;Read statement used inside or outside the loop will give you only 1 record. Read statement will never return multiple records back.&lt;/P&gt;&lt;P&gt;If you want to access multiple records then go for loop.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 14:06:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-inside-a-loop/m-p/699429#M31726</guid>
      <dc:creator>rameez_khan</dc:creator>
      <dc:date>2018-10-17T14:06:16Z</dc:date>
    </item>
  </channel>
</rss>

