<?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: GETTING DATA FROM TWO TABLES. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222463#M1207565</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can implement this using below two methods:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.inner join as explained above &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;2.Use FOR ALL ENTERIES like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a.decsribe 3 intrenal table i_matgrp,i_t023t,and i_display.&lt;/P&gt;&lt;P&gt;b.Select all the fields from in the i_matgrp&lt;/P&gt;&lt;P&gt;c.then select all the enetried in the i_t023t for all enteries in i_matgrp&lt;/P&gt;&lt;P&gt;d.finally read all the data from the two internal table into i_display&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select matkl l_sum l_t_sum from matgrp into table i_matgrp where matk = matk.
"supposing the value of matk is provided by user or if all the data then remove the where condition
if sy-subrc = 0.
select matkl wgbez wgbez60 from t023t into table i_t230t for all enteries in i_matgrp where matk = i_matk.
endif.

loop at i_matkgrp into wa_matkgrp.
wa-matkl = wa_matkgrp-matkl.
wa-l_sum = wa_matkgrp-l_sum.
wa- l_t_sum = wa_matkgrp-l_t_sum.
loop at i_t230t into wa-t230.
wa-wgbez = wa_t230-wgbez.
wa-wgbez60 = wa_t230-wgbez60.

append wa into itab.
clear wa.
endloop.
enloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this might help you out.&lt;/P&gt;&lt;P&gt;Pooja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Feb 2009 07:48:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-17T07:48:27Z</dc:date>
    <item>
      <title>GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222452#M1207554</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 am having i_matgrp table with fields matkl , l_sum , l_t_sum.&lt;/P&gt;&lt;P&gt;I need to get material group description(wgbez,wgbez60) from t023t table for each matkl in i_matgrp &lt;/P&gt;&lt;P&gt;and put all 3 fields and descriptions(2 fields) in to a single table i_display for display.&lt;/P&gt;&lt;P&gt;please suggest select query for this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:14:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222452#M1207554</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222453#M1207555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anil,&lt;/P&gt;&lt;P&gt; Try using &lt;STRONG&gt;inner joins&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample query,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT p~cityfrom                    " Departure city&lt;/P&gt;&lt;P&gt;         p~cityto                      " Arrival city&lt;/P&gt;&lt;P&gt;         p~carrid                      " Airline Code&lt;/P&gt;&lt;P&gt;         p~deptime                     " DEPTIME&lt;/P&gt;&lt;P&gt;         p~arrtime                     " Arrival time&lt;/P&gt;&lt;P&gt;         p~connid                      " Flight Connection Number&lt;/P&gt;&lt;P&gt;         f~fldate                      " Flight date&lt;/P&gt;&lt;P&gt;         f~price                       " Airfare&lt;/P&gt;&lt;P&gt;  INTO TABLE t_flight&lt;/P&gt;&lt;P&gt;  FROM spfli AS p INNER JOIN sflight AS f&lt;/P&gt;&lt;P&gt;    ON ( p&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid )&lt;/P&gt;&lt;P&gt;   AND ( p&lt;SUB&gt;connid = f&lt;/SUB&gt;connid )&lt;/P&gt;&lt;P&gt; WHERE ( p~cityfrom IN s_ctyfro )&lt;/P&gt;&lt;P&gt;   and ( p~cityto IN s_cityto )&lt;/P&gt;&lt;P&gt;   AND ( p~carrid IN s_carrid ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where s_cityto and s_carrid arethe select option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Much Regards,&lt;/P&gt;&lt;P&gt;Amuktha.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:16:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222453#M1207555</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222454#M1207556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use inner join. You can use this code fragment as a reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT
      A~matnr
      A~werks
      A~lgort
      A~labst
      B~matkl
      C~maktx
   INTO TABLE it_val
   FROM mard as A INNER JOIN mara as B ON B~matnr = A~matnr
   INNER JOIN makt as C ON A~matnr = C~matnr
   WHERE
      A~werks in c_werks AND
      A~lgort in c_lgort AND
      A~matnr in pro_code AND
      B~matkl in mat_grp  AND
      A~labst &amp;lt;&amp;gt; 0.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mon Magallanes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:17:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222454#M1207556</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222455#M1207557</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;&lt;/P&gt;&lt;P&gt;Try it out using FOR ALL ENTERIES statement.&lt;/P&gt;&lt;P&gt;first select the fields in i_mat table and then use the above statement to fetch(wgbez,wgbez60).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Rajesh Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:19:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222455#M1207557</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222456#M1207558</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;PRE&gt;&lt;CODE&gt;select matkl 
                  wgbez 
                  wgbez60 
           from t023t into table i_display 
