<?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 fields in select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443805#M1248254</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Swetha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the  third select statemnet will work for  you..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
_Dynamic where clause in select query.._

* With a variable, result: AND rbusa = '5145'
concatenate 'AND rbusa = '  ''''  i_tab-zgsber  ''''
append where_clause to where_tab.                                   

* Select
select * from zcostfreq                                            
     where (where_tab).                                               
endselect.

_Using a dynamic table name_

parameters:
 p_tab type tabname.

start-of-selection.
  select count(*) from (p_tab) into l_count.


_Dynamic retrieval and writing of data_

FIELD-SYMBOLS:
  &amp;lt;row&amp;gt;         TYPE ANY,
  &amp;lt;component&amp;gt;   TYPE ANY.

PARAMETERS:
 p_tab TYPE tabname.
 CREATE DATA dataref TYPE (p_tab).

* The variable dataref cannot be accessed directly, so a field symbol is
* used
  ASSIGN dataref-&amp;gt;* TO &amp;lt;row&amp;gt;.

  SELECT *
    FROM (p_tab) UP TO 10 ROWS
    INTO &amp;lt;row&amp;gt;.


    NEW-LINE.
    DO.
*     Write all the fields in the record    
      ASSIGN COMPONENT sy-index
        OF STRUCTURE &amp;lt;row&amp;gt;
        TO &amp;lt;component&amp;gt;.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        EXIT.
      ENDIF.
      WRITE &amp;lt;component&amp;gt;.
    ENDDO.
  ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhduas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Apr 2009 12:48:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-06T12:48:08Z</dc:date>
    <item>
      <title>Dynamic fields in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443803#M1248252</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;   In selection screen we are having period as select option.The values for period are 01 to 16. Based on  &lt;/P&gt;&lt;P&gt;      the values entered in selection screen for period we need to select HSLXX from FAGLFLEXT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   For example if we enter 01 to 03 in selection screen then we need to select HSL01 HSL02 HSL03   &lt;/P&gt;&lt;P&gt;       from FAGLFLEXT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Like this we need to select fields dynamically in select statement. Can any one tell me how to restrict fields dynamically.&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;Swetha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 12:34:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443803#M1248252</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-06T12:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic fields in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443804#M1248253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swetha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at this thread and the Same Topic is discussed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.sdn.sap.com/click.jspa?searchID=24510876&amp;amp;messageID=6133607" target="test_blank"&gt;https://forums.sdn.sap.com/click.jspa?searchID=24510876&amp;amp;messageID=6133607&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 12:41:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443804#M1248253</guid>
      <dc:creator>asik_shameem</dc:creator>
      <dc:date>2009-04-06T12:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic fields in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443805#M1248254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Swetha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the  third select statemnet will work for  you..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
_Dynamic where clause in select query.._

* With a variable, result: AND rbusa = '5145'
concatenate 'AND rbusa = '  ''''  i_tab-zgsber  ''''
append where_clause to where_tab.                                   

* Select
select * from zcostfreq                                            
     where (where_tab).                                               
endselect.

_Using a dynamic table name_

parameters:
 p_tab type tabname.

start-of-selection.
  select count(*) from (p_tab) into l_count.


_Dynamic retrieval and writing of data_

FIELD-SYMBOLS:
  &amp;lt;row&amp;gt;         TYPE ANY,
  &amp;lt;component&amp;gt;   TYPE ANY.

PARAMETERS:
 p_tab TYPE tabname.
 CREATE DATA dataref TYPE (p_tab).

* The variable dataref cannot be accessed directly, so a field symbol is
* used
  ASSIGN dataref-&amp;gt;* TO &amp;lt;row&amp;gt;.

  SELECT *
    FROM (p_tab) UP TO 10 ROWS
    INTO &amp;lt;row&amp;gt;.


    NEW-LINE.
    DO.
*     Write all the fields in the record    
      ASSIGN COMPONENT sy-index
        OF STRUCTURE &amp;lt;row&amp;gt;
        TO &amp;lt;component&amp;gt;.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        EXIT.
      ENDIF.
      WRITE &amp;lt;component&amp;gt;.
    ENDDO.
  ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prabhduas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Apr 2009 12:48:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-fields-in-select-statement/m-p/5443805#M1248254</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-06T12:48:08Z</dc:date>
    </item>
  </channel>
</rss>

