<?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: SELECT Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836187#M664085</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Prabha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is possible to write dynamic select query...&lt;/P&gt;&lt;P&gt;put the table name in brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c_tablename type char5 value 'MARA'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from ( c_tablename ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points for helpful answers.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;hari krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Oct 2007 07:55:24 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-03T07:55:24Z</dc:date>
    <item>
      <title>SELECT Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836183#M664081</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 need to use a variable for the table name in the SELECT query statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say for ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c_tablename type char5  value 'MARA'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from c_tablename.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to do this ? or is there any other way to achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because c_tablename can be any table in SAP .It will be difficult to put in IF/Case statment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 07:26:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836183#M664081</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-03T07:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836184#M664082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,,&lt;/P&gt;&lt;P&gt;chek the sample code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below code might give you some idea:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt;,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;data: dy_table type ref to data,&lt;/P&gt;&lt;P&gt;      dy_line  type ref to data,&lt;/P&gt;&lt;P&gt;      xfc type lvc_s_fcat,&lt;/P&gt;&lt;P&gt;      ifc type lvc_t_fcat.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame.&lt;/P&gt;&lt;P&gt;   parameters: p_table(30) type c default 'T001'.&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&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;   perform get_structure.&lt;/P&gt;&lt;P&gt;   perform create_dynamic_itab.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Creates a dyanamic internal table **&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   perform get_data.&lt;/P&gt;&lt;P&gt;   perform write_out.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;form get_structure.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  data : idetails type abap_compdescr_tab,&lt;/P&gt;&lt;P&gt;         xdetails type abap_compdescr.&lt;/P&gt;&lt;P&gt;  data : ref_table_des type ref to cl_abap_structdescr.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ref_table_des ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  idetails[] = ref_table_des-&amp;gt;components[].&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  loop at idetails into xdetails.&lt;/P&gt;&lt;P&gt;       clear xfc.&lt;/P&gt;&lt;P&gt;       xfc-fieldname = xdetails-name .&lt;/P&gt;&lt;P&gt;       xfc-datatype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;       xfc-inttype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;       xfc-intlen  = xdetails-length." / 2.&lt;/P&gt;&lt;P&gt;       xfc-decimals = xdetails-decimals. " / 2.&lt;/P&gt;&lt;P&gt;       append xfc  to ifc.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;form create_dynamic_itab.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic internal table and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   call method cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;             it_fieldcatalog = ifc&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;             ep_table        = dy_table.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic work area and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   create data dy_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;   assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select Data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * into table &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;     from (p_table).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;form write_out.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Write out data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;       do.&lt;/P&gt;&lt;P&gt;         assign component sy-index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;         if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;            exit.&lt;/P&gt;&lt;P&gt;         endif.&lt;/P&gt;&lt;P&gt;         if sy-index = 1.&lt;/P&gt;&lt;P&gt;            write:/ &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;         else.&lt;/P&gt;&lt;P&gt;            write: &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;         endif.&lt;/P&gt;&lt;P&gt;      enddo.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if u find useful..&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 07:28:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836184#M664082</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2007-10-03T07:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836185#M664083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its acceptable. Jst chk the below cod for ex :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM (gt_con_dbmap_name)&lt;/P&gt;&lt;P&gt;           INTO TABLE lt_sel_ddic_map&lt;/P&gt;&lt;P&gt;           WHERE programm = l_program_map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 07:28:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836185#M664083</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-03T07:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836186#M664084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hI Prabha..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic select query &lt;/P&gt;&lt;P&gt;Eg: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c_tablename type char5 value 'MARA'.&lt;/P&gt;&lt;P&gt;Select * from (c_tablename).  "Table name must be enclosed in brackets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;reward if helpful.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 07:36:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836186#M664084</guid>
      <dc:creator>varma_narayana</dc:creator>
      <dc:date>2007-10-03T07:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836187#M664085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Prabha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is possible to write dynamic select query...&lt;/P&gt;&lt;P&gt;put the table name in brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data c_tablename type char5 value 'MARA'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from ( c_tablename ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points for helpful answers.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;hari krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2007 07:55:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/2836187#M664085</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-03T07:55:24Z</dc:date>
    </item>
  </channel>
</rss>

