<?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: Cannot use alias for dynamic column name in SELECT statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284590#M1388871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just remove INTO CORRESPONDING FIELDS OF TABLE to INTO TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT (col_name) INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT (col_name) INTO TABLE it_values FROM (tbl_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Nov 2009 14:03:46 GMT</pubDate>
    <dc:creator>SuhaSaha</dc:creator>
    <dc:date>2009-11-03T14:03:46Z</dc:date>
    <item>
      <title>Cannot use alias for dynamic column name in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284589#M1388870</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 want to retrieve values from several tables by using dynamic column &amp;amp; table name as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: tbl_name(30) TYPE c VALUE '/bic/tbi_srcsys',  " staticly initialized for this example
           col_name(30) TYPE c VALUE '/bic/bi_srcsys'.  " staticly initialized for this example

SELECT (col_name) INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The internal table "it_values" does not contain a field named "/bic/bi_srcsys", instead it has another generic field "value" so that the above code can be applied to other tables. I tried to use alias (AS) as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT (col_name) AS value INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this cannot work. I know that there are other ways to solve this problem, such as by using a single field in SELECT .. ENDSELECT and subsequently appending it to the work area and internal table as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT (col_name)  INTO (lv_value) FROM (tbl_name).
  wa_value-value = lv_value.
  APPEND wa_value TO it_values.
ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wonder if there is any other more elegant workaround, because I might have several other fields instead of only one?&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;Regards,&lt;/P&gt;&lt;P&gt;Joon Meng&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Nov 2009 14:00:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284589#M1388870</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-03T14:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use alias for dynamic column name in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284590#M1388871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just remove INTO CORRESPONDING FIELDS OF TABLE to INTO TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT (col_name) INTO CORRESPONDING FIELDS OF TABLE it_values FROM (tbl_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT (col_name) INTO TABLE it_values FROM (tbl_name).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Nov 2009 14:03:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284590#M1388871</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2009-11-03T14:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use alias for dynamic column name in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284591#M1388872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suhas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the quick reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry that I have not well described the structure of the internal table "it_values". This internal table contains several other fields (key, type, value, etc.). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess that the following code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT (col_name) INTO TABLE it_values FROM (tbl_name).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;works if the internal table only has one field (value) or the field "value" is in the first position, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, I need to fill the "value" field of internal table it_values (ignore the other fields like type, key) with values retrieved from (col_name) of the DDIC table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking forward to your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Joon Meng&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Nov 2009 14:24:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284591#M1388872</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-03T14:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use alias for dynamic column name in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284592#M1388873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Were you able to find a solution for this? I am in a similar situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Puja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 16:40:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cannot-use-alias-for-dynamic-column-name-in-select-statement/m-p/6284592#M1388873</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-24T16:40:21Z</dc:date>
    </item>
  </channel>
</rss>

