<?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 select query with dynamic where condition in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168134#M1516825</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;two observations here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) your target table will have the structure of the table you specify on the selection screen...it is not likely to have the field where you will put the count(*). remove that field from the selection list...and check point (2) below...it should be fine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) i changed your concatenate as follows....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate p_selfl1 ' = ' '''' p_value '''' into ls_where .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try....and think about the first one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Aug 2010 07:23:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-08-12T07:23:34Z</dc:date>
    <item>
      <title>Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168127#M1516818</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;&lt;/P&gt;&lt;P&gt;I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advice, if there is any other way to achieve this requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sanket Sethi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code***************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_tabnam      TYPE tabname,
            p_selfl1      TYPE edpline,
            p_value       TYPE edpline,
            p_where1      TYPE edpline .

DATA: lt_where    TYPE TABLE OF edpline,
      lt_sel_list TYPE TABLE OF edpline,
      l_wa_name   TYPE string,
      ls_where    TYPE edpline,
      l_having    TYPE string,
      dref        TYPE REF TO data,
      itab_type   TYPE REF TO cl_abap_tabledescr,
      struct_type TYPE REF TO cl_abap_structdescr,
      elem_type   TYPE REF TO cl_abap_elemdescr,
      comp_tab    TYPE cl_abap_structdescr=&amp;gt;component_table,
      comp_fld    TYPE cl_abap_structdescr=&amp;gt;component.

TYPES: f_count TYPE i.

FIELD-SYMBOLS : &amp;lt;lt_outtab&amp;gt; TYPE ANY TABLE,
*                &amp;lt;ls_outtab&amp;gt; TYPE ANY,
                &amp;lt;l_fld&amp;gt; TYPE ANY.

struct_type ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_tabnam ).
elem_type   ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'F_COUNT' ).
comp_tab = struct_type-&amp;gt;get_components( ).


comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.

struct_type = cl_abap_structdescr=&amp;gt;create( comp_tab ).
itab_type   = cl_abap_tabledescr=&amp;gt;create( struct_type ).

l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref-&amp;gt;* TO &amp;lt;lt_outtab&amp;gt;.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref-&amp;gt;* TO &amp;lt;ls_outtab&amp;gt;.

* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.

** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
*            INTO ls_where
*            SEPARATED BY space.
*APPEND ls_where TO lt_where.

* Creation of the "where" clause
APPEND p_where1 TO lt_where.

* Creation of the "having" clause
l_having = 'count(*) &amp;gt;= 1'.

* THE dynamic select
SELECT          (lt_sel_list)
       FROM     (p_tabnam)
       INTO CORRESPONDING FIELDS OF TABLE &amp;lt;lt_outtab&amp;gt;.
*       WHERE    (lt_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 06:34:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168127#M1516818</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T06:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168128#M1516819</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;Instead of using CONCATENATE for a Where-Clause in the Select statement, use REPLACE with your field-name and value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lt_where = '&amp;amp; = ''&amp;amp;'' '.
REPLACE '&amp;amp;' WITH field_name INTO lt_where.
REPLACE '&amp;amp;' WITH field_value INTO lt_where.

SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE &amp;lt;lt_outtab&amp;gt;
FROM (p_tabnam)
WHERE (lt_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 06:50:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168128#M1516819</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2010-08-12T06:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168129#M1516820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mahesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply. Actually my Where condition is not working properly. I want to use the below code for where condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EQUNR = '12345'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I use this value in lt_where, it gives me a dump. Do you have any idea on how to use the dynamic where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sanket sethi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:05:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168129#M1516820</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168130#M1516821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i think your dynamic Where table is empty....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what does the error analysis of the dump say??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Priyank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:09:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168130#M1516821</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168131#M1516822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sanket,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above given logic of mine works for you, put the code in the If condition and try-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF NOT P_EBELN IS INITIAL.

lt_where = '&amp;amp; = ''&amp;amp;'' '.
REPLACE '&amp;amp;' WITH p_ebeln INTO lt_where.
REPLACE '&amp;amp;' WITH field_value INTO lt_where.

SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE &amp;lt;lt_outtab&amp;gt;
FROM (p_tabnam)
WHERE (lt_where).

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:11:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168131#M1516822</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2010-08-12T07:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168132#M1516823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priyank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the value (1 Entry) in LT_WHERE  table as EQUNR = '12345'. , but the short dump appears with the following text "Runtime error, short dump could not be written."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:14:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168132#M1516823</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168133#M1516824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Sanket,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please share the values of your selection screen?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Priyank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:17:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168133#M1516824</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168134#M1516825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;two observations here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) your target table will have the structure of the table you specify on the selection screen...it is not likely to have the field where you will put the count(*). remove that field from the selection list...and check point (2) below...it should be fine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) i changed your concatenate as follows....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate p_selfl1 ' = ' '''' p_value '''' into ls_where .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try....and think about the first one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:23:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168134#M1516825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168135#M1516826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the Table name (say EQUI), Field name (Say EQUNR) &amp;amp; value (say 12345) on selection screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have pass the value to the LT_where as EQUNR = '12345'. but it gives the dump for &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; The current ABAP program has tried to execute an Open SQL stateme&lt;/P&gt;&lt;P&gt; which contains a dynamic condition. The part of the condition spe&lt;/P&gt;&lt;P&gt; at runtime is incorrectly parenthesized.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:24:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168135#M1516826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168136#M1516827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check my previous reply...it should work for you...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:29:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168136#M1516827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168137#M1516828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi priyank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have already changed the code as you suggested. But the issue is I have concatenate the period after the value&lt;/P&gt;&lt;P&gt;(E.g.  Equnr = '000000000010000000'.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It throughs the dump      &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; . Anyways thanks for all of you for the valuable suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 07:31:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168137#M1516828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-08-12T07:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic select query with dynamic where condition</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168138#M1516829</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;*CONCATENATE p_selfl1 '= '' p_value ''.'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Remove this dot '.' &lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 15:22:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-select-query-with-dynamic-where-condition/m-p/7168138#M1516829</guid>
      <dc:creator>medas144</dc:creator>
      <dc:date>2020-05-16T15:22:33Z</dc:date>
    </item>
  </channel>
</rss>

