on 01-04-2013 1:12 PM
Hi,
I have period and I want to break this period into its respective month.
Like date_from = 15/01/2012 date_to = 24/02/2012
i want to break this period as 15/01/2012 to 31/01/2012 and 01/02/2012 to 24/02/2012.
Can you please suggest me a function module or any method with which i can perform this opertaion.
Thanks in advance.
Hi Prakhar,
Though it is unreleased, function HR_99S_INTERVAL_BETWEEN_DATES may be useful to you. If you provide it with start and end dates and also specify TAB_MODE = 'I', export parameter MONTH_TAB will list all months between the specified dates. Just substitute your date_from for the first month's start date and your date_to for the last month's end date, and you'll have the result you're looking for.
CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
EXPORTING
begda = date_from
endda = date_to
tab_mode = 'I' " Include boundary months
IMPORTING
month_tab = lt_month_tab.
Cheers,
Amy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prakhar,
Use FM 'DETERMINE_END_OF_MONTH' to determine no_of_days_in_month.
And use concatenate no_of_days_in_month with start month you will get to period.
For example in your case : date_from is 15/01/2012.
No-of_days_in_month = 31.
concatenate this with month and year.
Last day in month = 31/01/2012.
Add 1 day to this date you will get 1st day in next month. ( 01/02/2012 in your example )
And use this date with date_to, you will get second period.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What did you try before posting, did you try a logic like
do
calculate first_day_of_ month from last_date changing day to '01'
if first_day_of_ month greater than first_date
create an interval from first_day_of_month to last_date
last_date = last day of previous month (first_day_of_month - 1)
" iterate.
else.
create an interval from first_day to last_day.
exit.
endif.
enddo.
Regards,
Raymond
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Raymond Giuseppi wrote:
What did you try before posting,
Indeed. But why try anything when you can post a basic question on SCN and within a few hours get 3 replies?
[sarcasm off]
Prakhar, please do some analysis yourself before posting. Try, for example, 'last day of month site:sap.com' in Google and see what happens. All date related functions have already been mentioned on SCN. Or simply search in SE37 using an asterisk (e.g. *LAST*DAY*).
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.