abap异常处理--第一篇

来源:互联网 发布:jupiter python 编辑:程序博客网 时间:2024/06/06 07:39

abap异常分类:

1)基于异常类的异常,相当于java中的exception体系

2)非异常类异常,这种异常又分为系统定义异常(相当于java中的error体系)和用户自定义异常(用法同java throw exception)

 

示例一:处理异常

program:

 data: result type decimals 2,
      number type value 0.
data oref   TYPE REF TO cx_root.
data text type string.
try.
  RESULT =  / NUMBER.
write: / 'Result of division:', RESULT.
RESULT = SQRT( NUMBER ).
write: / 'Result of square root:', RESULT.
catch CX_SY_ZERODIVIDE into OREF.
  TEXT = OREF->GET_TEXT( ).
  write text.
clear RESULT.
endtry.

 

result:

Division by zero

 

 

 

原创粉丝点击