最近做乙個功能,需要得到下周一至周五的日期功能,谷歌度娘一番後,沒有找到直接可也使用的函式,只能自己寫乙個。關於周的函式,可也檢視function group中的cada。
*設定變數
data : lv_monday type dats,
lv_sunday type dats,
lv_friday type dats.
*得到當前日期的周一和週日
call function 'get_week_info_based_on_date'
exporting
date = sy-datum
importing
* week =
monday = lv_monday
sunday = lv_sunday.
*得到下周一
call function 'rp_calc_date_in_interval'
exporting
date = lv_sunday
days = 1
months = 0
signum = '+'
years = 0
importing
calc_date = lv_monday.
*得到下周五
call function 'rp_calc_date_in_interval'
exporting
date = lv_monday
days = 4
months = 0
signum = '+'
years = 0
importing
calc_date = lv_friday.
得到當前日期是星期幾。
data lv_date type p.
*得到星期幾
call function 'day_in_week'
exporting
datum = sy-datum
importing
wotnr = lv_date.
*轉換成漢字
data lt_weekname type standard table of t246.
data wa_weekname type t246.
call function 'weekday_get'
exporting
language = '1'
* importing
* return_code =
tables
weekday = lt_weekname
* exceptions
* weekday_not_found = 1
* others = 2
.
if sy-subrc <> 0.
return.
endif.
read table lt_weekname with key wotnr = lv_date into wa_weekname.
*wa_weekname-langt 就是得到的資料.
abap 中日期的處理
日期 加減 call function rp calc date in interval exporting date in date days 5 months 0 signum years 0 importing calc date out date 也可以 通過 日期 數字 的語句進行日期的加...
ABAP常用日期處理函式
abap中常用日期函式 一 查詢兩個日期間的日間間隔 call function fima days and months and years exporting i date from 20080101 i key day from i date to 20090508 i key day to ...
abap獲取日期 ABAP 日期時間函式
hr jp month begin end date call function hr jp month begin end date exportingiv date 20160615 importingev month begin date zbegda 2016.06.01 ev month ...