abap獲取日期 ABAP 日期轉換成中文

2021-10-13 02:18:47 字數 4077 閱讀 1106

function zdate_convert_cn.

*"*"local inte***ce:

*"  importing

*"     value(i_datum) type  sydatum default sy-datum

*"  exporting

*"     value(e_year) type  char10

*"     value(e_month) type  char6

*"     value(e_day) type  char8

*"     reference(e_***at) type  char24

* input 080808 ==>2008.08.08

data: l_datum type sy-datum.

call function 'convert_date_to_internal'

exporting

date_external            = i_datum

importing

date_internal            = l_datum

exceptions

date_external_is_invalid = 1

others                   = 2.

check sy-subrc eq 0.

data:l_xyear type c length 8, " 年

l_month type c length 2, " 月

l_xdate type c.          " 日

data: l_year1 type c length 2,

l_year2 type c length 2,

l_year3 type c length 2,

l_year4 type c length 2.

*year

l_xyear = l_datum(4) .

l_year1 = l_xyear(1) .

l_year2 = l_xyear+1(1) .

l_year3 = l_xyear+2(1) .

l_year4 = l_xyear+3(1) .

*month

l_month   =  l_datum+4(2) .

*day

l_xdate   =  l_datum+6(2).

*convert year to chinese

perform frm_digit_to_chinese using l_year1

changing l_year1.

perform frm_digit_to_chinese using l_year2

changing l_year2.

perform frm_digit_to_chinese using l_year3

changing l_year3.

perform frm_digit_to_chinese using l_year4

changing l_year4.

concatenate l_year1 l_year2 l_year3 l_year4 into l_xyear .

concatenate l_xyear '年' into e_year.

condense e_year.

*convert month to chinese

perform frm_digit_to_chinese using l_month

changing e_month.

concatenate e_month '月' into e_month.

condense e_month.

*convert day to chinese

perform frm_digit_to_chinese using l_xdate

changing e_day   .

concatenate e_day '日' into e_day.

condense e_day.

*concatenate year month day inot chinese character.

concatenate e_year e_month e_day into e_***at.

condense e_***at.

endfunction.

***include lzdate_convert_cnf01 .

*&      form  frm_digit_to_chinese

*       text

form frm_digit_to_chinese using f_in

changing f_out.

case f_in.

* for year

when '0' .

f_out = '零'.

when '1' .

f_out = '一'.

when '2' .

f_out = '二'.

when '3'.

f_out = '三'.

when '4'.

f_out = '四'.

when '5'.

f_out = '五'.

when '6'.

f_out = '六'.

when '7'.

f_out = '七'.

when '8'.

f_out = '八'.

when '9'.

f_out = '九'.

* following is for month and day

when '01' .

f_out = '一'.

when '02' .

f_out = '二'.

when '03'.

f_out = '三'.

when '04'.

f_out = '四'.

when '05'.

f_out = '五'.

when '06'.

f_out = '六'.

when '07'.

f_out = '七'.

when '08'.

f_out = '八'.

when '09'.

f_out = '九'.

when '10'.

f_out = '十'.

when '11'.

f_out = '十一'.

when '12'.

f_out = '十二'.

when '13'.

f_out = '十三'.

when '14'.

f_out = '十四'.

when '15'.

f_out = '十五'.

when '16'.

f_out = '十六'.

when '17'.

f_out = '十七'.

when '18'.

f_out = '十八'.

when '19'.

f_out = '十九'.

when '20'.

f_out = '二十'.

when '21' .

f_out = '二十一'.

when '22' .

f_out = '二十二'.

when '23'.

f_out = '二十三'.

when '24'.

f_out = '二十四'.

when '25'.

f_out = '二十五'.

when '26'.

f_out = '二十六'.

when '27'.

f_out = '二十七'.

when '28'.

f_out = '二十八'.

when '29'.

f_out = '二十九'.

when '30'.

f_out = '三十'.

when '31'.

f_out = '三十一'.

endcase.

endform.                    " frm_digit_to_chinese

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 ...

abap獲取日期 ABAP常用日期函式總結

importing e date lastdate.e end of month e days of i date 其中,lastdate 為上月最後一天。firstday 是上月第一天 concatenate lastdate 6 01 into firstday.當天是當年的第幾周 date g...

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 ...