<?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: where condition with optional fields in a select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059952#M1353809</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;Use AND in WHERE condition. The select query will fetch records even if the optional fields are blank. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Aug 2009 11:39:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-08-26T11:39:41Z</dc:date>
    <item>
      <title>where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059949#M1353806</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 7 optional fields on the selection screen of a Report. While fetching the data from database table, how do we include those optional fields in WHERE condition of the select query?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use AND in WHERE condition of the select query: If I do not enter any values for the optional fields ,it will not fetch any data.&lt;/P&gt;&lt;P&gt; If I use OR : It will fetch wrong(unwanted) entries.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me to sovle this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;sravanthi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:28:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059949#M1353806</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059950#M1353807</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;Is the selection screen fields are SELECT-OPTIONS or PARAMTERS??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always use select-options so that u can get all the records if nothing specified on the screen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also do like this as well&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select-options : s_matnr for mara-matnr no extensions no-intervals. This will look like as paramter only..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now u can use this in select query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara into table itab&lt;/P&gt;&lt;P&gt;         where matnr in s_matnr&lt;/P&gt;&lt;P&gt;         and     mtart in s_mtart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:38:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059950#M1353807</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2009-08-26T11:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059951#M1353808</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;Please use select options names based on your requirement in select statement.&lt;/P&gt;&lt;P&gt;Use AND operation in select statement as select option provides option to exclude or include values.&lt;/P&gt;&lt;P&gt;Also, you can consult functional for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:38:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059951#M1353808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T11:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059952#M1353809</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;Use AND in WHERE condition. The select query will fetch records even if the optional fields are blank. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:39:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059952#M1353809</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T11:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059953#M1353810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;Hi Sravanthi, 
try this way.
&lt;PRE&gt;&lt;CODE&gt;
REPORT ztest.

DATA wa_spfli TYPE spfli.

SELECT-OPTIONS s_airline FOR wa_spfli-carrid NO INTERVALS
                                           NO-EXTENSION. "It looks like parameter. It serves your purpose.
START-OF-SELECTION.
SELECT * FROM SPFLI INTO TABLE IT_SPFLI WHERE AIRLINE IN s_airline.
&lt;/CODE&gt;&lt;/PRE&gt;

