ABAP 调用程序时获取的数量,金额和日期字段会出现 逗号,-,负号等非法字段,所需要进行转化

金额和数量转换,有些为负的需要先把负号去掉。

 DATA  l_dcpfm LIKE usr01-dcpfm.  

SELECT SINGLE dcpfm INTO l_dcpfm
  FROM usr01
  WHERE bname = sy-uname.

  IF lv_string CS '-'.
                  SPLIT  lv_string AT '-' INTO gs_out-erfmg_c lv_string2.
                ELSE.
                  gs_out-erfmg_c = lv_string.
                ENDIF.
                CALL FUNCTION 'UNITS_STRING_CONVERT'
                  EXPORTING
                    units_string = gs_out-erfmg_c
                    dcpfm        = l_dcpfm    "此时为X
*                   MLLN         = 'M'
*                   TSND         = 'T'
                  IMPORTING
                    units        = gs_out-erfmg
                  EXCEPTIONS
                    invalid_type = 1
                    OTHERS       = 2.
                IF lv_string CS '-'.
                  gs_out-erfmg = 0 - gs_out-erfmg.
                ENDIF.

日期转换
                CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
                  EXPORTING
                    date_external            = gs_out-budat_c
*                   ACCEPT_INITIAL_DATE      =
                  IMPORTING
                    date_internal            = gs_out-budat
                  EXCEPTIONS
                    date_external_is_invalid = 1
                    OTHERS                   = 2.
                IF sy-subrc = 0.

                ENDIF.

上一篇:工程变更号的创建CCAP_ECN_CREATE 实例


下一篇:ABAP 调用标准报表程序,获取程序输出list