2006 May 05 5:57 PM
Hi Dudes,
I need a Function Module that gives me the months between the given range of months
for ex:
if user gives 200501 till 200510
the the output should be a table which returns
200501
200502
200503
.
.
.
.
.
200510
2006 May 05 6:05 PM
Hi Jimmy,
Did you try using SD_DATETIME_DIFFERENCE.
But this should give your better result
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
However, I am not sure if the output is in months or days.
Regards,
Ravi
Note : Please mark the helpful answers
2006 May 05 6:07 PM
I´m think that dosn´t exist standard FM as you describe. Try doing it for yourself, don´t seem very dificult.
Regards.
2006 May 05 6:11 PM
2006 May 05 6:24 PM
Hi Sam,
try using FM <b>MONTHS_BETWEEN_TWO_DATES</b>
Regards,
Santosh
2006 May 05 6:57 PM
Hi Jimmy,
Try using FM "HR_IN_CALC_MONTHS" which is Function to calculate the months in split period . round the factor to get the whole number.
Hope this works for you.
Regards,
Vicky
2006 May 05 7:13 PM
Hi,
We can get the difference between two dates just by subtracting and i guess there is no need to use any function Module.
Regards
Kumar
2006 May 05 7:16 PM
Hi Kumar,
If the dates are in same year then we can directly subtract otherwise we need to do some manipulation.
regards,
vicky
2006 May 05 11:51 PM
Hi Vicky,
1.I could not find any FM but you can use FM FIMA_DAYS_AND_MONTHS_AND_YEARS. The import paramter to be used are Start Date and End Date. Since your requirement is to get months only, you can put DD = 01 for both Start Date and End Date. You need to use export parameter of E_MONTHS which will give you total number of months in between the given inputs. Use this value to print from Start Date till End Date by putting logic that maximum periods = 12.
2)Also you can use the following code to calculate the same :
REPORT ZTEST_MONTH_GET_17 .
data : date1(6) type c value 200503,
date2(6) type c value 200708.
data : var1(2) type c.
data : begin of date_arr occurs 0,
year1(4) type c,
month1(2) type c,
end of date_arr.
START-OF-SELECTION.
if date1(4) = date2(4).
var1 = date24(2) - date14(2) + 1.
date_arr-year1 = date1(4).
date_arr-month1 = date1+4(2).
do var1 times.
append date_arr.
date_arr-month1 = date_arr-month1 + 1.
shift date_arr-month1 right.
overlay date_arr-month1 with '00'.
enddo.
else.
while date1(4) le date2(4).
if date1(4) = date2(4).
var1 = date2+4(2).
else.
var1 = 12 - date1+4(2) + 1.
endif.
date_arr-year1 = date1(4).
date_arr-month1 = date1+4(2).
do var1 times.
append date_arr.
date_arr-month1 = date_arr-month1 + 1.
shift date_arr-month1 right deleting trailing space.
overlay date_arr-month1 with '00'.
enddo.
date1(4) = date1(4) + 1.
date1+4(2) = '01'.
endwhile.
endif.
clear date_arr.
loop at date_arr.
write 😕 date_arr.
endloop.
Note: Pls reward the points if you found reply helpful.