‎2008 Mar 05 8:04 AM
hi i need a function module which gives the month start and end dates as out put if i give two dates as input.
ex : input : a :01.01.2006
b: 01.06.2006
the o/p shld be :
01.01.2006 31.01.2006
01.02.2006 28.02.2006
01.03.2006 31.02.2006
upto the enddate ....
plz help.i have tried HR_BR_SPLIT_MONTHS but its of no use if the year changes ...
‎2008 Mar 05 8:26 AM
hi,
Could you elaborate on "no use if the year changes ".
I tried to reproduce your problem, I even tried for 2008 the values are different.I am not sure what is the exact problem
Regards,
Narayani
‎2008 Mar 05 8:35 AM
HI ,
narayani ,,the exact pblm is if i give input as 02.04.2007 and 03.04.2008 i want in between start and end dates of the months .
but o/p sdates will have 9 entries and pdates will have 2007 years dates only. thy are not getting the 2008 values......hope u have understood.
vishnu reddy.
‎2008 Mar 05 8:35 AM
‎2008 Mar 05 8:37 AM
‎2008 Mar 05 8:40 AM
Try using the FM "FIMA_DAYS_BETWEEN_TWO_DATES_2".
or
Use this FM
data: No_of_days TYPE I
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = G_T_PURO-AEDAT " Enddate
I_DATUM_VON = G_T_EBAN-BADAT " Start Date
IMPORTING
E_TAGE = No_of_days
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2.
write: No_of_days .
TO find out the difference in the form of months try
MONTHS_BETWEEN_TWO_DATES
MONTHS_BETWEEN_TWO_DATES_NEW
HR_99S_MONTHS_BETWEEN_DATES
HR_MONTHS_BETWEEN_TWO_DATES
Regards,
Chandru
‎2008 Mar 05 8:42 AM
Hi,
I have created a small function module which might your requirement as below:
FUNCTION zcalculatedates.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(START_DATE) TYPE BEGDA
*" REFERENCE(END_DATE) TYPE ENDDA
*" EXPORTING
*" REFERENCE(DATE_OUTPUT) TYPE DBSTODATE
*" EXCEPTIONS
*" DATE_CALC_ERROR
*" CHECK_DATES
*"----------------------------------------------------------------------
DATA: v_date TYPE sy-datum, v_datec(8), w_date_output TYPE dbssodate.
IF START_DATE GT END_DATE. RAISE CHECK_DATES. ENDIF.
MOVE start_date TO v_datec. v_datec+6(2) = '01'.
MOVE v_datec TO v_date.
DO.
MOVE v_date TO w_date_output-low.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = v_date
IMPORTING
last_day_of_month = w_date_output-high
EXCEPTIONS
day_in_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING date_calc_error.
ELSE.
IF w_date_output-low > end_date.
EXIT.
ELSE.
APPEND w_date_output TO date_output.
ENDIF.
ENDIF.
CALL FUNCTION 'BKK_ADD_MONTH_TO_DATE'
EXPORTING
months = 1
olddate = v_date
IMPORTING
newdate = v_date.
ENDDO.
ENDFUNCTION.
Examples of the function:
Exampe 1:
Input
Import parameters Value
START_DATE 01.01.2006
END_DATE 01.06.2006
Output
LOW HIGH
01.01.2006 31.01.2006
01.02.2006 28.02.2006
01.03.2006 31.03.2006
01.04.2006 30.04.2006
01.05.2006 31.05.2006
01.06.2006 30.06.2006
Example 2:
Input
Import parameters Value
START_DATE 01.08.2006
END_DATE 01.02.2007
Output
LOW HIGH
01.08.2006 31.08.2006
01.09.2006 30.09.2006
01.10.2006 31.10.2006
01.11.2006 30.11.2006
01.12.2006 31.12.2006
01.01.2007 31.01.2007
01.02.2007 28.02.2007
Cheers
‎2008 Mar 05 9:02 AM
‎2008 Mar 05 9:42 AM
hi aditya ,
wht type structure will be DBSTODATE and dbssodate .
plz let me know .
‎2008 Mar 05 9:43 AM
‎2008 Mar 05 9:52 AM
Hi Vishnu,
DBSTODATE is a table type and its structure is DBSSODATE.
DBSSODATE is a range structure for DATE field, i.e. it contains the following fields: SIGN, OPTION, LOW and HIGH.
However, you can replace the table type and structure with your own declarations in SE11 as per your convinience.
‎2008 Mar 05 9:53 AM
Its a Range for Dates...
Line type DBSSODATE
SIGN CHAR 1 0
OPTION CHAR 2 0
LOW DATS 8 0
HIGH DATS 8 0
Cheers!!
Lokesh
‎2008 Mar 05 9:58 AM
Hi try this,
This will give total days, months, and years between two dates.
HR_HK_DIFF_BT_2_DATES
Regards,
kavitha.
‎2008 Mar 05 10:11 AM
HI,
You can use FM CSCP_PARA1_GET_PERIODS.
Thanks,
Sriram Ponna.
‎2008 Mar 06 2:07 AM
hi,
sriram its giving only month start dates i want end dates also ....
regards,
vishnu.
‎2008 Mar 05 10:19 AM
‎2008 Mar 05 10:22 AM
Use this FM
data: No_of_days TYPE I
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = G_T_PURO-AEDAT " Enddate
I_DATUM_VON = G_T_EBAN-BADAT " Start Date
IMPORTING
E_TAGE = No_of_days
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2.
write: No_of_days .
TO find out the difference in the form of months try
MONTHS_BETWEEN_TWO_DATES
MONTHS_BETWEEN_TWO_DATES_NEW
HR_99S_MONTHS_BETWEEN_DATES
HR_MONTHS_BETWEEN_TWO_DATES
Please reward points, if its helpful.