<?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 select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621969#M1280522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Abeehs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please Don't Post Duplicate Posts and also Search Before Posting&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check [Dynamic Select Statement|&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1240593"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 May 2009 08:45:17 GMT</pubDate>
    <dc:creator>faisalatsap</dc:creator>
    <dc:date>2009-05-14T08:45:17Z</dc:date>
    <item>
      <title>dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621966#M1280519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I need to have a select query in dynamically for eg . i need to select the fields of the table dynamically using the select query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 08:30:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621966#M1280519</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T08:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621967#M1280520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Don't violate forum rules with duplicate posts&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 08:31:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621967#M1280520</guid>
      <dc:creator>GauthamV</dc:creator>
      <dc:date>2009-05-14T08:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621968#M1280521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your requirement is not clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Put in more details for an appropriate suggestion or solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhinab Mishra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 08:41:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621968#M1280521</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T08:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621969#M1280522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Abeehs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Please Don't Post Duplicate Posts and also Search Before Posting&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check [Dynamic Select Statement|&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1240593"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 08:45:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621969#M1280522</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-05-14T08:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621970#M1280523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhinab,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have two parameters in which you give a number and table name as input. Watever this number in the parameter is, i need to fetch those many fields from the relevant table. (eg. if the number entered is 5 and table entered is mara i need to display the the first 5 fields of the mara table)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 09:05:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621970#M1280523</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T09:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621971#M1280524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhinab,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have two parameters in which you give a number and table name as input. Watever this number in the parameter is, i need to fetch those many fields from the relevant table. (eg. if the number entered is 5 and table entered is mara i need to display the the first 5 fields of the mara table)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 09:06:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621971#M1280524</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T09:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621972#M1280525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abhees,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this code helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
parameters: p_fld1 type fieldname,
            p_tab1 type tabname.

types: begin of tp_table,
        field type string,
       end of tp_table.

data: t_table type standard table of tp_table.

select (p_fld1)
  from (p_tab1)
  into table t_table
  up to 1 rows.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 09:36:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621972#M1280525</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T09:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621973#M1280526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES:
  DD02L, DD03L.
PARAMETERS:
  P_I TYPE I,
  P_TABle(30) TYPE C.
type-pools : abap.
  field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,
               &amp;lt;dyn_wa&amp;gt;,
               &amp;lt;dyn_field&amp;gt;.
  data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.
DATA:
  BEGIN OF TABSTRUC OCCURS 0,
  FIELDNAME LIKE DD03L-FIELDNAME,
  POSITION LIKE DD03L-POSITION,
  END OF TABSTRUC.
DATA: FIELDSTR TYPE STRING.
DATA: T_TABLE TYPE STANDARD TABLE OF TP_TABLE.
data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.
  data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
  ref_table_des ?=
      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).
  idetails[[] = ref_table_des-&amp;gt;components[]].
    loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-inttype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
  endloop.
SELECT FIELDNAME POSITION INTO TABLE TABSTRUC FROM DD03L
  WHERE TABNAME = P_TABle
    AND ROLLNAME NE SPACE.
SORT TABSTRUC BY POSITION.
P_I = P_I + 1.
DELETE TABSTRUC FROM P_I.
LOOP AT TABSTRUC.
CONCATENATE FIELDSTR TABSTRUC-FIELDNAME INTO FIELDSTR SEPARATED BY
SPACE.
ENDLOOP.
delete ifc from p_i.
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=&amp;gt;create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.
    assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.
* Create dynamic work area and assign to FS
  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.
  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.
* Select Data from table.
  select (FIELDSTR) into table &amp;lt;dyn_table&amp;gt;
             from (p_table).
* Write out data from table.
  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.
    do.
      assign component  sy-index
         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ &amp;lt;dyn_field&amp;gt;.
      else.
        write: &amp;lt;dyn_field&amp;gt;.
      endif.
    enddo.
  endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have modified the original Source  Code to satisfy your requirement : &lt;A href="https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/dynamic" target="test_blank"&gt;https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/dynamic&lt;/A&gt;&lt;EM&gt;Internal&lt;/EM&gt;table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 10:05:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621973#M1280526</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T10:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621974#M1280527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data : sel1 type table of edpline.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if proj-vbukr eq '4200' or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;        &lt;EM&gt;proj-vbukr eq '4100' or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;        &lt;EM&gt;proj-vbukr eq '4400' or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;        &lt;EM&gt;proj-vbukr eq '4300' or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;        &lt;EM&gt;proj-vbukr eq '4800'.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        &lt;EM&gt;append&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;       &lt;EM&gt;'BUKRS HKONT GJAHR BELNR BUDAT BLART SHKZG DMBTR PROJK' to sel1.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt; &lt;EM&gt;else.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;EM&gt;append&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;      &lt;EM&gt;'BUKRS HKONT GJAHR BELNR BUDAT BLART SHKZG WRBTR PROJK' to sel1.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;select (sel1)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;       &lt;EM&gt;from bsis into corresponding fields of table i_final1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                        &lt;EM&gt;for all   entries in i_prps&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                        &lt;EM&gt;where projk eq i_prps-pspnr and&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                              &lt;EM&gt;bukrs in s_bukrs and&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                              &lt;EM&gt;gjahr in s_gjahr and&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                              &lt;EM&gt;blart in s_blart and&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;                                              &lt;EM&gt;budat in s_budat.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2009 10:19:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query/m-p/5621974#M1280527</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-14T10:19:17Z</dc:date>
    </item>
  </channel>
</rss>

