<?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 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806973#M915686</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Here, i am taking two tables mara and marc.&lt;/P&gt;&lt;P&gt;If you want to do without innerjoin, then you need to declare 2 internal tables and you need to use FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;i am giving sample code here.&lt;/P&gt;&lt;P&gt;Here, instead of  "*" you can fetch required fields according to ur use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab1 type standard table of mara,&lt;/P&gt;&lt;P&gt;         itab2 type  standard table of marc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select werks from marc into corresponding fields of table itab2 &lt;STRONG&gt;for all entries&lt;/STRONG&gt; in itab1 where matnr = itab1-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sandeep reddy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sandeep Reddy on May 19, 2008 7:12 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 May 2008 17:11:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-19T17:11:55Z</dc:date>
    <item>
      <title>select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806972#M915685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;v hv 2 tables,,from which i hv to match a common field ...which is having the same name........and i want to retrieve the data from the other field of table 2 ........and i hv to do it with out using inner join ....so plz suggest me?????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 16:52:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806972#M915685</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T16:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806973#M915686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Here, i am taking two tables mara and marc.&lt;/P&gt;&lt;P&gt;If you want to do without innerjoin, then you need to declare 2 internal tables and you need to use FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;i am giving sample code here.&lt;/P&gt;&lt;P&gt;Here, instead of  "*" you can fetch required fields according to ur use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab1 type standard table of mara,&lt;/P&gt;&lt;P&gt;         itab2 type  standard table of marc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select werks from marc into corresponding fields of table itab2 &lt;STRONG&gt;for all entries&lt;/STRONG&gt; in itab1 where matnr = itab1-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sandeep reddy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sandeep Reddy on May 19, 2008 7:12 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 17:11:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806973#M915686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T17:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806974#M915687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's assume the first table is named 'TABLE1' and the second 'TABLE2', and the common field is FIELD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First: Do the selection in TABLE1 and save the result in an internal table:&lt;/P&gt;&lt;P&gt;SELECT * INTO CORRESPONDING FIELDS OF TABLE tb1 FROM table 1 WHERE ...(any condition you want)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second: You have to do the selection in the second table with the aditional statement 'FOR ALL ENTRIES', and then you have to check the common field in the WHERE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * INTO tb2 FROM table2&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN tb1&lt;/P&gt;&lt;P&gt;WHERE field = tb1-field AND ...(any other condition you want)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before doing the second select, you have to check if the internal table tb1 has values (check sy-subrc after the first query); if the internal table is empty the second SELECT would bring you any value from the second table, and if you don't have any other conditions in the WHERE statement, it would bring you the whole table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 17:14:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806974#M915687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T17:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806975#M915688</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 both tables are having common field,  1st you get a data into one table&lt;/P&gt;&lt;P&gt;using that table you can get other table data which is relevant to 1st table.&lt;/P&gt;&lt;P&gt;using for all entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select  * from makt&lt;/P&gt;&lt;P&gt;            into table it_makt&lt;/P&gt;&lt;P&gt;            for all entries in it_mara&lt;/P&gt;&lt;P&gt;            where matnr = it_mara-matnr.&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;Regards&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 17:17:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806975#M915688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T17:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806976#M915689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want an example to join 3 tables, you can find it at this path in SAP&lt;/P&gt;&lt;P&gt;ABAPDOCU(Transaction)&lt;DEL&gt;&amp;gt;ABAP Database Access&lt;/DEL&gt;&amp;gt;Open SQL&lt;DEL&gt;&amp;gt;Read data&lt;/DEL&gt;&amp;gt;Inner Join.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;you can find the following code&lt;/STRONG&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa,&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;bookid TYPE sbook-bookid,&lt;/P&gt;&lt;P&gt;END OF wa,&lt;/P&gt;&lt;P&gt;itab LIKE SORTED TABLE OF wa&lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY carrid connid fldate bookid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT p&lt;SUB&gt;carrid p&lt;/SUB&gt;connid f&lt;SUB&gt;fldate b&lt;/SUB&gt;bookid&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;FROM ( ( spfli AS p&lt;/P&gt;&lt;P&gt;INNER JOIN sflight AS f ON p&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;p&lt;SUB&gt;connid = f&lt;/SUB&gt;connid )&lt;/P&gt;&lt;P&gt;INNER JOIN sbook AS b ON b&lt;SUB&gt;carrid = f&lt;/SUB&gt;carrid AND&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;connid = f&lt;/SUB&gt;connid AND&lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;fldate = f&lt;/SUB&gt;fldate )&lt;/P&gt;&lt;P&gt;WHERE p~cityfrom = 'FRANKFURT' AND&lt;/P&gt;&lt;P&gt;p~cityto = 'NEW YORK' AND&lt;/P&gt;&lt;P&gt;f&lt;SUB&gt;seatsmax &amp;gt; f&lt;/SUB&gt;seatsocc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa.&lt;/P&gt;&lt;P&gt;AT NEW fldate.&lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-connid, wa-fldate.&lt;/P&gt;&lt;P&gt;ENDAT.&lt;/P&gt;&lt;P&gt;WRITE / wa-bookid.&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;In the same way you can join two tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 19:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806976#M915689</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T19:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806977#M915690</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;FOR ALL ENTRIES IN it's possibly the best way to do this.&lt;/P&gt;&lt;P&gt;Just match a common field by putting in into the WHERE clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note:it's VERY important to the program's performance that the FOR ALL ENTRIES IN table doesn't have any &lt;STRONG&gt;duplicate records&lt;/STRONG&gt;. If you need those duplicate records, just make an auxiliar FOR ALL ENTRIES IN table.&lt;/P&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr
mtart  TYPE mara-mtart
ernam TYPE mara-ernam
END OF ty_mara.

TYPES: BEGIN OF ty_marc,
matnr TYPE mara-matnr
werks TYPE marc-werks
END OF ty_marc.

DATA: itab_mara  TYPE TABLE OF ty_mara,
          itab_marc  TYPE TABLE OF ty_marc.

SELECT mara matnr ernam 
FROM mara
INTO TABLE itab_mara.

*** Here, you retrieve data from itab_marc, according to itab_mara:
SELECT matnr werks
FROM marc
INTO TABLE itab_marc
FOR ALL ENTRIES IN itab_mara
WHERE matnr = mara-matnr.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps,&lt;/P&gt;&lt;P&gt;Brian Gonsales&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 20:09:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/3806977#M915690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-19T20:09:20Z</dc:date>
    </item>
  </channel>
</rss>

