<?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: Dinamic Select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dinamic-select/m-p/5883369#M1325277</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;it_selopt-value = '''Hello'''.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2009 12:26:53 GMT</pubDate>
    <dc:creator>ThomasZloch</dc:creator>
    <dc:date>2009-07-08T12:26:53Z</dc:date>
    <item>
      <title>Dinamic Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dinamic-select/m-p/5883368#M1325276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;I am trying to do a dynamic select in which I don´t know which are going to be the conditions of the clause WHERE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF it_selopt OCCURS 0,
        field      TYPE string,
        value      TYPE string,
      END OF it_selopt,
      wa_selopt LIKE LINE OF it_selopt.

DATA cond_syntax TYPE string.

                ............

it_selopt-field = 'MATNR'.
it_selopt-value = 'Hello'.
APPEND it_selopt.


LOOP AT it_selopt.
  wa_selopt = it_selopt.

* First condition
  AT FIRST.
       CONCATENATE wa_selopt-field '=' wa_selopt-value
         INTO cond_syntax SEPARATED BY space.
    CONTINUE.  "
  ENDAT.
* Other conditions  
       CONCATENATE cond_syntax 'AND' wa_selopt-field '=' wa_selopt-value
            INTO cond_syntax SEPARATED BY space.
ENDLOOP.


TRY. 
    SELECT SINGLE * 
           FROM eban 
           WHERE (cond_syntax). 

  CATCH cx_sy_dynamic_osql_error. 
    MESSAGE `Wrong WHERE condition!` TYPE 'I'. 
ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that in runtime gives a syntax error for the following thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In runtime the variable cond_syntax has the following:  MATNR = Hello&lt;/P&gt;&lt;P&gt;And it should have this: MATNR = 'Hello'&lt;/P&gt;&lt;P&gt;within quotation marks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because if it does not take Hello as if it was a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I have tried the following thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: field_2_read TYPE string.
  DATA: d_tabix TYPE n.

  LOOP AT it_selopt.
       wa_selopt = it_selopt.
       d_tabix = sy-tabix.
       CONCATENATE 'IT_SELOPT[' d_tabix ']-low' INTO field_2_read.

* First condition
       AT FIRST.
          CONCATENATE wa_selopt-field '=' field_2_read  
            INTO cond_syntax SEPARATED BY space.
          CONTINUE.
       ENDAT.

* Other conditions  
       CONCATENATE cond_syntax 'AND' wa_selopt-field '=' field_2_read 
            INTO cond_syntax SEPARATED BY space.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it continues giving me a error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2009 12:24:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dinamic-select/m-p/5883368#M1325276</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-08T12:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dinamic Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dinamic-select/m-p/5883369#M1325277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;it_selopt-value = '''Hello'''.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2009 12:26:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dinamic-select/m-p/5883369#M1325277</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2009-07-08T12:26:53Z</dc:date>
    </item>
  </channel>
</rss>

