在sap6.10版本里,exception classes已经取代了catchable runtime errors,Each exception class includes
message texts 下面是异常类的继承层结构,想要查看每个类的描述,用类制作器进行查看
CX_SY_ROOT
|
|--CX_STATIC_CHECK :
|
|--CX_DYNAMIC_CHECK
| |
| |--CX_SY_ARITHMETIC_ERROR
| | |
| | |-- CX_SY_ZERODIVIDE
| | |
| | |-- CX_SY_ARITHMETIC_OVERFLOW
| | |
| | |-- CX_SY_ARG_OUT_OF_DOMAIN
| | |
| | |-- CX_SY_PRECISION_LOSS
| |
| |--CX_SY_ASSIGN_ERROR
| | |
| | |-- CX_SY_ASSIGN_CAST_ERROR
| | | |
| | | |-- CX_SY_ASSIGN_CAST_ILLEGAL_CAST
| | | |
| | | |-- CX_SY_ASSIGN_CAST_UNKNOWN_TYPE
| | |
| | |-- CX_SY_ASSIGN_OUT_OF_RANGE
| |
| |--CX_SY_CODEPAGE_CONVERTER_INIT
| |
| |--CX_SY_CONVERSION_ERROR
| | |
| | |-- CX_SY_CONVERSION_OVERFLOW
| | |
| | |-- CX_SY_CONVERSION_NO_NUMBER
| | |
| | |-- CX_SY_CONVERSION_CODEPAGE
| | |
| | |-- CX_SY_CONVERSION_BASE64
| | |
| | |-- CX_SY_CONV_ILLEGAL_DATE_TIME
| |
| |--CX_SY_CREATE_ERROR
| | |
| | |-- CX_SY_CREATE_OBJECT_ERROR
| | |
| | |-- CX_SY_CREATE_DATA_ERROR
| |
| |--CX_SY_DATA_ACCESS_ERROR
| | |
| | |-- CX_SY_RANGE_OUT_OF_BOUNDS
| | |
| | |-- CX_SY_OFFSET_NOT_ALLOWED
| |
| |--CX_SY_DYN_CALL_ERROR
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_CLASS
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_FORM
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_FUNC
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_METHOD
| | |
| | |-- CX_SY_DYN_CALL_PARAMETER_ERROR
| | |
| | |-- CX_SY_DYN_CALL_EXCP_NOT_FOUND
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_TYPE
| | |
| | |-- CX_SY_DYN_CALL_PARAM_MISSING
| | |
| | |-- CX_SY_DYN_CALL_PARAM_NOT_FOUND
| |
| |--CX_SY_FILE_ACCESS_ERROR
| | |
| | |-- CX_SY_FILE_AUTHORITY
| | |
| | |-- CX_SY_FILE_CLOSE
| | |
| | |-- CX_SY_FILE_IO
| | |
| | |-- CX_SY_FILE_OPEN
| | |
| | |-- CX_SY_FILE_OPEN_MODE
| | |
| | |-- CX_SY_FILE_POSITION
| | |
| | |-- CX_SY_FILE_TRUNCATE
| |
| |--CX_SY_GEN_SOURCE_TOO_WIDE
| |
| |--CX_SY_IMPORT_MISMATCH_ERROR
| |
| |--CX_SY_MOVE_CAST_ERROR
| |
| |--CX_SY_PROGRAM_NOT_FOUND
| |
| |--CX_SY_PROVIDE_EXCEPTION
| | |
| | |-- CX_SY_PROVIDE_INTERVAL_OVERLAP
| | |
| | |-- CX_SY_PROVIDE_TABLE_NOT_SORTED
| |
| |--CX_SY_READ_SRC_LINE_TOO_LONG
| |
| |--CX_SY_REF_IS_INITIAL
| |
| |--CX_SY_REPLACE_INFINITE_LOOP
| |
| |--CX_SY_SCAN_SOURCE_TOO_WIDE
| |
| |--CX_SY_SQL_ERROR
| | |
| | |-- CX_SY_OPEN_SQL_ERROR
| | | |
| | | |-- CX_SY_OPEN_SQL_DB
| | | |
| | | |-- CX_SY_DYNAMIC_OSQL_ERROR
| | | |
| | | |--CX_SY_DYNAMIC_OSQL_SEMANTICS
| | | |
| | | |--CX_SY_DYNAMIC_OSQL_SYNTAX
| | |
| | |-- CX_SY_NATIVE_SQL_ERROR
| |
| |--CX_SY_WRITE_SRC_LINE_TOO_LONG
| |
| |--CX_XSLT_EXCEPTION
| |
| |--CX_XSLT_SYSTEM_ERROR
| |
| |-- CX_XSLT_ABAP_CALL_ERROR
| |
| |-- CX_XSLT_DESERIALIZATION_ERROR
| |
| |-- CX_XSLT_FORMAT_ERROR
| |
| |-- CX_XSLT_RUNTIME_ERROR
| |
| |-- CX_XSLT_SERIALIZATION_ERROR
|
|--CX_NO_CHECK
|
|--CX_SY_EXPORT_NO_SHARED_MEMORY
|
|--CX_SY_EXPORT_BUFFER_NO_MEMORY
|
|--CX_SY_GENERATE_SUBPOOL_FULL
|
|--CX_SY_LOCALIZATION_ERROR
|
|--CX_SY_NO_HANDLER
|
|--CX_SY_PIPES_NOT_SUPPORTED
|
|--CX_SY_PIPE_REOPEN
|
|--CX_SY_REMOTE_CALL_ERROR
| |
| |--CX_SY_RMC_COMM_FAILURE
| |
| |--CX_SY_RMC_INVALID_STATUS
| |
| |--CX_SY_RMC_SYSTEM_FAILURE
|
|--CX_SY_TOO_MANY_FILES
举个例子
使用exception classes
data MYREF type ref to CX_SY_ARITHMETIC_ERROR.
data ERR_TEXT type STRING.
data RESULT type I.
try.
RESULT = 1 / 0.
catch cx_sy_arithmetic_error into MYREF.
ERR_TEXT = MYREF->GET_TEXT( ).
………………
endtry.
这各写法在java里是司通见惯的
===================================
使用catchable runtime errors
data RESULT type I.
catch system-exceptions ARITHMETIC_ERRORS = 4.
RESULT = 1 / 0.
endcatch.
if SY-SUBRC = 4.
...
endif.
message texts 下面是异常类的继承层结构,想要查看每个类的描述,用类制作器进行查看
CX_SY_ROOT
|
|--CX_STATIC_CHECK :
|
|--CX_DYNAMIC_CHECK
| |
| |--CX_SY_ARITHMETIC_ERROR
| | |
| | |-- CX_SY_ZERODIVIDE
| | |
| | |-- CX_SY_ARITHMETIC_OVERFLOW
| | |
| | |-- CX_SY_ARG_OUT_OF_DOMAIN
| | |
| | |-- CX_SY_PRECISION_LOSS
| |
| |--CX_SY_ASSIGN_ERROR
| | |
| | |-- CX_SY_ASSIGN_CAST_ERROR
| | | |
| | | |-- CX_SY_ASSIGN_CAST_ILLEGAL_CAST
| | | |
| | | |-- CX_SY_ASSIGN_CAST_UNKNOWN_TYPE
| | |
| | |-- CX_SY_ASSIGN_OUT_OF_RANGE
| |
| |--CX_SY_CODEPAGE_CONVERTER_INIT
| |
| |--CX_SY_CONVERSION_ERROR
| | |
| | |-- CX_SY_CONVERSION_OVERFLOW
| | |
| | |-- CX_SY_CONVERSION_NO_NUMBER
| | |
| | |-- CX_SY_CONVERSION_CODEPAGE
| | |
| | |-- CX_SY_CONVERSION_BASE64
| | |
| | |-- CX_SY_CONV_ILLEGAL_DATE_TIME
| |
| |--CX_SY_CREATE_ERROR
| | |
| | |-- CX_SY_CREATE_OBJECT_ERROR
| | |
| | |-- CX_SY_CREATE_DATA_ERROR
| |
| |--CX_SY_DATA_ACCESS_ERROR
| | |
| | |-- CX_SY_RANGE_OUT_OF_BOUNDS
| | |
| | |-- CX_SY_OFFSET_NOT_ALLOWED
| |
| |--CX_SY_DYN_CALL_ERROR
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_CLASS
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_FORM
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_FUNC
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_METHOD
| | |
| | |-- CX_SY_DYN_CALL_PARAMETER_ERROR
| | |
| | |-- CX_SY_DYN_CALL_EXCP_NOT_FOUND
| | |
| | |-- CX_SY_DYN_CALL_ILLEGAL_TYPE
| | |
| | |-- CX_SY_DYN_CALL_PARAM_MISSING
| | |
| | |-- CX_SY_DYN_CALL_PARAM_NOT_FOUND
| |
| |--CX_SY_FILE_ACCESS_ERROR
| | |
| | |-- CX_SY_FILE_AUTHORITY
| | |
| | |-- CX_SY_FILE_CLOSE
| | |
| | |-- CX_SY_FILE_IO
| | |
| | |-- CX_SY_FILE_OPEN
| | |
| | |-- CX_SY_FILE_OPEN_MODE
| | |
| | |-- CX_SY_FILE_POSITION
| | |
| | |-- CX_SY_FILE_TRUNCATE
| |
| |--CX_SY_GEN_SOURCE_TOO_WIDE
| |
| |--CX_SY_IMPORT_MISMATCH_ERROR
| |
| |--CX_SY_MOVE_CAST_ERROR
| |
| |--CX_SY_PROGRAM_NOT_FOUND
| |
| |--CX_SY_PROVIDE_EXCEPTION
| | |
| | |-- CX_SY_PROVIDE_INTERVAL_OVERLAP
| | |
| | |-- CX_SY_PROVIDE_TABLE_NOT_SORTED
| |
| |--CX_SY_READ_SRC_LINE_TOO_LONG
| |
| |--CX_SY_REF_IS_INITIAL
| |
| |--CX_SY_REPLACE_INFINITE_LOOP
| |
| |--CX_SY_SCAN_SOURCE_TOO_WIDE
| |
| |--CX_SY_SQL_ERROR
| | |
| | |-- CX_SY_OPEN_SQL_ERROR
| | | |
| | | |-- CX_SY_OPEN_SQL_DB
| | | |
| | | |-- CX_SY_DYNAMIC_OSQL_ERROR
| | | |
| | | |--CX_SY_DYNAMIC_OSQL_SEMANTICS
| | | |
| | | |--CX_SY_DYNAMIC_OSQL_SYNTAX
| | |
| | |-- CX_SY_NATIVE_SQL_ERROR
| |
| |--CX_SY_WRITE_SRC_LINE_TOO_LONG
| |
| |--CX_XSLT_EXCEPTION
| |
| |--CX_XSLT_SYSTEM_ERROR
| |
| |-- CX_XSLT_ABAP_CALL_ERROR
| |
| |-- CX_XSLT_DESERIALIZATION_ERROR
| |
| |-- CX_XSLT_FORMAT_ERROR
| |
| |-- CX_XSLT_RUNTIME_ERROR
| |
| |-- CX_XSLT_SERIALIZATION_ERROR
|
|--CX_NO_CHECK
|
|--CX_SY_EXPORT_NO_SHARED_MEMORY
|
|--CX_SY_EXPORT_BUFFER_NO_MEMORY
|
|--CX_SY_GENERATE_SUBPOOL_FULL
|
|--CX_SY_LOCALIZATION_ERROR
|
|--CX_SY_NO_HANDLER
|
|--CX_SY_PIPES_NOT_SUPPORTED
|
|--CX_SY_PIPE_REOPEN
|
|--CX_SY_REMOTE_CALL_ERROR
| |
| |--CX_SY_RMC_COMM_FAILURE
| |
| |--CX_SY_RMC_INVALID_STATUS
| |
| |--CX_SY_RMC_SYSTEM_FAILURE
|
|--CX_SY_TOO_MANY_FILES
举个例子
使用exception classes
data MYREF type ref to CX_SY_ARITHMETIC_ERROR.
data ERR_TEXT type STRING.
data RESULT type I.
try.
RESULT = 1 / 0.
catch cx_sy_arithmetic_error into MYREF.
ERR_TEXT = MYREF->GET_TEXT( ).
………………
endtry.
这各写法在java里是司通见惯的
===================================
使用catchable runtime errors
data RESULT type I.
catch system-exceptions ARITHMETIC_ERRORS = 4.
RESULT = 1 / 0.
endcatch.
if SY-SUBRC = 4.
...
endif.