星期五, 六月 04, 2010

ABAP处理所有异常

语法,


TRY.

  ...                       " TRY block (application coding)

CATCH cx_... cx_... ...

    ...                     " CATCH block (exception handler)

CATCH cx_... cx_... ...

    ...                     " CATCH block (exception handler)

  ...

  CLEANUP.

    ...                     " CLEANUP block (cleanup context)

ENDTRY.

如果想处理所有异常,使用

catch cx_root.


  1. A TRY block, in which exceptions can occur.
    This exception block consists of all the statements between the TRY and the CATCH statement.
  2. One or more CATCH blocks for catching exceptions.
    These exception blocks are initiated with CATCH and ended with a further CATCH, CLEANUP, or ENDTRY.
  3. A CLEANUP block for cleanup work after the exceptions have been caught.
    This statement block is initiated by CLEANUP and ended with ENDTRY. A TRY-ENDTRY structure must not contain more than one CLEANUP block in precisely this position.