-
Notifications
You must be signed in to change notification settings - Fork 3
The ZCX_ABAK exception
ZCX_ABAK
is the root exception class for everything related to abaK
. The abaK
classes and methods will only yield exceptions of this type or of one of its subtypes.
If you need to raise specific error messages in your CONTENT
and FORMAT
custom extensions, make sure these inherit from ZCX_ABAK
.
ZCX_ABAK
inherits from CX_STATIC_CHECK
to which it adds two extra functionalities which will be explained below.
A lot of the exceptions yielded by ZIF_ABAK
will be chained. This means the exception will actually be a tree of exceptions in which the actual original exception is buried one or more levels deep. Exception chaining is a standard functionality in ABAP and is done through the use of the PREVIOUS
attribute.
Because ZCX_STATIC_CHECK->GET_TEXT()
and ZCX_STATIC_CHECK->GET_LONGTEXT()
don't take PREVIOUS
into consideration, using them will only return the message text of the parent exception which is usually too generic. Getting to the relevant message requires walking down the PREVIOUS
path.
For convenience, ZCX_ABAK
redefines both GET_TEXT()
and GET_LONGTEXT()
so that it always returns the message text of the deepest level, which is usually the one we need.
Some of the errors are not class exceptions. They are, instead, the result of a MESSAGE
command. The details of the last issued MESSAGE command can be found in some fields of standard structure SYST
.
An optional flag parameter called PREVIOUS_FROM_SYST
was added to the ZCX_ABAK
constructor. When this parameter is set to true, ZCX_ABAK will be automatically created based on the message details found in SYST
. Example:
Let's assume that, at some point, a BAPI or a Function module were called or an explicit MESSAGE command was issued. This code will wrap that message into a proper abaK
OO exception:
DATA: o_exp TYPE REF TO zcx_abak.
CREATE OBJECT o_exp
EXPORTING
previous_from_syst = abap_true.
Technical note: Since the constructor of ABAP exception class is automatically generated and, thus, cannot be manually edited, this feature was implemented through enhancement ZABAK_CX_ABAK
.