<?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: Creating and running Query dynamically. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024512#M1168970</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;check this link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/creating" target="test_blank"&gt;https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/creating&lt;/A&gt;&lt;EM&gt;Flat&lt;/EM&gt;and&lt;EM&gt;Complex&lt;/EM&gt;Internal&lt;EM&gt;Tables&lt;/EM&gt;Dynamically&lt;EM&gt;using&lt;/EM&gt;RTTI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Santosh Thorat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Jan 2009 06:46:50 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-06T06:46:50Z</dc:date>
    <item>
      <title>Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024511#M1168969</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;This is my first post here with a hope that I will get my problem resolved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a query to give me internal table using the table name. This logic will be used for some other work I have to accomplish.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am selecting the field names from the table DD03L for my Z-table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT * FROM dd03l into corresponding fields of table mytable
WHERE tabname = 'ZMS_MCLINT'.
sort mytable by position.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, based on the fields selected I will create a select query&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
QueryStr = 'Select'.
assign QueryStr to &amp;lt;fs&amp;gt;.
Loop at mytable.
  if not mytable-fieldname(1) = '.'.
    concatenate &amp;lt;fs&amp;gt; mytable-fieldname into &amp;lt;fs&amp;gt; separated by SPACE .
  endif.
endloop.
concatenate &amp;lt;fs&amp;gt; 'from ' mytable-fieldname 'into table itab.' into &amp;lt;fs&amp;gt; separated by SPACE .
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will give me the result as&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Select MANDT CLCODE CLNAME ADDRESS1 ADDRESS2 ADDRESS3 AREA CITY PINCODE from PINCODE into table itab
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now My requirement is to execute the query which i have build on the fly to get the data into iTAB. How can I execute the query which is assigned in field symbol &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is any other logic also its welcome.&lt;/P&gt;&lt;P&gt;&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;Munir Solkar (MS)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 06:42:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024511#M1168969</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T06:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024512#M1168970</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;check this link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/creating" target="test_blank"&gt;https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/creating&lt;/A&gt;&lt;EM&gt;Flat&lt;/EM&gt;and&lt;EM&gt;Complex&lt;/EM&gt;Internal&lt;EM&gt;Tables&lt;/EM&gt;Dynamically&lt;EM&gt;using&lt;/EM&gt;RTTI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Santosh Thorat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 06:46:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024512#M1168970</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T06:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024513#M1168971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear &lt;STRONG&gt;+Santosh,&lt;/STRONG&gt;+&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quick response.&lt;/P&gt;&lt;P&gt;That was really helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;MS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 07:06:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024513#M1168971</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T07:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024514#M1168972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above link is applicable for only a single table. What if we have to extract fields dynamically from two different tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my requirement is as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to display fields from VBAK and VBAP tables with relation as VBAK-VBELN = VBAP-VBELN.&lt;/P&gt;&lt;P&gt;A separate table is created Z_IF_FIELDS to store the columns required to be displayed for a particular report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Report Name           Position          Column Name
SO_REPORT              1                 VBAK-VBELN
SO_REPORT              2                 VBAP-POSNR
SO_REPORT              3                 VBAP-MATNR
SO_REPORT              4                 VBAP-KWMENG
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program should fetch only above fields from two tables mentioned (vbak, vbap) in an internal table and display the result as an output to the user (either list view and ALV).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly help at the earliest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;MS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 09:21:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024514#M1168972</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T09:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024515#M1168973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need help for multiple tables&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 09:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024515#M1168973</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T09:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024516#M1168974</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;Instead of forming the whole query through concatenation,  concatenate only the fieldnames.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then pass it in the query as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at mytable.&lt;/P&gt;&lt;P&gt;  if not wa_mytable-fieldname(1) = '.'.&lt;/P&gt;&lt;P&gt;    concatenate &amp;lt;fields&amp;gt; wa_mytable-fieldname into fields separated by SPACE .&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select &amp;lt;fields&amp;gt; from into into table itab .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;K.Tharani.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 09:58:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024516#M1168974</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T09:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating and running Query dynamically.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024517#M1168975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Store your filed names separately then use it like,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select (fileds) from (table) into table itab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manoj Kumar P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jan 2009 10:08:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/creating-and-running-query-dynamically/m-p/5024517#M1168975</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-06T10:08:04Z</dc:date>
    </item>
  </channel>
</rss>

