<?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: select statement using 2 tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237785#M141295</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to make a connection to the customer master file.  In this case, you will have a 1 to many relationship with KNA1 and LIKP.  Do you want to output only one record for each customer number?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that you already have the v_likp internal table, you can just read it with key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at i_kna1 into v_kna1.

clear v_likp.
read table i_likp into v_likp with key kunnr = v_kna1-kunnr.

concatenate: v_kna1-kunnr
v_kna1-name1
v_likp-charg
    into v_output seperated by c_tab.

append v_ouput.



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Mar 2006 20:35:50 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2006-03-08T20:35:50Z</dc:date>
    <item>
      <title>select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237782#M141292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the following code, i have to select "v_likp-charg" into the "concatenate" statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please let me know, how can i do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;help is appreciated,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;data: i_kna1 type t_kna1 occurs 0,&lt;/P&gt;&lt;P&gt;      v_kna1 type t_kna1,&lt;/P&gt;&lt;P&gt;      i_likp type t_likp occurs 0,&lt;/P&gt;&lt;P&gt;      v_likp type t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_kna1,&lt;/P&gt;&lt;P&gt;        kunnr like kna1-kunnr,&lt;/P&gt;&lt;P&gt;        name1 like kna1-name1,&lt;/P&gt;&lt;P&gt;       end of t_kna1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_likp,&lt;/P&gt;&lt;P&gt;        matnr like likp-matnr,&lt;/P&gt;&lt;P&gt;        charg like likp-charg,&lt;/P&gt;&lt;P&gt;        kunnr like likp-kunnr,&lt;/P&gt;&lt;P&gt;      end of t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of v_output,&lt;/P&gt;&lt;P&gt;         record(500),&lt;/P&gt;&lt;P&gt;      end of v_ouput.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_kna1 into v_kna1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate: v_kna1-kunnr&lt;/P&gt;&lt;P&gt;             v_kna1-name1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="7" type="ul"&gt;&lt;P&gt;i want "v_likp-charg" to be here..******&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      into v_output seperated by c_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append v_ouput.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:28:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237782#M141292</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237783#M141293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How did u declear &amp;lt;i&amp;gt;c_tab&amp;lt;/i&amp;gt; in ur code.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Khimavath Vikranth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:32:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237783#M141293</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237784#M141294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you can do a read table to v_likp and get the code...something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at i_kna1 into v_kna1.
w_index = sy-tabix.
read table v_likp index w_tabix.
concatenate: v_kna1-kunnr
v_kna1-name1
v_likp-charg
into v_output seperated by c_tab.

append v_ouput.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it depends on the data...you must have the same number of records on both i_kna1 and v_likp otherwise...do a SELECT SINGLE on likp using a condition...Always inside the loop.&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;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:35:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237784#M141294</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237785#M141295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to make a connection to the customer master file.  In this case, you will have a 1 to many relationship with KNA1 and LIKP.  Do you want to output only one record for each customer number?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that you already have the v_likp internal table, you can just read it with key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

loop at i_kna1 into v_kna1.

clear v_likp.
read table i_likp into v_likp with key kunnr = v_kna1-kunnr.

concatenate: v_kna1-kunnr
v_kna1-name1
v_likp-charg
    into v_output seperated by c_tab.

append v_ouput.



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237785#M141295</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-03-08T20:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237786#M141296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  Check the below code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use an Inner join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a~kunnr&lt;/P&gt;&lt;P&gt;       a~name1 &lt;/P&gt;&lt;P&gt;       b~matnr&lt;/P&gt;&lt;P&gt;       b~charg &lt;/P&gt;&lt;P&gt;into table itab from kna1 as a inner join likp as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;kunnr = b&lt;/SUB&gt;kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now process ITAB.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB into wa_itab.&lt;/P&gt;&lt;P&gt;concatenate: wa_itab-kunnr&lt;/P&gt;&lt;P&gt;wa_itab-name1&lt;/P&gt;&lt;P&gt;wa_itab-charg&lt;/P&gt;&lt;P&gt;into v_output seperated by c_tab.&lt;/P&gt;&lt;P&gt;append v_ouput.&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;Regards,&lt;/P&gt;&lt;P&gt;Vara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:36:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237786#M141296</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237787#M141297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: begin of c_tab ,&lt;/P&gt;&lt;P&gt;         x(1) type x value '09',&lt;/P&gt;&lt;P&gt;      end of c_tab.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:38:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237787#M141297</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237788#M141298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if your v_likp-kunnr and v_kna1-kunnr are linked then your code should be&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT i_likp INTO v_likp.
  CLEAR v_kna1.
  READ TABLE i_kna1 WITH KEY kunnr = v_likp-kunnr.
  CHECK SY-SUBRC = 0.
.....your concatenate statement can follow here...
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Remember, I had the LOOP AT i_likp first because, you can have several LIKP records for the same KUNNR.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:38:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237788#M141298</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237789#M141299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; loop at i_kna1 into v_kna1.&lt;/P&gt;&lt;P&gt; &amp;lt;b&amp;gt;read table i_likp where kunnr = v_kna1-kunnr.&amp;lt;/b&amp;gt;  concatenate: v_kna1-kunnr&lt;/P&gt;&lt;P&gt;v_kna1-name1 &amp;lt;b&amp;gt;i_likp-charge&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="7" type="ul"&gt;&lt;P&gt;i want "v_likp-charg" to be here..******&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into v_output seperated by c_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append v_ouput.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 20:47:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237789#M141299</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T20:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: select statement using 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237790#M141300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thnx one and all,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Mar 2006 21:58:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-using-2-tables/m-p/1237790#M141300</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-03-08T21:58:23Z</dc:date>
    </item>
  </channel>
</rss>

