<?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: dynamic sql in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577925#M861295</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 should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data cols type string.

CONCATENATE 'PERNR' p_datapt into cols SEPARATED BY space.

select (cols) from (tabname) ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas Langen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Mar 2008 11:48:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-27T11:48:16Z</dc:date>
    <item>
      <title>dynamic sql</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577924#M861294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In the following dynamic sql query p_datapt is a parameter, so it showing the error as that field doesnot exist in table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   select PERNR p_datapt from (tabname) into corresponding  fields of table &amp;lt;itab1&amp;gt; WHERE begda &amp;lt;= p_endda                 AND endda &amp;gt;= p_begda.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do i handle this..?(that is how to place the field name which is entered by the user at runtime instead of p_datapt).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Eg. If the user enters value for p_datapt as 'SUBTY' we need to select PERNR and SUBTY from the specified table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in this.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Arunsri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 10:41:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577924#M861294</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T10:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic sql</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577925#M861295</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 should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data cols type string.

CONCATENATE 'PERNR' p_datapt into cols SEPARATED BY space.

select (cols) from (tabname) ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas Langen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 11:48:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577925#M861295</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T11:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic sql</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577926#M861296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arunsri,&lt;/P&gt;&lt;P&gt;you could also use an internal table to specify the fields. Here's what you can find in the SAP Help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SELECT \[SINGLE \[FOR UPDATE\] | DISTINCT\] (itab)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Effect&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Works like &lt;STRONG&gt;SELECT \[SINGLE \[FOR UPDATE\] | DISTINCT\] s1 ... sn&lt;/STRONG&gt;, if the internal table &lt;STRONG&gt;itab&lt;/STRONG&gt; contains the list &lt;STRONG&gt;s1 ... sn&lt;/STRONG&gt; as ABAP source code, and works like SELECT \[SINGLE \[FOR UPDATE\] | DISTINCT\] *, if &lt;STRONG&gt;itab&lt;/STRONG&gt; is empty. The internal table &lt;STRONG&gt;itab&lt;/STRONG&gt; may only contain one field, which must have type C and not be longer than 72 characters. You must specify &lt;STRONG&gt;itab&lt;/STRONG&gt; in parentheses. Do not include spaces between the parentheses and the table name. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The same restrictions apply to this variant as to &lt;STRONG&gt;SELECT \[SINGLE \[FOR UPDATE\] | DISTINCT\] s1 ... sn&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Example to display all Lufthansa routes: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA WA_SPFLI    TYPE SPFLI, 
     WA_FTAB(72) TYPE C, 
     FTAB        LIKE TABLE OF WA_FTAB. 

CLEAR FTAB. 
FTAB = 'CITYFROM'. APPEND WA_FTAB TO FTAB. 
FTAB = 'CITYTO'.   APPEND WA_FTAB TO FTAB. 
SELECT DISTINCT (FTAB) 
       INTO CORRESPONDING FIELDS OF WA_SPFLI 
       FROM SPFLI 
       WHERE 
         CARRID   = 'LH'. 
  WRITE: / WA_SPFLI-CITYFROM, WA_SPFLI-CITYTO. 
ENDSELECT. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I hope this helps. Best regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 12:38:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql/m-p/3577926#M861296</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-27T12:38:16Z</dc:date>
    </item>
  </channel>
</rss>