Thanks
Venkat.O&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:42:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059953#M1353810</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2009-08-26T11:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059954#M1353811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;pls see the below sample query.&lt;/P&gt;&lt;P&gt;definitely it will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT   vbeln "Quotation no&lt;/P&gt;&lt;P&gt;          erdat " Creation Date&lt;/P&gt;&lt;P&gt;          ernam "Creator&lt;/P&gt;&lt;P&gt;          angdt "Valid From&lt;/P&gt;&lt;P&gt;          bnddt "Valid To&lt;/P&gt;&lt;P&gt;          knumv&lt;/P&gt;&lt;P&gt;          auart "Document type&lt;/P&gt;&lt;P&gt;          audat "Document Date&lt;/P&gt;&lt;P&gt;          vtweg "Distribution channel&lt;/P&gt;&lt;P&gt;          vkorg "Sales Organization&lt;/P&gt;&lt;P&gt;          kunnr "Customer no&lt;/P&gt;&lt;P&gt;          FROM   vbak   INTO  TABLE gt_vbak&lt;/P&gt;&lt;P&gt;          WHERE vbeln IN so_vbeln AND&lt;/P&gt;&lt;P&gt;              erdat IN so_date AND&lt;/P&gt;&lt;P&gt;              auart EQ  text-t20 AND&lt;/P&gt;&lt;P&gt;              vtweg EQ pa_vtweg AND&lt;/P&gt;&lt;P&gt;              vkorg IN so_vkorg.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:46:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059954#M1353811</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T11:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059955#M1353812</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 are saying optional fields are in selection-screen,  To fetch the data from select query you have to give all necessary selection screen fields in where condition either it is a optional or mandatory in selection screen.  If it is the optional selection screen field but if it is necessary to use in where condition you have to use,   if it is optional selection screen field does not give any values to that field,  no  problem it will pulls all records which are matched.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 11:51:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059955#M1353812</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T11:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059956#M1353813</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 use the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF lty_vbeln,&lt;/P&gt;&lt;P&gt;         sign(1) TYPE c,&lt;/P&gt;&lt;P&gt;         option(2) TYPE c,&lt;/P&gt;&lt;P&gt;         low       TYPE vbak-vbeln,&lt;/P&gt;&lt;P&gt;         high      TYPE vbak-vbeln,&lt;/P&gt;&lt;P&gt;       END OF lty_vbeln,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       BEGIN OF lty_erdat,&lt;/P&gt;&lt;P&gt;         sign(1) TYPE c,&lt;/P&gt;&lt;P&gt;         option(2) TYPE c,&lt;/P&gt;&lt;P&gt;         low       TYPE vbak-erdat,&lt;/P&gt;&lt;P&gt;         high      TYPE vbak-erdat,&lt;/P&gt;&lt;P&gt;       END OF lty_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lt_vbeln TYPE STANDARD TABLE OF lty_vbeln,&lt;/P&gt;&lt;P&gt;      lt_erdat TYPE STANDARD TABLE OF lty_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lw_vbeln TYPE lty_vbeln,&lt;/P&gt;&lt;P&gt;      lw_erdat TYPE lty_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT p_vbeln IS INITIAL.&lt;/P&gt;&lt;P&gt;CLEAR lw_vbeln.&lt;/P&gt;&lt;P&gt;lw_vbeln-sign = 'I'.&lt;/P&gt;&lt;P&gt;lw_vbeln-option = 'EQ'.&lt;/P&gt;&lt;P&gt;lw_vbeln-low    = p_vbeln.&lt;/P&gt;&lt;P&gt;APPEND lw_vbeln TO lt_vbeln.&lt;/P&gt;&lt;P&gt;CLEAR lw_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT p_erdat IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR lw_erdat.&lt;/P&gt;&lt;P&gt;lw_erdat-sign = 'I'.&lt;/P&gt;&lt;P&gt;lw_erdat-option = 'EQ'.&lt;/P&gt;&lt;P&gt;lw_erdat-low    = p_erdat.&lt;/P&gt;&lt;P&gt;APPEND lw_erdat TO lt_erdat.&lt;/P&gt;&lt;P&gt;CLEAR lw_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln erdat ....&lt;/P&gt;&lt;P&gt;FROM vbek&lt;/P&gt;&lt;P&gt;INTO TABLE lt_vbak&lt;/P&gt;&lt;P&gt;WHERE vbeln IN lt_vbeln&lt;/P&gt;&lt;P&gt;  AND erdat IN lt_erdat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This always help when you have optional field on screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need more info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Krunal Raichura&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 12:00:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059956#M1353813</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T12:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: where condition with optional fields in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059957#M1353814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use selecti option then you can fetch the data even if you dont enter any value in that field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;select-options: s_matnr for mara-matnr,&lt;/P&gt;&lt;P&gt;                         s_spart for mara-spart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select matnr form mara into table itab&lt;/P&gt;&lt;P&gt;where matnr in s_matnr and&lt;/P&gt;&lt;P&gt;           spart in s_spart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you are using parameter then you need to append the value of parameter into a range table and then use this range table in your select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameter: p_matnr like mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ranges: r_matnr for mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;r_matnr-sign = 'I'.&lt;/P&gt;&lt;P&gt;r_matnr-option = 'EQ'.&lt;/P&gt;&lt;P&gt;r_matnr-low = p_matnr.&lt;/P&gt;&lt;P&gt;appned r_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select matnr form mara into table itab&lt;/P&gt;&lt;P&gt;where matnr in r_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope thie will help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 13:04:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/where-condition-with-optional-fields-in-a-select-statement/m-p/6059957#M1353814</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-08-26T13:04:50Z</dc:date>
    </item>
  </channel>
</rss>

