Ansicht
Dokumentation

ABENTRY_ABEXA - TRY ABEXA

ABENTRY_ABEXA - TRY ABEXA

TXBHW - Original Tax Base Amount in Local Currency   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

Exceptions, TRY

This example demonstrates the TRY control structure.

Source Code

Execute

Description

  • If the content of number is greater than 100, the TRY control structure of the compilation unit raises an exception of the class CX_DEMO_ABS_TOO_LARGE in the TRY block. This exception is handled by the second CATCH block of the same TRY control structure, since the subclass of the most general exception is CX_ROOT.
  • If the content of number is 0, the runtime framework in the TRY block of the TRY control structure of the called method calculation raises an exception of the predefined class CX_SY_ZERODIVIDE. This is handled in the CATCH block of the same TRY control structure.
  • If the content of number is a negative number, the runtime framework in the TRY block of the TRY control structure of the called method calculation raises an exception of the predefined class CX_SY_ARG_OUT_OF_DOMAIN. Since no handler is defined for this exception in this TRY control structure, the exception is propagated from the method, which is made possible by the declaration of the superclass CX_SY_ARITHMETIC_ERROR using RAISING in the method interface. The CLEANUP block of the inner TRY control structure is executed first.
  • Any other exceptions are handled in the final CATCH block of the TRY control structure of the compilation unit, which catches all possible exceptions by specifying the most generic exception class CX_ROOT. If, for example, CX_SY_ARG_OUT_OF_DOMAIN or one of its superclasses was not declared in the method interface, the exception CX_SY_NO_HANDLER would be raised and would be handled in the final CATCH block.





CL_GUI_FRONTEND_SERVICES - Frontend Services   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 2171 Date: 20240329 Time: 155014     sap01-206 ( 55 ms )