<?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 Dynamic Where clause usage in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795061#M1679543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement where i need to create an FM which basically serves as a search tool. I have 5 input parameters (say EmployeeID ,Name, Address, Phone etc) and will return the same parameters (Result EmployeeID ,Name, Address, Phone) as export. When i give any one input parameter at a time, it is working fine, as i have coded individual blocks for each parameter. However, i need to have a situation where one may input any one or more input parameters &lt;BR /&gt;(say Name and Phone), and need to return the resulting employee(Also incase Employee/Name and phone are not matching, need to return 0/No values).Guess this would need a dynamic select query. Could somebody help me implementing the same, with a similar scenario ?&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;P&gt;Saptarshi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2012 07:42:36 GMT</pubDate>
    <dc:creator>saptarshi_sen</dc:creator>
    <dc:date>2012-06-22T07:42:36Z</dc:date>
    <item>
      <title>Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795061#M1679543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement where i need to create an FM which basically serves as a search tool. I have 5 input parameters (say EmployeeID ,Name, Address, Phone etc) and will return the same parameters (Result EmployeeID ,Name, Address, Phone) as export. When i give any one input parameter at a time, it is working fine, as i have coded individual blocks for each parameter. However, i need to have a situation where one may input any one or more input parameters &lt;BR /&gt;(say Name and Phone), and need to return the resulting employee(Also incase Employee/Name and phone are not matching, need to return 0/No values).Guess this would need a dynamic select query. Could somebody help me implementing the same, with a similar scenario ?&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;P&gt;Saptarshi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 07:42:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795061#M1679543</guid>
      <dc:creator>saptarshi_sen</dc:creator>
      <dc:date>2012-06-22T07:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795062#M1679544</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;Are you selecting all the required data from a single table. If yes, then you can make use of ranges. Based on the input provided by the user to the function module. build your ranges internal table and then use these ranges in select query, in the same way as you use select option with IN operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you. Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kartik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 07:47:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795062#M1679544</guid>
      <dc:creator>Kartik2</dc:creator>
      <dc:date>2012-06-22T07:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795063#M1679545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could build a dynamic where clause or convert parameter to ranges like in following sample :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; DATA: s_kunnr TYPE RANGE OF kna1-kunnr WITH HEADER LINE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_name1 TYPE RANGE OF kna1-name1 WITH HEADER LINE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; DEFINE range_build.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; refresh s_&amp;amp;1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &amp;amp;1 is not initial.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_&amp;amp;1-sign = 'I'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &amp;amp;1 CA '*+'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_&amp;amp;1-option = 'CP'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_&amp;amp;1-option = 'EQ'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s_&amp;amp;1-low = &amp;amp;1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; append s_&amp;amp;1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; END-OF-DEFINITION.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; range_build kunnr.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; range_build name1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; SELECT SINGLE kunnr name1 INTO (kunnr, name1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM kna1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE kunnr IN s_kunnr&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND name1 IN s_name1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; IF sy-subrc NE 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAISE not_found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: courier new,courier;"&gt;&amp;nbsp; ENDIF. &lt;/SPAN&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 08:06:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795063#M1679545</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2012-06-22T08:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795064#M1679546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use select-options or Ranges to fetch data from your table, if its available in a single table.&lt;/P&gt;&lt;P&gt;Alternately, if you know the statement in each case, and teh cases are also well defined, you can store your dynamic where conditions in a variable and use it in teh select.&lt;/P&gt;&lt;P&gt; For eg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If p_1 = 'X'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w_dynamic = ' xref1 = 'Y' '.&lt;/P&gt;&lt;P&gt;elseif p_1 = space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w_dynamic = ' xref1 = space '.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w_dynamic = ' xref1 &amp;lt;&amp;gt; space '.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from bkpf where &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; belnr in so_belnr and &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; gjahr in so_gjahr and&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; ( w_dynamic ).&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; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suzie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 08:10:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795064#M1679546</guid>
      <dc:creator>lijisusan_mathews</dc:creator>
      <dc:date>2012-06-22T08:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795065#M1679547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response Kartik .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using Ranges as well, although in my case i am fetching data from 4 different tables (customer master tables),&amp;nbsp; and things are also working fine on giving one input parameter..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But things are getting complicated when i'm putting in two different parameters, as i am using around 9 input parameters.. Would that need me to define a set of range tables for each parameter block ?&lt;/P&gt;&lt;P&gt;Somehow feel that it's not as complicated as i think, and there's a simpler way out ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Saptarshi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 05:39:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795065#M1679547</guid>
      <dc:creator>saptarshi_sen</dc:creator>
      <dc:date>2012-06-23T05:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795066#M1679548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also use combination of ranges and dynamic sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: l_condition TYPE string.&lt;/P&gt;&lt;P&gt;DATA: l_table TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: p_matnr TYPE RANGE OF ekpo-matnr.&lt;/P&gt;&lt;P&gt;DATA: p_matnr_ld LIKE LINE OF p_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p_matnr_ld-sign = 'I'.&lt;BR /&gt;p_matnr_ld-low = '0000000012345'.&lt;BR /&gt;p_matnr_ld-option = 'EQ'.&lt;BR /&gt;APPEND p_matnr_ld TO p_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE 'ekpo' TO l_table.&lt;/P&gt;&lt;P&gt;CONCATENATE l_table&amp;nbsp; '~matnr IN p_matnr' INTO l_condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM (l_table)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; TABLE lt_xxxx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE (l_condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 07:11:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795066#M1679548</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-06-27T07:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Where clause usage</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795067#M1679549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Simo, this seems to suit the requirement..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2012 13:19:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-where-clause-usage/m-p/8795067#M1679549</guid>
      <dc:creator>saptarshi_sen</dc:creator>
      <dc:date>2012-06-29T13:19:29Z</dc:date>
    </item>
  </channel>
</rss>

