1、获得最后一天
CALL FUNCTION ‘FIMA_DATE_CREATE’
EXPORTING
I_DATE = I_DATE “输入日期。sy-datum类型 如:‘20110402’。
I_FLG_END_OF_MONTH = ‘ ‘
I_YEARS = 2 “两年后的日期时间,既sy-datum的年加2所得日期,可为负数,表示前两年
I_MONTHS = 1 “一个月后的日期。既sy-datum的月加1所得日期,可为负数,表示前一个月
I_DAYS = 23 “23天后的日期。可为负数,表示23天前的日期
I_CALENDAR_DAYS = 10 “10天后的日历。同I_DAYS参数。
I_SET_LAST_DAY_OF_MONTH = ‘X’ “返回的日期为当前月份的最后一天
IMPORTING
E_DATE = E_DATE “返回的日期。如果I_DAYS和I_CALENDAR_DAYS都设置,则天数累加
E_FLG_END_OF_MONTH = FLAG “如果输入参数I_SET_LAST_DAY_OF_MONTH设置’X’了,则返回值为’X’。
E_DAYS_OF_I_DATE = DAY. “返回输入日期的‘日’字段与I_DAYS字段的和。本例子为:25
2、获得周数
DATA WEEK LIKE SCAL-WEEK.
CALL FUNCTION ‘DATE_GET_WEEK’
EXPORTING
DATE = SY-DATUM ”输入日期,如:‘20110402’
IMPORTING
WEEK = WEEK.“返回输入日期为该年第几周。如:‘201113’。表示为2011年的第13周。
3、获得某周的第一天日期
DATA DATE LIKE SCAL-DATE.
CALL FUNCTION ‘WEEK_GET_FIRST_DAY’
EXPORTING
WEEK = ‘201113’ “表示2011年的第13周
IMPORTING
DATE = DATE. “返回的DATE值为20110328,既2011年第13周的第一天是3月28日。
4、得到输入日期N个月前/后的日期
4.1 返回指定月以前的日期
CALL FUNCTION ‘CCM_GO_BACK_MONTHS’
EXPORTING
CURRDATE = sy-datum
BACKMONTHS = 6
IMPORTING
NEWDATE = DATE .
4.2 返回指定年,月,日以前或以后的日期.年月日得加减
CALL FUNCTION ‘RP_CALC_DATE_IN_INTERVAL’
EXPORTING
DATE = sy-datum
DAYS = 10
MONTHS = 5
SIGNUM = ‘+'”取值为‘+’或‘-’
YEARS = 1
IMPORTING
CALC_DATE = date .
5、返回两个日期之间的年数、月数、天数
CALL FUNCTION ‘FIMA_DAYS_AND_MONTHS_AND_YEARS’
EXPORTING
I_DATE_FROM = ‘20110402’
* I_KEY_DAY_FROM =
I_DATE_TO = ‘20110522’
* I_KEY_DAY_TO =
* I_FLG_SEPARATE = ‘ ‘
IMPORTING
E_DAYS = E_DAYS “值为50
E_MONTHS = E_MONTHS “值为2
E_YEARS = E_YEARS . “值为1
6、获取输入日期月份的最后一天
BKK_GET_MONTH_LASTDAY
EXPORTING
I_DATE = ‘20110403’
IMPORTING
E_DATE = E_DATE. “E_DATE= ‘20110430’
7、日期有效性检查
DATE_CHECK_PLAUSIBILITY
8、获得所有的月份信息
DATA MONTH_NAMES LIKE T247 OCCURS 0.
CALL FUNCTION ‘MONTH_NAMES_GET’
EXPORTING
LANGUAGE = SY-LANGU
* IMPORTING
* RETURN_CODE =
TABLES
MONTH_NAMES = MONTH_NAMES
* EXCEPTIONS
* MONTH_NAMES_NOT_FOUND = 1
* OTHERS = 2
.
9.弹出一个窗口显示一个日历允许用户选择一个日期
CALL FUNCTION ‘F4_DATE’
EXPORTING
DATE_FOR_FIRST_MONTH = SY-DATUM
DISPLAY = ‘X’ “如果为X则只显示日历窗口,而没有返回值
* FACTORY_CALENDAR_ID = ‘ ‘
* GREGORIAN_CALENDAR_FLAG = ‘ ‘
* HOLIDAY_CALENDAR_ID = ‘ ‘
* PROGNAME_FOR_FIRST_MONTH = ‘ ‘
IMPORTING
SELECT_DATE = “返回值为选择的日期
* SELECT_WEEK =
* SELECT_WEEK_BEGIN =
* SELECT_WEEK_END =
* EXCEPTIONS
* CALENDAR_BUFFER_NOT_LOADABLE = 1
* DATE_AFTER_RANGE = 2
* DATE_BEFORE_RANGE = 3
* DATE_INVALID = 4
* FACTORY_CALENDAR_NOT_FOUND = 5
* HOLIDAY_CALENDAR_NOT_FOUND = 6
* PARAMETER_CONFLICT = 7
* OTHERS = 8
10、获取一年的第几周和这个周一和周日的日期
FM:GET_WEEK_INFO_BASED_ON_DATE
输入参数 值
DATE 2008.01.09
输出参数 值
WEEK 200802 <—-2008年第二周
MONDAY 2008.01.07 <—-这个周周一的日期
SUNDAY 2008.01.13 <—-周日的日期
11、输入日期是星期几
FM:DAY_IN_WEEK
输入参数 值
DATUM 2008.01.09
输出参数 值
WOTNR 3 <—-2008-1-9为周三
12、弹窗选择时间
CALL ‘F4_CLOCK’
EXPORTING
START_TIME = ’15:18:20’或‘151820’”输入时可选的
DISPLAY =
IMPORTING
SELECTED_TIME = “返回选择的时间
13、 年和月的选择窗口
DATA MONTH LIKE ISELLIST-MONTH.
CALL FUNCTION ‘POPUP_TO_SELECT_MONTH’
EXPORTING
ACTUAL_MONTH = SY-DATUM+0(6)
* FACTORY_CALENDAR = ‘ ‘
* HOLIDAY_CALENDAR = ‘ ‘
LANGUAGE = SY-LANGU
START_COLUMN = 8
START_ROW = 5
IMPORTING
SELECTED_MONTH = MONTH “返回值为六位数字
* RETURN_CODE =
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
MONTH_NOT_FOUND = 3
OTHERS = 4 .
14、获取周的信息
DATA WEEKDAY LIKE T246 OCCURS 0.
CALL FUNCTION ‘WEEKDAY_GET’
* EXPORTING
* LANGUAGE = SY-LANGU
* IMPORTING
* RETURN_CODE =
TABLES
WEEKDAY = WEEKDAY
* EXCEPTIONS
* WEEKDAY_NOT_FOUND = 1
* OTHERS = 2
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/18110.html