<?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 Date select-option (range) restricting Timestamp database field. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821907#M1128390</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'm writing a report that requires a Date select-option on the selection screen, but the field that I want to restrict on in the database is a timestamp.  While I'm sure I could write something that converts my date select-option into a timestamp range, I was wondering if there is a standard FMod or something that achieves the same thing.&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;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Nov 2008 14:44:48 GMT</pubDate>
    <dc:creator>afordham</dc:creator>
    <dc:date>2008-11-18T14:44:48Z</dc:date>
    <item>
      <title>Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821907#M1128390</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'm writing a report that requires a Date select-option on the selection screen, but the field that I want to restrict on in the database is a timestamp.  While I'm sure I could write something that converts my date select-option into a timestamp range, I was wondering if there is a standard FMod or something that achieves the same thing.&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;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2008 14:44:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821907#M1128390</guid>
      <dc:creator>afordham</dc:creator>
      <dc:date>2008-11-18T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821908#M1128391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi use this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OIL_DATE_TO_TIMESTAMP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2008 14:48:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821908#M1128391</guid>
      <dc:creator>former_member203501</dc:creator>
      <dc:date>2008-11-18T14:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821909#M1128392</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 thing you have to &lt;STRONG&gt;concatenate sy-datum sy-uzeit&lt;/STRONG&gt; into xyz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tks,&lt;/P&gt;&lt;P&gt;Krishna..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2008 15:27:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821909#M1128392</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-18T15:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821910#M1128393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm facing the same issue. Did this get resolved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Gauri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 03:18:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821910#M1128393</guid>
      <dc:creator>gauri_hurria</dc:creator>
      <dc:date>2013-08-27T03:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821911#M1128394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;Use could also use the function Module &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABI_TIMESTAMP_CONVERT_INTO&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 05:14:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821911#M1128394</guid>
      <dc:creator>sivaganesh_krishnan</dc:creator>
      <dc:date>2013-08-27T05:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Date select-option (range) restricting Timestamp database field.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821912#M1128395</link>
      <description>&lt;P&gt;Hello Andrew,&lt;/P&gt;&lt;P&gt;I know it's too late, but maybe can be useful for others: &lt;/P&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;CODE&gt;types:  gty_ts_range   type range of timestamp .
types:  gty_date_range type range of dats .

Parameters:
IT_DATE_RANGE	        Importing	Type	GTY_DATE_RANGE	                                IV_TIME_ZONE	        Importing	Type	SY-ZONLO	'UTC'
RT_TIMESTAMP_RANGE	Returning	Type	GTY_TS_RANGE	 

  method date_to_ts_range.

    types: begin of lty_date_result,
             date  type dats,
             shift type i,
           end of lty_date_result.

    constants: lc_min_date    type dats value '19000101',
               lc_max_date    type dats value '21000101',
               lc_end_of_days type dats value '99991231',
               lc_min_time    type tims value '000000',
               lc_max_time    type tims value '235959'.

    statics: st_all_dates type sorted table of dats with unique key table_line.

    data: lv_date              type dats.
    data: lv_max_timestamp     type timestamp.
    data: lv_min_timestamp     type timestamp.
    data: lv_ts                type timestamp.
    data: lt_date_result       type sorted table of lty_date_result with unique key date
                                                                    with non-unique sorted key k2 components shift.
    data: ls_prev_date_result  type lty_date_result.
    data: ls_ts_range          like line of rt_timestamp_range.

    check: it_date_range[] is not initial.

    " Get All Dates...
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    if st_all_dates[] is initial.
      lv_date = lc_min_date.
      while lv_date &amp;lt;= lc_max_date.
        insert lv_date into table st_all_dates[].
        add 1 to lv_date.
      endwhile.
    endif.

    lv_min_timestamp = date_time_to_ts( iv_date      = lc_min_date
                                        iv_time      = lc_min_time
                                        iv_time_zone = iv_time_zone  ).

    lv_max_timestamp = date_time_to_ts( iv_date      = lc_max_date
                                        iv_time      = lc_max_time
                                        iv_time_zone = iv_time_zone  ).

    " Collect Date Result...
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    loop at st_all_dates into lv_date where table_line in it_date_range. "#EC CI_SORTSEQ
      insert value #( date = lv_date shift = 0 ) into table lt_date_result[].
    endloop.

    " Optimize Date Result...
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    check lt_date_result[] is not initial.

    " Step 1: Calculate Shifts...
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    loop at lt_date_result[] assigning field-symbol(&amp;lt;fs_date_result&amp;gt;).
      if sy-tabix = 1.
        lv_date = &amp;lt;fs_date_result&amp;gt;-date.
        &amp;lt;fs_date_result&amp;gt;-shift = 8.
      else.
        &amp;lt;fs_date_result&amp;gt;-shift = &amp;lt;fs_date_result&amp;gt;-date - lv_date.
        lv_date = &amp;lt;fs_date_result&amp;gt;-date.
      endif.
    endloop.
    insert value #( date = lc_end_of_days shift = 8 ) into table lt_date_result[]. " Needed for last loop...

    " Step 2: Collect Results...
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    clear: ls_ts_range.
    loop at lt_date_result[] assigning &amp;lt;fs_date_result&amp;gt; where shift &amp;lt;&amp;gt; 1.

      " Start Date...
      if ls_ts_range is initial.
        ls_ts_range-sign   = 'I'.
        ls_ts_range-option = 'BT'.
        clear: lv_ts.
        lv_ts = date_time_to_ts( iv_date      = &amp;lt;fs_date_result&amp;gt;-date
                                 iv_time      = lc_min_time
                                 iv_time_zone = iv_time_zone ).
        ls_ts_range-low  = lv_ts.
      endif.

      " End Date...
      data(lv_prev_line) = sy-tabix - 1.
      if ls_ts_range is not initial and lv_prev_line &amp;gt; 0.
        read table lt_date_result into ls_prev_date_result index lv_prev_line.
        if sy-subrc = 0.
          clear: lv_ts.
          lv_ts = date_time_to_ts( iv_date      = ls_prev_date_result-date
                                   iv_time      = lc_max_time
                                   iv_time_zone = iv_time_zone ).
          ls_ts_range-high = lv_ts.

          " Optimize Selections...
          " GE:
          if ls_ts_range-high = lv_max_timestamp and ls_ts_range-low is not initial.
            ls_ts_range-option = 'GE'.
            clear: ls_ts_range-high.
          endif.
          " LE:
          if ls_ts_range-low = lv_min_timestamp and ls_ts_range-high is not initial.
            ls_ts_range-option = 'LE'.
            ls_ts_range-low = ls_ts_range-high.
            clear: ls_ts_range-high.
          endif.

          append ls_ts_range to rt_timestamp_range[].


          " Renewal of Start Date...
          clear: ls_ts_range.
          ls_ts_range-sign   = 'I'.
          ls_ts_range-option = 'BT'.
          clear: lv_ts.
          lv_ts = date_time_to_ts( iv_date      = &amp;lt;fs_date_result&amp;gt;-date
                                   iv_time      = lc_min_time
                                   iv_time_zone = iv_time_zone ).
          ls_ts_range-low  = lv_ts.
        endif.
      endif.

    endloop.

  endmethod.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;BR, Dmitrii&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 10:43:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-select-option-range-restricting-timestamp-database-field/m-p/4821912#M1128395</guid>
      <dc:creator>dmitry_sharshatkin</dc:creator>
      <dc:date>2022-04-29T10:43:21Z</dc:date>
    </item>
  </channel>
</rss>

