Skip to Content
author's profile photo Former Member
Former Member

Split period into different date ranges

Hi,

Can someone let me know if there is any standard Function module that can split up the periods? For example I have a total period 01.01.2008 to 31.12.2008 and I have a split period of 01.04.2008 to 30.04.2008.

Now my resultant period should be,

1. 01.01.2008 to 31.03.2008

2. 01.04.2008 to 30.04.2008

3. 01.05.2008 to 31.12.2008

Thanks,

Prasath N

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jun 16, 2008 at 09:40 AM

    Hi,

    check function module RHXPROVIDE_PERIODS.

    regards

    Walter Habich

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 08:09 AM

    If a FM is not available does anyone have a sample code on how to achieve this? I searched in code gallery but couldnt manage to get one.

    Thanks,

    Prasath N

    Add a comment
    10|10000 characters needed characters exceeded

    • Are there no programmers around your site? This really is tremendously basic.

      PARAMETERS: p_dat TYPE d.
      
      CONSTANTS: c_start_of_all_periods TYPE d VALUE '20080101',
                 c_end_of_all_periods   TYPE d VALUE '20081231'.
      
      DATA: start_of_first_period TYPE d,
            end_of_first_period   TYPE d,
            start_of_split_period TYPE d,
            end_of_split_period   TYPE d,
            start_of_2nd_period   TYPE d,
            end_of_2nd_period     TYPE d.
      
      IF p_dat LT c_start_of_all_periods OR p_dat GT c_end_of_all_periods.
        WRITE: / 'Outside range'.
        EXIT.
      ENDIF.
      
      start_of_split_period = p_dat.
      start_of_first_period = c_start_of_all_periods.
      end_of_2nd_period = c_end_of_all_periods.
      
      * Get first day of supplied month
      start_of_split_period+6(2) = '01'.
      
      * Get day before the first day of supplied month
      end_of_first_period = start_of_split_period - 1.
      
      start_of_2nd_period = start_of_split_period.
      start_of_2nd_period+6(2) = '28'. " Get 28th of supplied month
      ADD 4 TO start_of_2nd_period. " Get 4 days later - this will be in next month
      start_of_2nd_period+6(2) = '01'. " Get first day of next month
      
      end_of_split_period = start_of_2nd_period - 1. " Get day before start of 2nd period
      
      WRITE: / start_of_first_period,
               end_of_first_period,
               start_of_split_period,
               end_of_split_period,
               start_of_2nd_period,
               end_of_2nd_period. 

      If you are a programmer, I hope this sample is sufficient to show how to deal with all kinds of date handling coding problems.

      matt

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 08:23 AM

    Hi Prasath,

    Try this:

    REPORT ZKEERTHI_SDN1.

    parameters: startdat type sy-datum,

    enddate type sy-datum,

    split1 type sy-datum,

    split2 type sy-datum.

    data: p1 type sy-datum,

    p2 type sy-datum.

    p1 = split1 - 1.

    p2 = split2 + 1.

    write:/ startdat, 'to' , p1.

    write:/ split1, 'to' , split2.

    write:/ p2, 'to' , enddate.

    Hope this helps,

    Keerthi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 08:40 AM

    hi split the date range in to three like this..

    use the function module to get the last date of the month..

    JVA_LAST_DATE_OF_MONTH

    get the time interval from the fm

    'FIMA_DAYS_AND_MONTHS_AND_YEARS'

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.