Ansicht
Dokumentation

ABENEXCEPTION_CATEGORIES - EXCEPTION CATEGORIES

ABENEXCEPTION_CATEGORIES - EXCEPTION CATEGORIES

Vendor Master (General Section)   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

Exception Categories

Exception classes are subclasses of the following abstract classes:

The assignment to one of the three abstract subclasses of CX_ROOT determines the exception category, that is, whether an exception must be declared explicitly in the procedure interface when propagating from a procedure, and how the declaration is checked:

  • CX_STATIC_CHECK
If exceptions defined using subclasses of CX_STATIC_CHECK are propagated from a procedure, they must be explicitly declared in the interface of the procedure. The syntax check statically checks whether all exceptions raised in the procedure using RAISE EXCEPTION or the addition THROW in a conditional expression, or declared in the interfaces of called procedures are either handled using CATCH or declared explicitly in the interface, and produces a warning if this is not the case.
  • CX_DYNAMIC_CHECK
If exceptions defined using subclasses of CX_DYNAMIC_CHECK are propagated from a procedure, they must be declared explicitly in the interface of the procedure. However, this is not checked statically by the syntax check, but dynamically at that moment when such an exception is propagated from a procedure.
  • CX_NO_CHECK
Exceptions that are defined using subclasses of CX_NO_CHECK can always be propagated, whereby a possible resumability is preserved. It is not necessary to declare exceptions defined using subclasses of CX_NO_CHECK in the interface of a procedure. They are declared implicitly, but it is also possible to declare subclasses of CX_NO_CHECK explicitly in the interface of a procedure. On the one hand, this can be used to document the possible occurrence of exceptions of this category. On the other hand, this makes it possible to change the category of existing exceptions to CX_NO_CHECK without causing errors in interface definitions.

If an exception of category CX_STATIC_CHECK or CX_DYNAMIC_CHECK is propagated from the procedure but not declared in the interface of the procedure, the interface is violated and an exception of the predefined class CX_SY_NO_HANDLER is raised at the call point of the procedure. The exception object of the exception contains a reference to the original exception in the attribute PREVIOUS. An exception of category CX_NO_CHECK can be propagated independently of its explicit declaration in the procedure interface.

Use a suitable exception category

Notes

  • Using Exception Categories
  • Exceptions of the CX_STATIC_CHECK category are always justified if the direct caller of a procedure is to be forced to handle the exception or to at least explicitly forward it. However, if an exception can be prevented by prior checks, exceptions of the CX_DYNAMIC_CHECK category are preferable. Otherwise untestable dead code can be created because corresponding exception handling is necessary, but it is never processed when the interface is used correctly.

  • If the program logic can eliminate potential error situations, the corresponding exceptions do not have to be handled or declared in the interface. This is the case, for example, if, prior to a division, there is an explicit requirement for the denominator not to equal zero (precondition). In this case, exceptions of the CX_DYNAMIC_CHECK category can be used. These exceptions only need to be handled and declared if their occurrence cannot be otherwise prevented.

  • For exception situations that can occur practically at any time or that cannot be handled directly, the CX_NO_CHECK category can be used. Otherwise, these exceptions would have to be declared in almost every interface, which would result in more complex programs lacking in clarity.

  • Most predefined CX_SY_... exceptions for error situations in the runtime framework are subclasses of CX_DYNAMIC_CHECK. As a result, not every potential exception of every ABAP statement has to be handled or declared, only those whose occurrence cannot be prevented.
  • The caller of a procedure must anticipate that the procedure propagates exceptions from category CX_NO_CHECK in addition to explicitly declared exceptions. Some of the predefined CX_SY_... exceptions for error situations in the runtime framework are subclasses of CX_NO_CHECK.
  • Interface violations normally only occur for exceptions of the category CX_DYNAMIC_CHECK, since exceptions of the category CX_STATIC_CHECK are checked first by the syntax check and exceptions of the category CX_NO_CHECK can pass each interface.
  • The resumability of an exception is not specified as a property of the exception class and is instead defined by the addition RESUMABLE of the statement RAISE EXCEPTION or the addition THROW in a conditional expression when the exception is raised. This property can be lost for exceptions of type CX_STATIC_CHECK and CX_DYNAMIC_CHECK during propagation of parameter interfaces of procedures, if they are not also declared there with RESUMABLE.





PERFORM Short Reference   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 7217 Date: 20240328 Time: 185249     sap01-206 ( 155 ms )