for all entries in i_matgrp.

loop at i_display.
read table i_display from i_display field value matkl = i_matgrp-matkl.
modify table i_display from i_display transporting wgbez wgbez60.
endloop. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will work&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:19:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222456#M1207558</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222457#M1207559</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;use inner joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer this query.&lt;/P&gt;&lt;P&gt;data :&lt;/P&gt;&lt;P&gt;  begin of fs,&lt;/P&gt;&lt;P&gt;    carrid type spfli-carrid,&lt;/P&gt;&lt;P&gt;    connid type spfli-connid,&lt;/P&gt;&lt;P&gt;    fldate type sflight-fldate,&lt;/P&gt;&lt;P&gt;    price  type sflight-price,&lt;/P&gt;&lt;P&gt;end of fs.&lt;/P&gt;&lt;P&gt;data t_sflight like standard table of fs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a~carrid&lt;/P&gt;&lt;P&gt;          a~connid&lt;/P&gt;&lt;P&gt;          b~fldate&lt;/P&gt;&lt;P&gt;          b~price&lt;/P&gt;&lt;P&gt;   from ( spfli as a inner join sflight as b on&lt;/P&gt;&lt;P&gt;a&lt;SUB&gt;carrid eq b&lt;/SUB&gt;carrid and a&lt;SUB&gt;connid eq b&lt;/SUB&gt;connid )&lt;/P&gt;&lt;P&gt;into table t_sflight.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:20:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222457#M1207559</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222458#M1207560</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;Its sample inner join&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab occurs 0,
        matnr like mara-matnr,
        maktx like makt-maktx,
      end of itab.

select * into corresponding fields of table itab
from ( mara as a
  inner join makt as b on a~matnr = b~matnr ).

loop at itab.
 write:/ itab-matnr, itab-maktx.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pl. search the forum,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:23:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222458#M1207560</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-02-17T07:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222459#M1207561</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 the two tables are the same, then you can try using the except operation as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from tablea&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;except&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from tableb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If they share a common primary key, then you could also do a left join between the table and filter on the absence of data in the second table to find the rows missing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select tablea.*&lt;/P&gt;&lt;P&gt;from tablea&lt;/P&gt;&lt;P&gt;left join tableb on tablea.rowid = tableb.rowid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where tableb.rowid is null&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Neelima.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:23:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222459#M1207561</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222460#M1207562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab,
matkl like i_matgrp-matkl,
wgbez like t023t-wgbez,
wgbez60 like t023t-wgbez60 ,
end of itab.

select i_matgrp~matkl t023t~wgbez t023t~wgbez60 
into corresponding fields of table itab
from i_matgrp
inner join t023t on ( i_matgrp~matkl = t023t~matkl).&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:25:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222460#M1207562</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222461#M1207563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi tahir,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is giving error as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i_matgrp is not defined as  table or view in the ABAP data dictionay,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:30:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222461#M1207563</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222462#M1207564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab,
matkl like t023t,
wgbez like t023t-wgbez,
wgbez60 like t023t-wgbez60 ,
end of itab.
 
select matkl wgbez wgbez60 
into corresponding fields of table itab
from t023t.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i was thinking i_matgrp is dictionary table.&lt;/P&gt;&lt;P&gt;u can select all material group and their description in this way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:43:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222462#M1207564</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222463#M1207565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can implement this using below two methods:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.inner join as explained above &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;2.Use FOR ALL ENTERIES like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a.decsribe 3 intrenal table i_matgrp,i_t023t,and i_display.&lt;/P&gt;&lt;P&gt;b.Select all the fields from in the i_matgrp&lt;/P&gt;&lt;P&gt;c.then select all the enetried in the i_t023t for all enteries in i_matgrp&lt;/P&gt;&lt;P&gt;d.finally read all the data from the two internal table into i_display&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select matkl l_sum l_t_sum from matgrp into table i_matgrp where matk = matk.
"supposing the value of matk is provided by user or if all the data then remove the where condition
if sy-subrc = 0.
select matkl wgbez wgbez60 from t023t into table i_t230t for all enteries in i_matgrp where matk = i_matk.
endif.

