日期金额格式问题
日期
DATA:lv_date TYPE dats.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = lv_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc NE 0. "如果返回非0,则日期不合法
gv_error = 'X'.
gs_data-msgtp = 'E'.
gs_data-light = icon_red_light.
gs_data-msg = '日期格式错误'.
error_flag = 'X'.
ENDIF.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = lv_date
IMPORTING
date_external = gs_data-datbi
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
金额
http://blog.sina.com.cn/s/blog_5d3b01030100tv1b.html
https://blog.csdn.net/zhongguomao/article/details/80298971
DATA l_internal_amount TYPE bseg-dmbtr. DATA lc LIKE t001-waers . lc = 'CNY'. CLEAR:l_internal_amount. l_internal_amount = gs_excel-kbetr. CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERNAL' EXPORTING currency = lc amount_internal = l_internal_amount IMPORTING amount_external = l_internal_amount. gs_data-kbetr = l_internal_amount.
金额负号问题
CONVERSION_EXIT_Z001_INPUT 金额负号还原函数(小数点2位)
CONVERSION_EXIT_Z001_OUTPUT 金额负号提前函数(小数点2位)
CONVERSION_EXIT_Z002_INPUT 数量负号还原函数(小数点3位)
金额转化大写汉字
FUNCTION z_numeric_to_chinese. *"---------------------------------------------------------------------- *"*"本地接口: *" IMPORTING *" VALUE(IV_MONEY) TYPE BF_DMBTR *" EXPORTING *" VALUE(EV_MONEY) TYPE STRING *" EXCEPTIONS *" WRONG_MONEY *"---------------------------------------------------------------------- iv_money = abs( iv_money ). DATA: scr(30) TYPE c, res(60) TYPE c,fen(2) TYPE c . DATA: len TYPE i, c1 TYPE i, c2 TYPE i, c3 TYPE i, c4 TYPE i. DATA: d1(1) TYPE c, d2(1) TYPE c, d3 TYPE i. DATA: digit(2) TYPE c, weight(2) TYPE c. DATA: rule1(20) TYPE c VALUE '零壹贰叁肆伍陆柒捌玖'. DATA: rule2(30) TYPE c VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万'. scr = iv_money * 100. CONDENSE scr NO-GAPS. IF scr = '0'. res = '零元'. ELSE. len = strlen( scr ). c1 = 0. d1 = '0'. CLEAR res. DO len TIMES. c1 = c1 + 1. c2 = len - c1. d2 = scr+c2(1) . IF d2 = '0'. d3 = 0. ELSE. d3 = d2. ENDIF. digit = rule1+d3(1) . c3 = ( c1 - 1 ) . weight = rule2+c3(1) . IF d2 = '0'. IF c1 = 3. digit = ''. ELSEIF c1 = 7. digit = ''. IF len > 10 . c4 = len - 10. IF scr+c4(4) = '0000'. weight = ''. ENDIF. ENDIF. ELSEIF c1 = 11. digit = ''. ELSEIF d1 = '0'. digit = ''. weight = ''. ELSE. weight = ''. ENDIF. ENDIF. CONCATENATE digit weight res INTO res . d1 = d2. ENDDO. ENDIF. len = strlen( res ) - 1. fen = res+len(1). IF fen <> '分' . CONCATENATE res '整' INTO ev_money. ELSE. ev_money = res. ENDIF. ENDFUNCTION.
从左边截取 (取数据的X位 具体值) 以小数后有三位为例子
TYPES:BEGIN OF ty_s, string(20), "ALV展示字段 \ END OF ty_s. DATA gt_split TYPE TABLE OF ty_s WITH HEADER LINE. DATA lv_str TYPE string. DATA :lv_str_in TYPE ekpo-menge . DATA in_table LIKE TABLE OF zsds_xsck WITH HEADER LINE. CLEAR: lv_str. lv_str_in = |240.000|. CLEAR: lv_str. FREE:gt_split. lv_str = lv_str_in . SPLIT lv_str AT '.' INTO TABLE gt_split. DATA(lv_zs) = VALUE #( gt_split[ 1 ]-string OPTIONAL ). DATA(lv_xs) = VALUE #( gt_split[ 2 ]-string OPTIONAL ). *整数部分 1234。 IF strlen( lv_zs ) - 6 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 6 PLACES LEFT. in_table-zje_sw = lv_str+0(1)."十万 * FIND REGEX `^[0-9]+$` IN IN_TABLE-ZJE_SW. ENDIF. IF strlen( lv_zs ) - 5 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 5 PLACES LEFT. in_table-zje_w = lv_str+0(1)."万 ENDIF. IF strlen( lv_zs ) - 4 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 4 PLACES LEFT. in_table-zje_1000 = lv_str+0(1)."千 ENDIF. IF strlen( lv_zs ) - 3 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 3 PLACES LEFT. in_table-zje_100 = lv_str+0(1)."百 ENDIF. IF strlen( lv_zs ) - 2 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 2 PLACES LEFT. in_table-zje_10 = lv_str+0(1)."十 ENDIF. IF strlen( lv_zs ) - 1 >= 0. lv_str = lv_zs. SHIFT lv_str BY strlen( lv_str ) - 1 PLACES LEFT. in_table-zje_1 = lv_str+0(1)."元 ENDIF. *小数部分 IF strlen( lv_xs ) - 3 >= 0. lv_str = lv_xs. SHIFT lv_str BY strlen( lv_str ) - 3 PLACES LEFT. in_table-zje_jiao = lv_str+0(1)."角 ENDIF. IF strlen( lv_xs ) - 2 >= 0. lv_str = lv_xs. SHIFT lv_str BY strlen( lv_str ) - 2 PLACES LEFT. in_table-zje_fen = lv_str+0(1)."分 ENDIF. APPEND in_table.CLEAR in_table.