<?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: How to execute this SQL Query in ABAP Program. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826818#M43202</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like you wish to run some Native SQL - am I right ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using EXEC SQL syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Displaying an extract from the table AVERI_CLNT: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: F1(3), F2(3), F3(3). &lt;/P&gt;&lt;P&gt;F3 = ' 1 '. &lt;/P&gt;&lt;P&gt;EXEC SQL. &lt;/P&gt;&lt;P&gt;  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT &lt;/P&gt;&lt;P&gt;         WHERE ARG2 = :F3 &lt;/P&gt;&lt;P&gt;ENDEXEC. &lt;/P&gt;&lt;P&gt;WRITE: / F1, F2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, please award me the points as so few people do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Colin. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Oct 2004 14:52:00 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2004-10-07T14:52:00Z</dc:date>
    <item>
      <title>How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826817#M43201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a string which is the SQL Query.&lt;/P&gt;&lt;P&gt;How to execute this sql Query (SQL_STR) in ABAP Program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:-&lt;/P&gt;&lt;P&gt;DATA: SQL_STR type string.&lt;/P&gt;&lt;P&gt;SQL_STR = 'select * from spfli.'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2004 13:24:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826817#M43201</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-10-07T13:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826818#M43202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like you wish to run some Native SQL - am I right ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using EXEC SQL syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Displaying an extract from the table AVERI_CLNT: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: F1(3), F2(3), F3(3). &lt;/P&gt;&lt;P&gt;F3 = ' 1 '. &lt;/P&gt;&lt;P&gt;EXEC SQL. &lt;/P&gt;&lt;P&gt;  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT &lt;/P&gt;&lt;P&gt;         WHERE ARG2 = :F3 &lt;/P&gt;&lt;P&gt;ENDEXEC. &lt;/P&gt;&lt;P&gt;WRITE: / F1, F2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, please award me the points as so few people do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Colin. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2004 14:52:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826818#M43202</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-10-07T14:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826819#M43203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't execute this string of Abap statement in Abap. &lt;/P&gt;&lt;P&gt;You can partially have a dynamic statement within your SELECT statement. eq.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT (ftab) from (tabname). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where ftab is an internal table of string which contains '*' and tabname is a string which is the table name 'SPFLI'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also can create a form pool that contains the source code of a subroutine which 'SELECT * FROM SPFLI' is one of the line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Nablan Umar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2004 14:54:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826819#M43203</guid>
      <dc:creator>nablan_umar</dc:creator>
      <dc:date>2004-10-07T14:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826820#M43204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT dynamic_sql_example .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF gt_itab OCCURS 1 ,&lt;/P&gt;&lt;P&gt;line(80) TYPE c ,&lt;/P&gt;&lt;P&gt;END OF gt_itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA gt_restab TYPE .... .&lt;/P&gt;&lt;P&gt;DATA gv_name(30) TYPE c .&lt;/P&gt;&lt;P&gt;DATA gv_err(120) TYPE c .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gt_itab-line = 'REPORT generated_sql .' .&lt;/P&gt;&lt;P&gt;APPEND gt_itab .&lt;/P&gt;&lt;P&gt;gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .&lt;/P&gt;&lt;P&gt;APPEND gt_itab .&lt;/P&gt;&lt;P&gt;gt_itab-line = SQL_STR .&lt;/P&gt;&lt;P&gt;APPEND gt_itab .&lt;/P&gt;&lt;P&gt;gt_itab-line = 'ENDFORM.' .&lt;/P&gt;&lt;P&gt;APPEND gt_itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab&lt;/P&gt;&lt;P&gt;IF FOUND .&lt;/P&gt;&lt;P&gt;WRITE:/ gv_err .&lt;/P&gt;&lt;P&gt;LOOP AT gt_result .&lt;/P&gt;&lt;P&gt;WRITE:/ .... .&lt;/P&gt;&lt;P&gt;ENDLOOP .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Serdar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Oct 2004 19:59:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826820#M43204</guid>
      <dc:creator>ssimsekler</dc:creator>
      <dc:date>2004-10-07T19:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826821#M43205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Serdar Simsekler ,&lt;/P&gt;&lt;P&gt;Your code really helped me,&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Oct 2004 10:45:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826821#M43205</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-10-08T10:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute this SQL Query in ABAP Program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826822#M43206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vinay,&lt;/P&gt;&lt;P&gt;I have similar requirement for dynamic sql query. Can you provide complete code for this on sdn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;R. Singh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 07:06:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-this-sql-query-in-abap-program/m-p/826822#M43206</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-03T07:06:29Z</dc:date>
    </item>
  </channel>
</rss>

