abap异常处理--第一篇

    技术2022-05-18  11

    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

     

     

     


    最新回复(0)