ABAP 命令の例外クラス

以下主要是为了便于以后开发时方便使用,特拷贝于sap帮助文件


CX_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_TAB_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_FIND_INFINITE_LOOP
  |    |
  |    |--CX_SY_GEN_SOURCE_TOO_WIDE
  |    |
  |    |--CX_SY_IMPORT_MISMATCH_ERROR
  |    |
  |    |    |--CX_SY_IMPORT_FORMAT_ERROR
  |    |
  |    |--CX_SY_INVALID_REGEX
  |    |
  |    |--CX_SY_MATCHER
  |    |
  |    |    |--CX_SY_REGEX_TOO_COMPLEX
  |    |    |
  |    |    |--CX_SY_INVALID_REGEX
  |    |
  |    |--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


这里简单的做一个使用的例子:

  DATA LDF_SEG  TYPE I.
  TRY .
    LDF_SEG 'abc'.
  CATCH CX_SY_CONVERSION_NO_NUMBER.
    MESSAGE E010(YGCAWITH 'abc'.
  ENDTRY.


本例来源于abap help

PARAMETERS number TYPE i.
DATA: result TYPE p LENGTH 8 DECIMALS 2,
      oref   TYPE REF TO cx_root,
      text   TYPE string.

TRY.
    IF ABS( number ) > 100.
      RAISE EXCEPTION TYPE cx_demo_abs_too_large.
    ENDIF.
    PERFORM calculation USING    number
                      CHANGING result
                               text.
  CATCH cx_sy_arithmetic_error INTO oref.
    text = oref->get_text( ).
  CATCH cx_root INTO oref.
    text = oref->get_text( ).
ENDTRY.

IF NOT text IS INITIAL.
  WRITE / text.
ENDIF.

WRITE: / 'Final result:', result.

FORM calculation USING    p_number LIKE number
                 CHANGING p_result LIKE result
                          p_text   LIKE text
                          RAISING  cx_sy_arithmetic_error.

  DATA l_oref TYPE REF TO cx_root.

  TRY.
      p_result =  1 / p_number.
      WRITE: / 'Result of division:', p_result.
      p_result = SQRT( p_number ).
      WRITE: / 'Result of square root:', p_result.
    CATCH cx_sy_zerodivide INTO l_oref.
      p_text = l_oref->get_text( ).
    CLEANUP.
      CLEAR p_result.
  ENDTRY.

ENDFORM. 





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值