<?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: ST05 - Explain SQL in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974714#M70583</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr from &lt;/P&gt;&lt;P&gt;vbak as a join vbap as b &lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;vbeln eq b&lt;/SUB&gt;vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;PJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Sep 2005 07:34:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-09-15T07:34:16Z</dc:date>
    <item>
      <title>ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974710#M70579</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 want to try out different kinds of sql-statements inside ST05.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now:&lt;/P&gt;&lt;P&gt;This doesn't work:&lt;/P&gt;&lt;P&gt;SELECT VBAK~VBELN FROM VBAK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;SELECT VBELN FROM VBAK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to get the first option to work as well. Mainly because I want to make some inner join stuff...&lt;/P&gt;&lt;P&gt;Any pointers ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 05:39:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974710#M70579</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-15T05:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974711#M70580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's right, you only use the '~' when you do joins. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbak~vbeln from vbak&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is not a join&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of tbl_vbak occurs 0,
        vbeln  like vbak-vbeln,
        posnr  like vbap-posnr,
      end of tbl_vbak.

select vbak~vbeln
       vbap~posnr
       into table tbl_vbak
       from vbak
       inner join vbap
       on vbak~vbeln = vbap~vbeln.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 05:44:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974711#M70580</guid>
      <dc:creator>former_member221770</dc:creator>
      <dc:date>2005-09-15T05:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974712#M70581</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;Let me put it this way:&lt;/P&gt;&lt;P&gt;Could you make a sql join between VBAK and VBAP that works in ST05.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to use the EXPLAIN button in ST05 in order to see the index hit etc...&lt;/P&gt;&lt;P&gt;//Martin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Martin Andersson&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:21:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974712#M70581</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-15T07:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974713#M70582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think you can "join" VBAK and VBAK. Doesn't make much sense to me. Why would you want to join a database table to itself?&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;Pat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:27:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974713#M70582</guid>
      <dc:creator>former_member221770</dc:creator>
      <dc:date>2005-09-15T07:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974714#M70583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a&lt;SUB&gt;vbeln b&lt;/SUB&gt;posnr from &lt;/P&gt;&lt;P&gt;vbak as a join vbap as b &lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;vbeln eq b&lt;/SUB&gt;vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;PJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:34:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974714#M70583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-15T07:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974715#M70584</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;This doesn't work in ST05.&lt;/P&gt;&lt;P&gt;(First of all you need to write sql in UPPER CASE...)&lt;/P&gt;&lt;P&gt;//MA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:39:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974715#M70584</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-15T07:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974716#M70585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this bit of ABAP:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of tbl_vbak occurs 0,
        order1  like vbak-vbeln,
        order2  like vbak-vbeln,
      end of tbl_vbak.

select t1~vbeln t2~vbeln
       into table tbl_vbak
       from vbak as t1
       inner join vbak as t2
       on t1~vbeln = t2~vbeln.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:43:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974716#M70585</guid>
      <dc:creator>former_member221770</dc:creator>
      <dc:date>2005-09-15T07:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974717#M70586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oops, ignore my last post - i just saw your edited message....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:44:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974717#M70586</guid>
      <dc:creator>former_member221770</dc:creator>
      <dc:date>2005-09-15T07:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974718#M70587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you put this sample code in a ABAP program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: begin of tbl_vbak occurs 0,
        vbeln  like vbak-vbeln,
        posnr  like vbap-posnr,
      end of tbl_vbak.
 
select vbak~vbeln
       vbap~posnr
       into table tbl_vbak
       from vbak
       inner join vbap
       on vbak~vbeln = vbap~vbeln.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then run ST05 to activate the trace, run your program, deactivate the trace, then view the trace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look for the VBAK PREPARE line and click onit and hit Explain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will see at the bottom a little tree structure. It will identify the index hit here (in this case VBAK&lt;SUB&gt;0 and VBAP&lt;/SUB&gt;0).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will also see the parsed SQL statement on the top half of the screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this answers your question.&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;Pat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:51:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974718#M70587</guid>
      <dc:creator>former_member221770</dc:creator>
      <dc:date>2005-09-15T07:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974719#M70588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ST05-Explain you have to use (something like) native SQL. I copied statement from an explain of a trace:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  * FROM   "USR21" 
WHERE "MANDT" = :A0 AND "BNAME" = :A1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and replaced the variables with some values (shown in the list below):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  * FROM   "USR21" WHERE "MANDT" = "200" AND "BNAME" = "MY_USER"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I'm also able to make new statements 'from scratch':&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM "VBAK"
WHERE   "MANDT" = '200' AND "VBELN" = '000000616'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just write your statement in a test report (local) in development system, make a trace, copy this in your production (or test) system and replace the variables accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess, the syntax might be DB dependent, but by this way that's not a problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 07:56:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974719#M70588</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-09-15T07:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974720#M70589</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;We are getting there....&lt;/P&gt;&lt;P&gt;Let me clarify.&lt;/P&gt;&lt;P&gt;Goto ST05.&lt;/P&gt;&lt;P&gt;Click "Enter SQL Statement"&lt;/P&gt;&lt;P&gt;Paste in our sql join statement.&lt;/P&gt;&lt;P&gt;Click Explain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT VBELN FROM VBAK -- works fine&lt;/P&gt;&lt;P&gt;SELECT X_VBAK~VBELN FROM VBAK AS X_VBAK  -- no explain here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem we are having is how do we handle alias in ST05....?&lt;/P&gt;&lt;P&gt;//MA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 08:08:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974720#M70589</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-09-15T08:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: ST05 - Explain SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974721#M70590</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;so a join as example brings this result:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT
  T_00 . "VBELN"
FROM
  "VBAK" T_00 , "VBAP" T_01
WHERE
  ( T_01 . "MANDT" = :A0 AND T_00 . "VBELN" = T_01 . "VBELN" ) AND T_00 . "MANDT" = :A1 AND T_00 .
  "VBELN" &amp;gt; :A2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- and without join no explicit definition is possible (or would make sense).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2005 08:27:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/st05-explain-sql/m-p/974721#M70590</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-09-15T08:27:49Z</dc:date>
    </item>
  </channel>
</rss>

