ABAP顾问
分类:
2008-11-25 13:45:22
DATA: pp TYPE p DECIMALS 2.
DATA: cxroot TYPE REF TO cx_root,
exception_msg(1000),
msg(1000).
PARAMETERS: str(6) .
**方法1
TRY .
pp = str.
CATCH cx_root INTO cxroot.
msg = cxroot->get_text( ).
WRITE:/ msg.
ENDTRY.
**方法2
CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
pp = str .
ENDCATCH.
IF sy-subrc <> 0.
WRITE / 'Error!'.
ENDIF.
**方法3
DATA str_tmp TYPE string .
str_tmp = str.
IF NOT str_tmp CO '0123456789.-'.
WRITE / 'Err'.
ELSE.
pp = str_tmp.
ENDIF.
WRITE / pp.