<?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: SQL:How to define the where condition? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308369#M1990662</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please check the below code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : _date_range TYPE RANGE OF mseg-budat_mkpf,
       _start_day  TYPE mseg-budat_mkpf,
       _last_day   TYPE mseg-budat_mkpf.

PARAMETERS : p_monyr TYPE spmon OBLIGATORY.

START-OF-SELECTION.

* First day of period
  _start_day = |{ p_monyr }{ '01' }|.
* Last day of period
  CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
    EXPORTING
      day_in            = _start_day
    IMPORTING
      last_day_of_month = _last_day
    EXCEPTIONS
      day_in_no_date    = 1
      OTHERS            = 2.
* Populate date range
  _date_range = VALUE #( BASE _date_range ( sign = 'I' option = 'BT' low = _start_day high = _last_day ) ).
* Pass into select
  SELECT * FROM mseg INTO TABLE @DATA(_t_mseg) WHERE budat_mkpf IN @_date_range.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best Regards, Manish Shankar.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jan 2021 13:38:25 GMT</pubDate>
    <dc:creator>manish_shankar</dc:creator>
    <dc:date>2021-01-12T13:38:25Z</dc:date>
    <item>
      <title>SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308359#M1990652</link>
      <description>&lt;P&gt;Select ~&lt;/P&gt;
  &lt;P&gt;From MSEG&lt;/P&gt;
  &lt;P&gt;Where the month of MSEG-BUDAT_MKPF = [Analyze period] on selection screen&lt;/P&gt;
  &lt;P&gt;I just need YYYYMM (6 characters) to be the condition. &lt;/P&gt;
  &lt;P&gt;How to deal with it?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 08:34:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308359#M1990652</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-11T08:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308360#M1990653</link>
      <description>&lt;P&gt;you must describe the input period variable :&lt;/P&gt;&lt;P&gt;- is it a parameter ? &lt;/P&gt;&lt;P&gt;- is it a select option ?  is it limited in intervals / extension ? &lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 08:43:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308360#M1990653</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-01-11T08:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308361#M1990654</link>
      <description>&lt;P&gt;It is a select-option, and it's not limited, just must be showed as 'MM.YYYY'&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 08:52:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308361#M1990654</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-11T08:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308362#M1990655</link>
      <description>&lt;P&gt;you need to convert it to be able to use it in a SELECT statement. &lt;/P&gt;&lt;P&gt;To create a variable like a select-option, you have to use the RANGES type. (press F1 on RANGES). &lt;/P&gt;&lt;P&gt;After that you have to convert SELECT OPTION (it is not so easy). Maybe there is function module that do this for you. Other wise :&lt;/P&gt;&lt;P&gt;- Sign (I or E) you don't need to touch it&lt;/P&gt;&lt;P&gt;- OPTION (EQ, BT, ...)  you need to replace it &lt;/P&gt;&lt;P&gt;- LOW (low value)&lt;/P&gt;&lt;P&gt;- HIGH (high value)&lt;/P&gt;&lt;P&gt;for example, if you have something like   08.2020 - 10.2020 &lt;/P&gt;&lt;P&gt;inside SAP it will be I BT 202008 202010 &lt;/P&gt;&lt;P&gt;you need to convert it in  I BT 20200801  20201031 &lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 09:21:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308362#M1990655</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-01-11T09:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308363#M1990656</link>
      <description>&lt;P&gt;or ABAP &amp;gt;= 7.40 SP08:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM sflight
    WHERE substring( fldate , 1 , 6 ) = '201712'
    INTO TABLE @DATA(itab).
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2021 10:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308363#M1990656</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-01-11T10:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308364#M1990657</link>
      <description>&lt;P&gt;Thanks for your answering!&lt;/P&gt;&lt;P&gt;As your suggestion , if I convert the S_ZYEAR to a RANGE type, what should I fill into the LOW value and the HIGH value ?&lt;/P&gt;&lt;P&gt;I don't know the details of year and month, because it competely set by users&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 05:37:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308364#M1990657</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-12T05:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308365#M1990658</link>
      <description>&lt;P&gt;Date in SAP is  YYYYMMDD  &lt;/P&gt;&lt;P&gt;So if you have YYYY you have to do a concatenation of YYYY MM DD &lt;/P&gt;&lt;P&gt;if you have only the YYYY the select option contains :&lt;/P&gt;&lt;P&gt;I EQ YYYY    you have to convert it to   I BT YYYY0101   YYYY1231 &lt;/P&gt;&lt;P&gt;it is not an easy task, I wonder if it is not better to ask user for date and convert it to year &lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 06:45:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308365#M1990658</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2021-01-12T06:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308366#M1990659</link>
      <description>&lt;P&gt;But YYYY MM completely depends on what user selected on the selection screen, in this case, how to convert it to year?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 06:57:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308366#M1990659</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-12T06:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308367#M1990660</link>
      <description>&lt;P&gt;or like low '00000101' &lt;/P&gt;&lt;P&gt;            high '00001231'?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 07:02:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308367#M1990660</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-12T07:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308368#M1990661</link>
      <description>&lt;P&gt;What about this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_period TYPE n LENGTH 6.

DATA(lv_period) = |{ p_period }%|.
SELECT * FROM mseg
  INTO TABLE @DATA(lt_mseg)
  WHERE budat_mkpf LIKE @lv_period.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 07:18:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308368#M1990661</guid>
      <dc:creator>jakob_steen-petersen</dc:creator>
      <dc:date>2021-01-12T07:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308369#M1990662</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Please check the below code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : _date_range TYPE RANGE OF mseg-budat_mkpf,
       _start_day  TYPE mseg-budat_mkpf,
       _last_day   TYPE mseg-budat_mkpf.

PARAMETERS : p_monyr TYPE spmon OBLIGATORY.

START-OF-SELECTION.

* First day of period
  _start_day = |{ p_monyr }{ '01' }|.
* Last day of period
  CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
    EXPORTING
      day_in            = _start_day
    IMPORTING
      last_day_of_month = _last_day
    EXCEPTIONS
      day_in_no_date    = 1
      OTHERS            = 2.
* Populate date range
  _date_range = VALUE #( BASE _date_range ( sign = 'I' option = 'BT' low = _start_day high = _last_day ) ).
* Pass into select
  SELECT * FROM mseg INTO TABLE @DATA(_t_mseg) WHERE budat_mkpf IN @_date_range.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best Regards, Manish Shankar.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 13:38:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308369#M1990662</guid>
      <dc:creator>manish_shankar</dc:creator>
      <dc:date>2021-01-12T13:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: SQL:How to define the where condition?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308370#M1990663</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 02:06:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-how-to-define-the-where-condition/m-p/12308370#M1990663</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2021-01-13T02:06:34Z</dc:date>
    </item>
  </channel>
</rss>