loop at i_matkgrp into wa_matkgrp.
wa-matkl = wa_matkgrp-matkl.
wa-l_sum = wa_matkgrp-l_sum.
wa- l_t_sum = wa_matkgrp-l_t_sum.
loop at i_t230t into wa-t230.
wa-wgbez = wa_t230-wgbez.
wa-wgbez60 = wa_t230-wgbez60.

append wa into itab.
clear wa.
endloop.
enloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this might help you out.&lt;/P&gt;&lt;P&gt;Pooja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:48:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222463#M1207565</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222464#M1207566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If ur first table i_matgrp having data.&lt;/P&gt;&lt;P&gt;Then find the logic below for ur query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if i_matgrp is not initial.

select SPRAS
       MATKL
       WGBEZ
       WGBEZ60
       into table i_display
for all entries in i_matgrp
where matkl eq i_matgrp-matkl.


endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls let me know if any queries regarding this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Syed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 07:57:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222464#M1207566</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T07:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222465#M1207567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having i_matgrp table with fields matkl , l_sum , l_t_sum.&lt;/P&gt;&lt;P&gt;I need to get material group description(wgbez,wgbez60) from t023t table for each matkl in i_matgrp &lt;/P&gt;&lt;P&gt;and put all 3 fields and descriptions(2 fields) in to a single table i_display for display.&lt;/P&gt;&lt;P&gt;please suggest select query for this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi.&lt;/P&gt;&lt;P&gt;sorry do like in this way.just copy paste it and check t&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but also paste ur code for the internal table of i_matgrp which u have made&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab,
matkl like t023t-matkl,
wgbez like t023t-wgbez,
wgbez60 like t023t-wgbez,
end of itab.
data:wa_itab like itab.
data:wa_i_matgrp like i_matgrp.

data: begin of i_display,
matkl like t023t-matkl,
l_sum type i,
l_t_sum type i, "these two fields can be according to ur need,
wgbez like t023-wgbez,
wgbez60 like t023t-wgbez60,
end of i_display.

data: wa_i_display like i_display.

select matkl wgbez wgbez60 into corresponding fields of itab
from t023t FOR ALL ENTRIES IN i_matgrp
where matkl = i_matgrp-matkl.

loop at i_matgrp into wa_i_matgrp.
  MOVE-CORRESPONDING wa_i_matgrp to wa_i_display.
  read table itab into wa_itab WITH KEY matkl = wa_i_matgrp-matkl.
   MOVE-CORRESPONDING wa_itab to wa_i_display.
  append wa_i_display to i_display.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: tahir naqqash on Feb 17, 2009 1:07 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:01:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222465#M1207567</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: GETTING DATA FROM TWO TABLES.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222466#M1207568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;Sorry my Sap was down so i cant test my code.&lt;/P&gt;&lt;P&gt;now i have checked it and correct it. &lt;/P&gt;&lt;P&gt;now u have to fill ur i_matgrp table according to ur need by select or by append. however i have tested it for 001 materal group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ztn_test.
data: BEGIN OF i_matgrp OCCURS 10,
      matkl like t023t-matkl,
      l_sum type i,
      i_t_sum type i,
  END OF i_matgrp.
" To test for matkl = 001.
  " but u should fill ur i_matgrp according to ur need by select statement or append, which u are using
  i_matgrp-matkl = '001'. append i_matgrp.


data: begin of itab OCCURS 10,
matkl like t023t-matkl,
wgbez like t023t-wgbez,
wgbez60 like t023t-wgbez,
end of itab.
data:wa_itab like itab.
data:wa_i_matgrp like i_matgrp.

data: begin of i_display occurs 10,
matkl like t023t-matkl,
l_sum type i,
l_t_sum type i, "these two fields can be according to ur need,
wgbez like t023t-wgbez,
wgbez60 like t023t-wgbez60,
end of i_display.

data: wa_i_display like i_display.

select matkl wgbez wgbez60 into corresponding fields of table itab
from t023t FOR ALL ENTRIES IN i_matgrp
where matkl = i_matgrp-matkl.

loop at i_matgrp into wa_i_matgrp.
  MOVE-CORRESPONDING wa_i_matgrp to wa_i_display.
  read table itab into wa_itab WITH KEY matkl = wa_i_matgrp-matkl.
   MOVE-CORRESPONDING wa_itab to wa_i_display.
  append wa_i_display to i_display.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2009 08:19:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-data-from-two-tables/m-p/5222466#M1207568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-17T08:19:12Z</dc:date>
    </item>
  </channel>
</rss>

