<?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: Checking conditions in SELECT statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144868#M1192355</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to thank you all for your helpfull solutions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At last I was told to solve this problem by deleting those two conditions and add an statement like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    SELECT * FROM QALS INTO ls_tab&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN gt_qals&lt;/P&gt;&lt;P&gt;     WHERE prueflos = gt_qals-prueflos.&lt;/P&gt;&lt;P&gt;      CHECK ls_tab-offennlzmk EQ 0 AND p_allow1 EQ ''.&lt;/P&gt;&lt;P&gt;      CHECK ls_tab-offen_lzmk EQ 0 AND p_allow2 EQ ''.&lt;/P&gt;&lt;P&gt;      DELETE gt_qals WHERE prueflos = ls_tab-prueflos.&lt;/P&gt;&lt;P&gt;    ENDSELECT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Feb 2009 10:19:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-02T10:19:15Z</dc:date>
    <item>
      <title>Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144862#M1192349</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 am relative new to ABAP and I would like to ask a question about checking conditions in SELECT statement in the "WHERE" part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two checkboxes at the selection screen and each should disable one of  conditions (marked with two stars) in the SELECT mentioned below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is, whether there exists an option how to solve this problem without using solution like:&lt;/P&gt;&lt;P&gt;IF checkobx1.&lt;/P&gt;&lt;P&gt; SELECT (without one condition)&lt;/P&gt;&lt;P&gt;ELSEIF checkbox2.&lt;/P&gt;&lt;P&gt; SELECT(without other condition).&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt; SELECT (with both conditions)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT  q&lt;SUB&gt;prueflos q&lt;/SUB&gt;herkunft q&lt;SUB&gt;aufnr q&lt;/SUB&gt;sa_aufnr q&lt;SUB&gt;matnr q&lt;/SUB&gt;werkvorg&lt;/P&gt;&lt;P&gt;          q&lt;SUB&gt;pastrterm  q&lt;/SUB&gt;paendterm&lt;/P&gt;&lt;P&gt;          q&lt;SUB&gt;verid q&lt;/SUB&gt;objnr v&lt;SUB&gt;objnr AS objnr_fa v&lt;/SUB&gt;auart&lt;/P&gt;&lt;P&gt;    FROM qals AS q INNER JOIN vkaufk AS v&lt;/P&gt;&lt;P&gt;    ON q&lt;SUB&gt;aufnr = v&lt;/SUB&gt;aufnr&lt;/P&gt;&lt;P&gt;    INTO CORRESPONDING FIELDS OF TABLE gt_qals&lt;/P&gt;&lt;P&gt;    WHERE q~prueflos IN s_pruefl&lt;/P&gt;&lt;P&gt;      AND q~stat35     EQ space&lt;/P&gt;&lt;P&gt;      AND q~werk       EQ loswk&lt;/P&gt;&lt;P&gt;      AND q~herkunft IN s_herk&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;      AND q~offennlzmk EQ 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="2" type="ul"&gt;&lt;P&gt;      AND q~offen_lzmk EQ 0&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;      AND q~pastrterm IN s_startt&lt;/P&gt;&lt;P&gt;      AND q~paendterm LE s_endt&lt;/P&gt;&lt;P&gt;      AND v~auart IN s_auart.    "('ZCPA', 'ZCPK', 'ZCBA').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 09:53:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144862#M1192349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T09:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144863#M1192350</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;U can try to use the ranges:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: R1 FOR QALS-OFFENNLZMK,
                R2 FOR QALS-OFFEN_LZMK.


IF CHECKBOX1
  R1(3) = 'IEQ'.
  R1-LOW = 0.
  APPEND R1.
ELSEIF CHECKBOX2.
  R2(3) = 'IEQ'.
  R2-LOW = 0.
  APPEND R2.
ENDIF.

