<?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 SQL with field symbol in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259728#M1986962</link>
    <description>&lt;P&gt;Please use the CODE button when you post code.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 19:42:22 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-10-13T19:42:22Z</dc:date>
    <item>
      <title>Dynamic SQL with field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259727#M1986961</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;my requirement seems a little weird, but maybe you can help me.&lt;/P&gt;
  &lt;P&gt;We have a custom db-table, which comes with two colomns: table and field.&lt;/P&gt;
  &lt;P&gt;In this table (ZB01), the customer has values like KNA1 &amp;amp; NAME1, or KNVV &amp;amp; AUFSD.&lt;/P&gt;
  &lt;P&gt;The customer number is always known.&lt;/P&gt;
  &lt;P&gt;I would like to know, if it is possible to create a dynamic select with dynamic output like:&lt;/P&gt;
  &lt;P&gt;DATA: LT_ZB01 type STANDARD TABLE OF zb01.&lt;/P&gt;
  &lt;P&gt;Select * from zb01 into TABLE lt_zb01.&lt;BR /&gt;&lt;BR /&gt;loop at lt_zb01 ASSIGNING FIELD-SYMBOL(&amp;lt;zb01&amp;gt;).&lt;BR /&gt; &lt;BR /&gt; Select single (&amp;lt;zb01&amp;gt;-FIELD) from (&amp;lt;zb01&amp;gt;-TABLE)&lt;BR /&gt; into @data(lv_var)&lt;BR /&gt; where&lt;BR /&gt; kunnr = '0000030047'.&lt;BR /&gt; ENDLOOP.&lt;/P&gt;
  &lt;P&gt;In this custom table, there could be any table and table-field coming to have being selected.&lt;/P&gt;
  &lt;P&gt;I have tried with creation of "type ref to data" and @data(var) as output, but nothing works.&lt;/P&gt;
  &lt;P&gt;Is this possible? (We are in a S/4HANA environment)&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 17:25:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259727#M1986961</guid>
      <dc:creator>tim82</dc:creator>
      <dc:date>2020-10-13T17:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL with field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259728#M1986962</link>
      <description>&lt;P&gt;Please use the CODE button when you post code.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:42:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259728#M1986962</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-13T19:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL with field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259729#M1986963</link>
      <description>&lt;P&gt;You have to create the data object dynamically:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA dref_field TYPE REF TO data.
FIELD-SYMBOLS &amp;lt;field&amp;gt; TYPE ANY.

CREATE DATA dref_field TYPE (&amp;lt;zb01&amp;gt;-field).
ASSIGN dref_field-&amp;gt;* TO &amp;lt;field&amp;gt;.

Select single (&amp;lt;zb01&amp;gt;-FIELD) 
    from (&amp;lt;zb01&amp;gt;-TABLE)
    into @&amp;lt;field&amp;gt;
    where kunnr = '0000030047'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Of course, handle all exception situations like field is not valid...&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:42:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259729#M1986963</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-13T19:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL with field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259730#M1986964</link>
      <description>&lt;P&gt;Thank your very much, this works!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 19:49:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259730#M1986964</guid>
      <dc:creator>tim82</dc:creator>
      <dc:date>2020-10-13T19:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic SQL with field symbol</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259731#M1986965</link>
      <description>&lt;P&gt;Don't tag your own answer as the correct one, tag  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;'s one.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 10:16:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-sql-with-field-symbol/m-p/12259731#M1986965</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2020-10-15T10:16:25Z</dc:date>
    </item>
  </channel>
</rss>

