<?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: SELECT command with variables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094438#M1705460</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one sample program, here columns are variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_dynamic_columns .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE STANDARD TABLE OF spfli,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wa LIKE LINE OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: line(72) TYPE c,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list LIKE TABLE OF line(72).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line = ' CITYFROM CITYTO '.&lt;/P&gt;&lt;P&gt;APPEND line TO list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (list)&lt;/P&gt;&lt;P&gt;&amp;nbsp; INTO CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM spfli.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOOP AT itab INTO wa.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WRITE: / wa-cityfrom, wa-cityto.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Oct 2012 11:39:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-10-04T11:39:32Z</dc:date>
    <item>
      <title>SELECT command with variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094437#M1705459</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 have a program where the user enters a number of tables and a number of fields (existing SAP fields) into the selection screen.&lt;/P&gt;&lt;P&gt;In an INCLUDE structure, I have a SELECT command that will simply connect these tables (currently using JOINs) and fetch all these fields and put them into an internal table.&lt;/P&gt;&lt;P&gt;The SELECT currently looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNC1~KUNNR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNC1~BUKRS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNC1~GJAHR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNB1~AKONT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNA1~KUNNR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNA1~NAME1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNA1~NAME2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNA1~ORT01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KNA1~ERNAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; T001~BUTXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; T001~WAERS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FROM KNC1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN KNB1 ON KNB1~KUNNR = KNC1~KUNNR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND KNB1~BUKRS = KNC1~BUKRS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN KNA1 ON KNA1~KUNNR = KNC1~KUNNR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN T001 ON T001~BUKRS = KNC1~BUKRS&lt;/P&gt;&lt;P&gt;INTO TABLE &amp;lt;F_TABLE&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the long run, I have to use the variables I get from the selection screen for both the fields and the tables, but I have to start somewhere plus I think the solution is quite similar: First, I just want to somehow use those field-variables in the SELECT (I already have them in the form [table]~[field]). The idea is that, since I do not know how many fields there might be, I will concatenate them into one field_list (KNC1~KUNNR KNC1~BUKRS ...) and use that in the SELECT.&lt;/P&gt;&lt;P&gt;Can anybody give me a hint on how to do this? Field-symbols don't seem to work - or I haven't yet found out how: I can declare them and assign the correct value to them and, when viewed in the debugger, they look all right, but the SELECT does not want to know about them.&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sapperdapper&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 11:31:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094437#M1705459</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-10-04T11:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT command with variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094438#M1705460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one sample program, here columns are variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_select_dynamic_columns .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: itab TYPE STANDARD TABLE OF spfli,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wa LIKE LINE OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: line(72) TYPE c,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list LIKE TABLE OF line(72).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line = ' CITYFROM CITYTO '.&lt;/P&gt;&lt;P&gt;APPEND line TO list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (list)&lt;/P&gt;&lt;P&gt;&amp;nbsp; INTO CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM spfli.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOOP AT itab INTO wa.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WRITE: / wa-cityfrom, wa-cityto.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 11:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094438#M1705460</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-10-04T11:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT command with variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094439#M1705461</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 will close this and mark it as "Assumed answered". I have now fully dynamized the SELECT statement and the joins between all the tables involved and I haven't yet found a scenario where it doesn't work. Well, I'll have to do some testing and if I don't find one, the user is sure to find some scenario that will break my code &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for all the help!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sapperdapper&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2012 07:02:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-command-with-variables/m-p/9094439#M1705461</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-10-23T07:02:43Z</dc:date>
    </item>
  </channel>
</rss>