SELECT ........................................
  WHERE 
      ...............................................
      AND OFFENNLZMK IN R1
      AND OFFEN_LZMK IN R2
      ...............................................&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:01:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144863#M1192350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T10:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144864#M1192351</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 can build the where clause dynamically and pass it to the select statement. Take a look at the program &lt;STRONG&gt;demo_select_dynamic_conditions&lt;/STRONG&gt; in SE38.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:04:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144864#M1192351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T10:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144865#M1192352</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;&lt;/P&gt;&lt;P&gt;If u write someother logic for ur requirement, definetly there will be a select query.&lt;/P&gt;&lt;P&gt;In ur logic also, ultimately only one Select query will be executed. so performance will be the same if u use some other logic aslo. So use ur logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:08:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144865#M1192352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T10:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144866#M1192353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can solve the problem with dynamic creation of condition in where list &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; first add all mandatry values&lt;/P&gt;&lt;P&gt;ex: "q~prueflos IN s_pruefl" add to  itab_sel_final&lt;/P&gt;&lt;P&gt;"AND q~stat35 EQ space" add to  itab_sel_final&lt;/P&gt;&lt;P&gt;"AND q~werk EQ loswk" add to  itab_sel_final&lt;/P&gt;&lt;P&gt;"AND q~herkunft IN s_herk" add to  itab_sel_final&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then add those check box which is selected&lt;/P&gt;&lt;P&gt;suppoese check1 = X then add&lt;/P&gt;&lt;P&gt;"AND filed = check1" add to  itab_sel_final&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So decide your where condtion in internal table ITAB_SEL_FINAL and then use in select statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT q&lt;SUB&gt;prueflos q&lt;/SUB&gt;herkunft q&lt;SUB&gt;aufnr q&lt;/SUB&gt;sa_aufnr q&lt;SUB&gt;matnr q&lt;/SUB&gt;werkvorg&lt;/P&gt;&lt;P&gt;q&lt;SUB&gt;pastrterm q&lt;/SUB&gt;paendterm&lt;/P&gt;&lt;P&gt;q&lt;SUB&gt;verid q&lt;/SUB&gt;objnr v&lt;SUB&gt;objnr AS objnr_fa v&lt;/SUB&gt;auart&lt;/P&gt;&lt;P&gt;FROM qals AS q INNER JOIN vkaufk AS v&lt;/P&gt;&lt;P&gt;ON q&lt;SUB&gt;aufnr = v&lt;/SUB&gt;aufnr&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE gt_qals&lt;/P&gt;&lt;P&gt; WHERE (itab_sel_final).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will solve your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:09:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144866#M1192353</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T10:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144867#M1192354</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;With this, I think u can directly read into WHERE clause&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF checkbox1.
 
    v_where = '&amp;amp; BETWEEN ''&amp;amp;'' AND ''&amp;amp;'' '.
    REPLACE '&amp;amp;' WITH key_field INTO v_where.
    REPLACE '&amp;amp;' WITH field_LOW INTO v_where.
    REPLACE '&amp;amp;' WITH field_HIGH INTO v_where.
    CONDENSE v_where.

ELSEIF  checkbox2.

    v_where = '&amp;amp; BETWEEN ''&amp;amp;'' AND ''&amp;amp;'' '.
    REPLACE '&amp;amp;' WITH key_field INTO v_where.
    REPLACE '&amp;amp;' WITH field_LOW INTO v_where.
    REPLACE '&amp;amp;' WITH field_HIGH INTO v_where.
    CONDENSE v_where.

ENDIF.

select * into corresponding fields of table ITAB
             from (table_name)
            where (v_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this key_field is your fieldname in the where clause and field_low, field_high are range of values.&lt;/P&gt;&lt;P&gt;If i write static query it looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES: MATNR1 FOR MARA-MATNR.

  MATNR1-LOW = MATNR_LOW.
  MATNR1-HIGH = MATNR_HIGH.
  MATNR1-SIGN = 'I'.
  MATNR1-OPTION = 'BT'.
  APPEND MATNR1.


select * into corresponding fields of table itab
from mara where matnr BETWEEN 'M100' AND 'M200'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps u&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks\&lt;/P&gt;&lt;P&gt;Mahesh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mahesh Reddy on Jan 30, 2009 11:23 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 10:21:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144867#M1192354</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-01-30T10:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Checking conditions in SELECT statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144868#M1192355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to thank you all for your helpfull solutions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At last I was told to solve this problem by deleting those two conditions and add an statement like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    SELECT * FROM QALS INTO ls_tab&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN gt_qals&lt;/P&gt;&lt;P&gt;     WHERE prueflos = gt_qals-prueflos.&lt;/P&gt;&lt;P&gt;      CHECK ls_tab-offennlzmk EQ 0 AND p_allow1 EQ ''.&lt;/P&gt;&lt;P&gt;      CHECK ls_tab-offen_lzmk EQ 0 AND p_allow2 EQ ''.&lt;/P&gt;&lt;P&gt;      DELETE gt_qals WHERE prueflos = ls_tab-prueflos.&lt;/P&gt;&lt;P&gt;    ENDSELECT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2009 10:19:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-conditions-in-select-statement/m-p/5144868#M1192355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-02T10:19:15Z</dc:date>
    </item>
  </channel>
</rss>

