<?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: how to create a dynamic field sql? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-dynamic-field-sql/m-p/12184920#M1980154</link>
    <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;loki_luo15&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Something like this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_prstr TYPE i.
PARAMETERS: p_prend TYPE i.

DATA:
  lv_period TYPE n LENGTH 2,
  lt_fields TYPE TABLE OF string.

lv_period = p_prstr.
WHILE lv_period &amp;lt;= p_prend.
  APPEND |HSL{ lv_period }| TO lt_fields.
  lv_period = lv_period + 1.
ENDWHILE.

SELECT (lt_fields)
  FROM faglflext
  INTO TABLE lt_results&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You could also retrieve all HSL fields, for all months and then read the data only from fields for which the period was specified on the selection screen.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;Mateusz</description>
    <pubDate>Mon, 18 May 2020 10:21:34 GMT</pubDate>
    <dc:creator>MateuszAdamus</dc:creator>
    <dc:date>2020-05-18T10:21:34Z</dc:date>
    <item>
      <title>how to create a dynamic field sql?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-dynamic-field-sql/m-p/12184919#M1980153</link>
      <description>&lt;P&gt;I want to query data from faglflext table by given accounting period. In this table each month is a column. like HSL01,HSL02,HSL03....I wonder is it possible to dynamcie create a SQL like select HSL01,HESL02,...from select-options. Such as if I enter accounting period as 3 to 5, then the SQL is select HSL03,HSL04,HSL05...like. I wonder can EXEC be used for that? Thx. &lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 09:48:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-dynamic-field-sql/m-p/12184919#M1980153</guid>
      <dc:creator>former_member625844</dc:creator>
      <dc:date>2020-05-18T09:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a dynamic field sql?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-dynamic-field-sql/m-p/12184920#M1980154</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;loki_luo15&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Something like this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_prstr TYPE i.
PARAMETERS: p_prend TYPE i.

DATA:
  lv_period TYPE n LENGTH 2,
  lt_fields TYPE TABLE OF string.

lv_period = p_prstr.
WHILE lv_period &amp;lt;= p_prend.
  APPEND |HSL{ lv_period }| TO lt_fields.
  lv_period = lv_period + 1.
ENDWHILE.

SELECT (lt_fields)
  FROM faglflext
  INTO TABLE lt_results&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You could also retrieve all HSL fields, for all months and then read the data only from fields for which the period was specified on the selection screen.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;Mateusz</description>
      <pubDate>Mon, 18 May 2020 10:21:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-dynamic-field-sql/m-p/12184920#M1980154</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2020-05-18T10:21:34Z</dc:date>
    </item>
  </channel>
</rss>

