Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Split period into different date ranges

Former Member
0 Likes
3,738

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

1 ACCEPTED SOLUTION
Read only

former_member435013
Active Participant
0 Likes
1,937

Hi,

check function module RHXPROVIDE_PERIODS.

regards

Walter Habich

5 REPLIES 5
Read only

Former Member
0 Likes
1,937

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

Read only

matt
Active Contributor
0 Likes
1,937

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

Read only

Former Member
0 Likes
1,937

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.

Read only

Former Member
0 Likes
1,937

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'

Read only

former_member435013
Active Participant
0 Likes
1,938

Hi,

check function module RHXPROVIDE_PERIODS.

regards

Walter Habich