<?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: loop over two internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135098#M1190271</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;&amp;lt;answer deleted as similar responses already posted&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the above responses only avinash's solution will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: kartik tarla on Jan 21, 2009 10:52 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Jan 2009 17:21:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-21T17:21:16Z</dc:date>
    <item>
      <title>loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135094#M1190267</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 two tables. one table has 2 lines and the other has also 2 lines. i want to have for all data in table 1 the data which is in table 2, this means:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;customer 1&lt;/P&gt;&lt;P&gt;customer 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matnr1&lt;/P&gt;&lt;P&gt;matnr2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;result table&lt;/P&gt;&lt;P&gt;customer1 matnr1&lt;/P&gt;&lt;P&gt;customer1 matnr2&lt;/P&gt;&lt;P&gt;customer2 matnr1&lt;/P&gt;&lt;P&gt;customer2 matnr2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can I get the result table with loop.?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:08:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135094#M1190267</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135095#M1190268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;table3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;customer&lt;/P&gt;&lt;P&gt;matnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at table1.&lt;/P&gt;&lt;P&gt;clear table2.&lt;/P&gt;&lt;P&gt;read table2 with index sy-tabix.&lt;/P&gt;&lt;P&gt;table3-customer = table1-customer&lt;/P&gt;&lt;P&gt;table3-matnr = table2-matnr. &lt;/P&gt;&lt;P&gt;append table3. clear table3.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:13:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135095#M1190268</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135096#M1190269</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;Check this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at table1.
Loop at table2.
table3-customer = table1-customer.
table3-matnr      =   table2-matnr.
Append table3.
clear table3.
Endloop.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will get the result as you required.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:15:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135096#M1190269</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135097#M1190270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop tab1 into wa1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop tab2 intowa2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;append wa3 to tab3.&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;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:16:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135097#M1190270</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135098#M1190271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;lt;&amp;lt;answer deleted as similar responses already posted&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the above responses only avinash's solution will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: kartik tarla on Jan 21, 2009 10:52 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:21:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135098#M1190271</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135099#M1190272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why did you clear table3 Avinash?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:31:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135099#M1190272</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135100#M1190273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not required in this case. I have the habit of clearing the header data after append statement.&lt;/P&gt;&lt;P&gt;In some case where you use the read statement and populate some of the table fields in the loop. In this case when read cannot return the values for the givn condt then you need to pass blank to those fields. If you donot clear the values the previous values will exit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT i_9121 INTO i_9121_line.
    CLEAR i_hrsbu_line.

" First loop pass the read returns the value and maaping the value to the internal table field 
" i_vdetails_line-stext. But in the Next pass the read did not returned the value and sy-subrc get's 
" failed and value is not mapped to i_vdetails_line-stext. If you are not clearing the previous loop pass
" exits and get's append's..which is wrong
    READ TABLE i_hrsbu INTO i_hrsbu_line
             WITH KEY hrsbu = i_9121_line-hrsbu BINARY SEARCH.
    IF sy-subrc EQ 0.
      i_vdetails_line-stext =  i_hrsbu_line-stext.
    ENDIF.

    i_vdetails_line-unit   =  i_9121_line-persa(2).
    i_vdetails_line-objid  =  i_9121_line-objid.
    i_vdetails_line-posti  =  i_9121_line-posti.
    i_vdetails_line-begda  =  i_9121_line-begda.

    CLEAR i_funar_line.
    READ TABLE i_funar_t INTO i_funar_line
             WITH KEY funar = i_9121_line-funar BINARY SEARCH.
    IF sy-subrc EQ 0.
      i_vdetails_line-ltext =  i_funar_line-ltext.
    ENDIF.

*   Get Position Request Status Details
    CLEAR i_9122_line.
    READ TABLE i_9122 INTO i_9122_line
         WITH KEY objid = i_9121_line-objid BINARY SEARCH.
    IF sy-subrc EQ 0.
      CLEAR i_itmcd_line.
      READ TABLE i_itmcd_t INTO i_itmcd_line
                WITH KEY itmcd = i_9122_line-rstat BINARY SEARCH.
      IF sy-subrc EQ 0.
        i_vdetails_line-itext =  i_itmcd_line-itext.
      ENDIF.

      LOOP AT i_ev_st_lg INTO  i_st_lg_line
                         WHERE itmcd EQ i_9122_line-rstat  .
      ENDLOOP.
      IF sy-subrc EQ 0.
        CLEAR: l_date , l_time.
        WRITE :
          i_st_lg_line-datum TO l_date,
          i_st_lg_line-uzeit TO l_time.
        CONCATENATE l_date l_time(5) INTO i_vdetails_line-dandt
                         SEPARATED BY space.
      ENDIF.
    ENDIF.

*   Get Position Request Basic Details
    CLEAR i_9120_line.
    READ TABLE i_9120 INTO i_9120_line
         WITH KEY objid = i_9121_line-objid BINARY SEARCH.
    IF sy-subrc EQ 0.
      IF i_9120_line-intas EQ 'Y'.
        i_vdetails_line-intas = c_y.
      ELSEIF i_9120_line-intas EQ 'N'.
        i_vdetails_line-intas = c_n.
      ENDIF.
      IF NOT i_9120_line-projo IS INITIAL.

        PERFORM get_jobname USING i_9120_line-projo
                         CHANGING i_vdetails_line-jtitle.
      ENDIF.
    ENDIF.

    APPEND i_vdetails_line TO i_vdetails.
    CLEAR i_vdetails_line.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:39:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135100#M1190273</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135101#M1190274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Avinash has cleared the header line of table 3 well to avoid the confusion use like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Loop at table1 into wa1.
Loop at table2 into wa2.
wa3-customer = wa1-customer.
wa3-matnr      =   wa2-matnr.
Append wa3 to table3.
clear wa3.
Endloop.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code is avinash's i only modified it to make it clearer to u.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 17:42:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135101#M1190274</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T17:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: loop over two internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135102#M1190275</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;if u want to display the data like this when u fetch the data from the database table itself u can use outer join,otherwise if u want to process the internal tables,then u can go for the abouve method...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Jan 2009 18:34:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-over-two-internal-tables/m-p/5135102#M1190275</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-21T18:34:29Z</dc:date>
    </item>
  </channel>
</rss>

