<?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: Field selection at runtime in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087907#M977405</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;you can do with the below way,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;         field(6),&lt;/P&gt;&lt;P&gt;         end of itab.&lt;/P&gt;&lt;P&gt;data : field(5).&lt;/P&gt;&lt;P&gt;itab-field = field1.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;itab-field = field2.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;itab-field = field3.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;   field = itab-field.&lt;/P&gt;&lt;P&gt;   SELECT * FROM ZTAB WHERE (FIELD) EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Jul 2008 06:59:12 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-02T06:59:12Z</dc:date>
    <item>
      <title>Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087903#M977401</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 large number of very similar select statements run on the same (custom) DDIC table. Each select statement uses a different field of the table in the where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table fields: FIELD1, FIELD2, FIELD3, ..., FIELDN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE FIELD1 EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;   ...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE FIELD2 EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;   ...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE FIELD3 EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;   ...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SEARCH_KEY is a local text field. Rather than copying the identical code several times and changing the selection field in where each time, is there any method for dynamically determining the field at runtime? I.e. is there a way to replace these multiple select statements with a single select statement like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE FIELD EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;   ...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where FIELD can be determined to be any of FIELD1, FIELD2,... FIELDN?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to put the select statement in a subroutine and just call it with whatever field is required. Is this possible? If so, how? Help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 06:33:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087903#M977401</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-02T06:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087904#M977402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Pls try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: str type string.&lt;/P&gt;&lt;P&gt;Concatenate 'FIELD1'  'EQ SEARCH_KEY'&lt;/P&gt;&lt;P&gt;    into str.&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE (str)&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can concatenate FieldX to str.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 06:43:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087904#M977402</guid>
      <dc:creator>pole_li</dc:creator>
      <dc:date>2008-07-02T06:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087905#M977403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use dynamic fields :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE (FIELD) EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now (FIELD) can contain FIELD1 FIELD2 etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 06:45:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087905#M977403</guid>
      <dc:creator>Azeemquadri</dc:creator>
      <dc:date>2008-07-02T06:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087906#M977404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ws_where              TYPE string.               "Workarea for the where cond.&lt;/P&gt;&lt;P&gt;DATA: wtab                  LIKE TABLE OF ws_where.    "Table for the where cond.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate (FIELD1) '=' SEARCH_KEY into ws_where separated by space.&lt;/P&gt;&lt;P&gt;append ws_where to w_tab.&lt;/P&gt;&lt;P&gt;SELECT * FROM ZTAB WHERE (wtab) .&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Subramanian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 06:48:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087906#M977404</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-02T06:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087907#M977405</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;you can do with the below way,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;         field(6),&lt;/P&gt;&lt;P&gt;         end of itab.&lt;/P&gt;&lt;P&gt;data : field(5).&lt;/P&gt;&lt;P&gt;itab-field = field1.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;itab-field = field2.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;itab-field = field3.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;   field = itab-field.&lt;/P&gt;&lt;P&gt;   SELECT * FROM ZTAB WHERE (FIELD) EQ SEARCH_KEY&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 06:59:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087907#M977405</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-02T06:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087908#M977406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt; You create a sub routine and pass the field name and search key as input parameters and follow this code, here p1 is the searchkey and ws_fieldname is the fieldname&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters : p1 type vbak-vbeln.&lt;/P&gt;&lt;P&gt;data: ws_field_name(50) type c value 'vbeln = ',&lt;/P&gt;&lt;P&gt;      itab1 like standard table of ws_field_name,&lt;/P&gt;&lt;P&gt;      itab2 like line of itab1,&lt;/P&gt;&lt;P&gt;      itab type standard table of vbak.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate ws_field_name '''' p1 '''' into itab2.&lt;/P&gt;&lt;P&gt;append itab2 to itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Select * from vbak&lt;/P&gt;&lt;P&gt;            into corresponding fields of table itab&lt;/P&gt;&lt;P&gt;            where  (itab1).&lt;/P&gt;&lt;P&gt;********************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful.&lt;/P&gt;&lt;P&gt;Divya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 07:42:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087908#M977406</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-02T07:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Field selection at runtime</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087909#M977407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Azeem,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply. Could you post some example code? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2008 09:24:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/field-selection-at-runtime/m-p/4087909#M977407</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-02T09:24:30Z</dc:date>
    </item>
  </channel>
</rss>

