<?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: select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813559#M1313677</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;Take two variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: v_date1 type sy-datum,&lt;/P&gt;&lt;P&gt;        v_date2 type sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  concatenate s_mon-low '01' into v_date1.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  get the last day of month for the month that you have entered in s_mon-high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  suppose the last day of month is 30 or 31 or 28 or 29.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  concatenate s_mon-high &amp;lt;last day of month&amp;gt; into v_date2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  now in select query write as shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT mblnr&lt;/P&gt;&lt;P&gt;mjahr&lt;/P&gt;&lt;P&gt;bldat &lt;/P&gt;&lt;P&gt;budat&lt;/P&gt;&lt;P&gt;INTO TABLE gt_mkpf&lt;/P&gt;&lt;P&gt;FROM mkpf&lt;/P&gt;&lt;P&gt;WHERE mblnr in s_mblnr&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND ( bldat GE v_date1 and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;          &lt;STRONG&gt;bldat LE v_date2 )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND (budat GE v_date1 and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;         &lt;STRONG&gt;budat LE v_date2 )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND (mjahr between s_mon-low+0(4)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and s_mon-high+0(4)).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kumar Bandanadham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2009 06:37:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-23T06:37:13Z</dc:date>
    <item>
      <title>select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813554#M1313672</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;in the select option i have month and year range option as below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT-OPTIONS:  s_mon FOR s031-spmon&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection screen:&lt;/P&gt;&lt;P&gt; month =    2008.12    to   2009.02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where as in the select query i need to get  inbetween data 12.2008 to 2.2009.&lt;/P&gt;&lt;P&gt;if i put as bleow it doesnot select inbetween data , how to get fetch inbetween.&lt;/P&gt;&lt;P&gt;do i need to write code in intilization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  mblnr&lt;/P&gt;&lt;P&gt;              mjahr&lt;/P&gt;&lt;P&gt;              bldat&lt;/P&gt;&lt;P&gt;              budat&lt;/P&gt;&lt;P&gt;              INTO TABLE gt_mkpf&lt;/P&gt;&lt;P&gt;              FROM mkpf&lt;/P&gt;&lt;P&gt;              WHERE mblnr in s_mblnr&lt;/P&gt;&lt;P&gt;              AND  mjahr  = s_mon-low+0(4)&lt;/P&gt;&lt;P&gt;              and   mjahr  = s_mon-high+0(4).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help with code&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:21:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813554#M1313672</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813555#M1313673</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;the select option will take care of it by itself... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


SELECT mblnr
mjahr
bldat
budat
INTO TABLE gt_mkpf
FROM mkpf
WHERE mblnr in s_mblnr
AND mjahr in s_mon.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:25:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813555#M1313673</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813556#M1313674</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;The date format used in the select options is based on the user settings available in SU3 or SU01 defaults -&amp;gt; Date format settings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So either you can modify your user settings, or based on the format available in the table USR01, take the offset value accordingly from the select options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:26:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813556#M1313674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813557#M1313675</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;Check this way..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT mblnr
mjahr
bldat
budat
INTO TABLE gt_mkpf
FROM mkpf
WHERE mblnr in s_mblnr
AND mjahr GE s_mon-low+0(4)
and mjahr LE s_mon-high+0(4).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RANGES R_MJAHR FOR MKPF-MJAHR.
R_MJAHR-SIGN = 'I'.
R_MJAHR-LOW = S_MON-low+0(4).
IF S_MON-HIGH IS INITIAL.
  R_MJAHR-HIGH = S_MON-HIGH+0(4).
  R_MJAHR-OPTION = 'BT'.
ELSE.
  R_MJAHR-OPTION = 'EQ'.
ENDIF.
APPEND G_MJAHR. CLEAR R_MJAHR.

