DATA: days TYPE i,
months TYPE i,
years TYPE i.
CALL FUNCTION ‘FIMA_DAYS_AND_MONTHS_AND_YEARS’
EXPORTING
i_date_from = ‘20130101’
i_date_to = ‘20141001’
i_flg_separate = ’ ’ "是否单独计算 若有标识,则返回两日期相差的天数
IMPORTING
e_days = days "返回天数:638
e_months = months "返回月数:21
e_years = years. "返回年数:2
-
单独计算
CALL FUNCTION ‘FIMA_DAYS_AND_MONTHS_AND_YEARS’
EXPORTING
i_date_from = ‘20130101’
i_date_to = ‘20141001’
i_flg_separate = ‘X’ "标识 ‘X’
IMPORTING
e_days = days "返回天数:0
e_months = months "返回月数:9
e_years = years. "返回年数:1
实例:
*日期计算
CALL FUNCTION ‘FIMA_DAYS_AND_MONTHS_AND_YEARS’
EXPORTING
I_DATE_FROM = CPUDT_START -
I_KEY_DAY_FROM = I_DATE_TO = CPUDT_END
-
I_KEY_DAY_TO =
-
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = days -
E_MONTHS =
-
E_YEARS = .
IF days > 30.
CLEAR LS_MSG.
LS_MSG-TYPE = ‘E’.
LS_MSG-MESSAGE = ‘查询期间大于30天!’.
APPEND LS_MSG TO LT_MSG.
EX_JSONMSG = /ui2/cl_json=>serialize( data = LT_MSG ).RETURN.
ENDIF.