<?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 How Can I reconstruct the SQL in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821100#M918963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are using SAP DB + 46C on Unix machine, I used to run the following SQL command on SAP DB directly , how can I reconstruct the same SQL to work in ABAP report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SRTFD, COUNT(*), MAX(SRTF2) FROM INDX&lt;/P&gt;&lt;P&gt;WHERE RELID = 'SD'&lt;/P&gt;&lt;P&gt;GROUP BY SRTFD&lt;/P&gt;&lt;P&gt;HAVING COUNT(*)=1&lt;/P&gt;&lt;P&gt;AND MAX(SRTF2) != 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 May 2008 14:31:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-15T14:31:01Z</dc:date>
    <item>
      <title>How Can I reconstruct the SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821100#M918963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are using SAP DB + 46C on Unix machine, I used to run the following SQL command on SAP DB directly , how can I reconstruct the same SQL to work in ABAP report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SRTFD, COUNT(*), MAX(SRTF2) FROM INDX&lt;/P&gt;&lt;P&gt;WHERE RELID = 'SD'&lt;/P&gt;&lt;P&gt;GROUP BY SRTFD&lt;/P&gt;&lt;P&gt;HAVING COUNT(*)=1&lt;/P&gt;&lt;P&gt;AND MAX(SRTF2) != 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 14:31:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821100#M918963</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T14:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I reconstruct the SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821101#M918964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use the command EXEC.&lt;/P&gt;&lt;P&gt;&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;DATA: BEGIN OF WA, &lt;/P&gt;&lt;P&gt;        CLIENT(3), ARG1(3), ARG2(3), &lt;/P&gt;&lt;P&gt;      END OF WA. &lt;/P&gt;&lt;P&gt;DATA  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 :WA 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: / WA-CLIENT, WA-ARG1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Native SQL supports the directly-executable commands of your underlying database system. There are other special commands that you can use after the EXEC SQL statement for cursor handling, stored procedures (procedures stored in the database), and connections to other databases.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 14:54:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821101#M918964</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T14:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I reconstruct the SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821102#M918965</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;Everything you're using in your query including the COUNT, MAX, GROUP BY and HAVING can also be used in ABAP Open SQL, so a few minor changes should be sufficient to convert the code to Open SQL. At least this is the case in our 4.7 system; every upgrade seems to have added added extra functionality to Open SQL so it is possible that not all are available in 4.6C, in which case you'll have to use EXEC SQL. Anyway, try this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ls_indx,&lt;/P&gt;&lt;P&gt;        srtfd TYPE indx-srtfd,&lt;/P&gt;&lt;P&gt;        xcount TYPE I,&lt;/P&gt;&lt;P&gt;        max_srtf2 TYPE indx-srtf2,&lt;/P&gt;&lt;P&gt;      END OF ls_indx,&lt;/P&gt;&lt;P&gt;      lt_indx LIKE TABLE OF ls_indx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SRTFD  COUNT( * )&lt;/P&gt;&lt;P&gt;       MAX( SRTF2 )&lt;/P&gt;&lt;P&gt;INTO TABLE lt_indx&lt;/P&gt;&lt;P&gt;FROM INDX&lt;/P&gt;&lt;P&gt;WHERE RELID = 'SD'&lt;/P&gt;&lt;P&gt;GROUP BY SRTFD&lt;/P&gt;&lt;P&gt;HAVING COUNT( * ) = 2&lt;/P&gt;&lt;P&gt;AND MAX( SRTF2 ) &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpfull...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Ameen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2008 06:13:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-reconstruct-the-sql/m-p/3821102#M918965</guid>
      <dc:creator>former_member515797</dc:creator>
      <dc:date>2008-05-16T06:13:44Z</dc:date>
    </item>
  </channel>
</rss>