SELECT mblnr
mjahr
bldat
budat
INTO TABLE gt_mkpf
FROM mkpf
WHERE mblnr in s_mblnr
AND mjahr IN R_MJAHR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:29:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813557#M1313675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813558#M1313676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like this,but you will get between fiscal year 2008 and 2009,not between the dates....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT mblnr&lt;/P&gt;&lt;P&gt;             mjahr&lt;/P&gt;&lt;P&gt;             bldat&lt;/P&gt;&lt;P&gt;             budat INTO TABLE gt_mkpf FROM mkpf&lt;/P&gt;&lt;P&gt;                                   WHERE mblnr in s_mblnr&lt;/P&gt;&lt;P&gt;                                         AND mjahr GE s_mon-low+0(4)&lt;/P&gt;&lt;P&gt;                                         AND mjahr LE s_mon-high+0(4).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:36:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813558#M1313676</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813559#M1313677</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;Take two variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: v_date1 type sy-datum,&lt;/P&gt;&lt;P&gt;        v_date2 type sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  concatenate s_mon-low '01' into v_date1.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  get the last day of month for the month that you have entered in s_mon-high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  suppose the last day of month is 30 or 31 or 28 or 29.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  concatenate s_mon-high &amp;lt;last day of month&amp;gt; into v_date2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  now in select query write as shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT mblnr&lt;/P&gt;&lt;P&gt;mjahr&lt;/P&gt;&lt;P&gt;bldat &lt;/P&gt;&lt;P&gt;budat&lt;/P&gt;&lt;P&gt;INTO TABLE gt_mkpf&lt;/P&gt;&lt;P&gt;FROM mkpf&lt;/P&gt;&lt;P&gt;WHERE mblnr in s_mblnr&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND ( bldat GE v_date1 and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;          &lt;STRONG&gt;bldat LE v_date2 )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND (budat GE v_date1 and&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;         &lt;STRONG&gt;budat LE v_date2 )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AND (mjahr between s_mon-low+0(4)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and s_mon-high+0(4)).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kumar Bandanadham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:37:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813559#M1313677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813560#M1313678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please follow the steps below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Range: dat for mkpf-budat.&lt;/P&gt;&lt;P&gt;selection screen:&lt;/P&gt;&lt;P&gt;month = 2008.12 to 2009.02.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONCATENATE: s_mon-low '.01' TO dat-low.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONCATENATE: s_mon-high '.28' TO dat-high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dat-sign = 'I'.&lt;/P&gt;&lt;P&gt;dat-option = 'BT'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT mblnr&lt;/P&gt;&lt;P&gt;mjahr&lt;/P&gt;&lt;P&gt;bldat&lt;/P&gt;&lt;P&gt;budat&lt;/P&gt;&lt;P&gt;INTO TABLE gt_mkpf&lt;/P&gt;&lt;P&gt;FROM mkpf&lt;/P&gt;&lt;P&gt;WHERE mblnr in s_mblnr&lt;/P&gt;&lt;P&gt;AND BUDAT in DAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Suvendu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:46:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813560#M1313678</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813561#M1313679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try something like following&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES : MKPF,
         S031.
DATA GT_MKPF TYPE TABLE OF MKPF.
SELECT-OPTIONS: S_MBLNR FOR MKPF-MBLNR,
                S_MON   FOR S031-SPMON.


RANGES : R_BUDAT FOR MKPF-BUDAT.

START-OF-SELECTION.
  CLEAR R_BUDAT[].
****LOOP AT SELECTED MONTHS AND CREATE DATES RANGE
  LOOP AT S_MON.
    R_BUDAT-SIGN   = S_MON-SIGN.                 "SET SIGN EQUAL TO SELECTED
    R_BUDAT-OPTION = S_MON-OPTION.               "SET OPTION EQUAL TO SELECTED
    CONCATENATE S_MON-LOW '01' INTO R_BUDAT-LOW. "SET FIRST DATE OF THE MONTH
***********GET LAST DATE OF THE MONTH
    CALL FUNCTION 'DATE_GET_MONTH_LASTDAY'
      EXPORTING
        I_DATE = R_BUDAT-LOW
      IMPORTING
        E_DATE = R_BUDAT-HIGH.
    APPEND R_BUDAT. "APPEND DATE RANGE
  ENDLOOP.
***RUN QUERY
  SELECT MBLNR
         MJAHR
         BLDAT
         BUDAT
    INTO CORRESPONDING FIELDS OF TABLE GT_MKPF
    FROM MKPF
   WHERE BUDAT IN R_BUDAT
     AND MBLNR IN S_MBLNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 06:49:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/5813561#M1313679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T06:49:42Z</dc:date>
    </item>
  </channel>
</rss>

