<?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 into table within &amp;quot;EXEC SQL&amp;quot;. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732827#M1300199</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;sorry forgot to mention that it is not a ABAP database I'm selecting from. The table is hosted on a non SAP database. The db-connection is setup in the 'DBCON'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before executing the SELECT I've changed the db-connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;    i_dbs TYPE dbcon_name VALUE '&amp;lt;entry in DBCON&amp;gt;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    CONNECT TO :i_dbs&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    SET CONNECTION :i_dbs&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    SELECT ..&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards  Philipp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jun 2009 07:37:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-03T07:37:02Z</dc:date>
    <item>
      <title>SELECT into table within "EXEC SQL".</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732825#M1300197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try to fetch data from an external database into a internal table by using that coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CLEAR sy-subrc.&lt;/P&gt;&lt;P&gt;      EXEC SQL PERFORMING append_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        SELECT T1.TYPE, T1.ROUTE, T1.SHIPID&lt;/P&gt;&lt;P&gt;          INTO :_int_table&lt;/P&gt;&lt;P&gt;          FROM SAP2LVS.SV_O060 AS T1&lt;/P&gt;&lt;P&gt;          WHERE (T1.SHIPSTAT=30)&lt;/P&gt;&lt;P&gt;          ORDER BY T1.SHIPID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM APPEND_ITAB.&lt;/P&gt;&lt;P&gt;  APPEND &lt;U&gt;int&lt;/U&gt;table.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything works well but my question is:&lt;/P&gt;&lt;P&gt;Is that the only way to read data from an external database into an internal table? For every selected record the subform is called and the internal table is extended by one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isn't there any possibility like 'SELECT .. INTO TABLE ..' when using external database links with "EXEC SQL". &lt;/P&gt;&lt;P&gt;A coding like&lt;/P&gt;&lt;P&gt; EXEC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        SELECT T1.TYPE, T1.ROUTE, T1.SHIPID&lt;/P&gt;&lt;P&gt;          INTO TABLE :_int_table&lt;/P&gt;&lt;P&gt;          FROM SAP2LVS.SV_O060 AS T1&lt;/P&gt;&lt;P&gt;          WHERE (T1.SHIPSTAT=30)&lt;/P&gt;&lt;P&gt;          ORDER BY T1.SHIPID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; ENDEXEC.&lt;/P&gt;&lt;P&gt;Results in an error message an the source couldn't be activated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards.&lt;/P&gt;&lt;P&gt;Philipp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2009 07:21:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732825#M1300197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-03T07:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT into table within "EXEC SQL".</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732826#M1300198</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 dont know why  ur using Native SQL statements. Try to use Open SQL statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lakshman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2009 07:24:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732826#M1300198</guid>
      <dc:creator>former_member209217</dc:creator>
      <dc:date>2009-06-03T07:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT into table within "EXEC SQL".</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732827#M1300199</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;sorry forgot to mention that it is not a ABAP database I'm selecting from. The table is hosted on a non SAP database. The db-connection is setup in the 'DBCON'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before executing the SELECT I've changed the db-connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;    i_dbs TYPE dbcon_name VALUE '&amp;lt;entry in DBCON&amp;gt;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    CONNECT TO :i_dbs&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    SET CONNECTION :i_dbs&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    SELECT ..&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards  Philipp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2009 07:37:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732827#M1300199</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-03T07:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT into table within "EXEC SQL".</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732828#M1300200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you can do it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its not much different than what you are doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First get the resultset into a cursor.&lt;/P&gt;&lt;P&gt;Second: loop at the cursor and append to internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

exec sql.
  open dbcursor for
  SELECT MATNR MAKTX
  FROM Z_MATERIALVIEW
  WHERE MANDT = :v_symandt
endexec.

DO.
  EXEC SQL.
    FETCH NEXT dbcursor INTO :it_output-matnr,
                                 :it_output-maktx
if sy-subrc eq 0.
APPEND it_output. clear it_output.
else.
exit.
endif.

  ENDEXEC.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to do the error handling also.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a standard demo also using OOPs . In SE38 check the report &lt;STRONG&gt;ADBC_DEMO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Abdullah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2009 08:34:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-into-table-within-quot-exec-sql-quot/m-p/5732828#M1300200</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-03T08:34:04Z</dc:date>
    </item>
  </channel>
</rss>

