Error situations are always a possibility when a program is being executed. Among all, runtime errors indicate situations in which the meaningful program flow is no longer possible, and the execution of an ABAP program must be terminated. ABAP offers various methods for responding to error situations. Runtime errors can occur in one of the following situations:
A catchable exception is not handled.
An uncatchable exception is raised.
If an exception is handled properly, the short dump can be avoided, and normal termination of the program is achieved. So, the performance of the software is not affected as well. In this blog you can learn how to properly handle the exceptions. Also check exception handeling section in ABAP Keyword Documentation.
Another situation in which a runtime error raise is:
The statement RAISE SHORTDUMP or the addition THROW SHORTDUMP is used.
An assertion fails.
An exit message or message of type X is sent
The statement RAISE SHORTDUMP is an alternative to raising exit messages from release 7.54. That is, messages of type X. MESSAGE_TYPE_X represent a situation in which the program does not know what to do!
The attributes of the exception class can be used to send more information about an error to the short dump than a message text. The addition THROW SHORTDUMP in a conditional expression makes it possible to raise a runtime error in an operand position where assertions help verify certain assumptions about the state of a program in a particular location and ensure that these assumptions are met. From now on, the program-driven termination of a program should be implemented using RAISE SHORTDUMP, THROW SHORTDUMP, or ASSERT and not using exit messages.
As said, dumps happen when something goes wrong during an ABAP program runs and cannot be handled by the program. If you as an ABAP programmer really nead to raise a dump, you can use the statement RAISE SHORTDUMP which interrupts the execution of the current statement block and raises a runtime error that performs a database rollback, means the end of a database LUW in which all modifying database operations are undone until the beginning of the LUW.
The statement RAISE SHORTDUMP works roughly in the same way as when raising a class-based exception that does not have a handler and so it cannot be caught using CATCH. The exception object is used exclusively for the transport of information to the short dump. The syntax is as follows:
This runtime error is linked with an exception object that contains information on the exception situation using TYPE or oref:
If the addition TYPE is specified, an exception object of the exception class cx_class is created. Every exception class cx_class visible at this point can be specified after TYPE. The exception category is ignored.
The addition message can be used to link the exception object to a message.
The addition EXPORTING can be used to assign actual parameters to the input parameters of the instance constructor. The syntax and semantics are the same as the one for the statement RAISE EXCEPTION.
oref is a general expression position. If oref is specified, no new exception object is created. oref expects an object reference variable that points to an existing exception object. The static type of oref must be an exception class, that is, a subclass of CX_ROOT or the class itself. In the existing exception object, the internal attributes that describe the location of the exception are converted to the position of the RAISE statement.
Raising of a runtime error with an exception object of the exception class CX_DEMO_T100. The instance constructor is supplied with parameters that define the exception text and supply any variable text parts with values.
The short dump of the runtime error contains the name of the exception class and the exception text. The attributes of the exception object can be listed in the transaction ST22. Under Chain of Exception Objects, the long text of the short dump contains the attributes referenced in the attribute PREVIOUS of the exception object.
If a caught exception is transformed into a runtime error, it should be noted that the exception object does not remain unchanged and the information about the position of the exception is changed instead. If the original information is transported to the short dump, a new exception object of the same class can be created. The original exception object is passed to the constructor parameter PREVIOUS of the new object.
Raising of a runtime error when an exception is handled. A reference to the preceding exception object of the class cx_sy_zerodivide is passed to the attribute PREVIOUS of the created exception object of the class cx_demo. The chain of exception objects is listed in the long text of the short dump.
CLASS cx_demo DEFINITION INHERITING FROM cx_static_check.
CLASS demo DEFINITION.
CLASS-METHODS main RAISING cx_sy_zerodivide.
CATCH cx_sy_zerodivide INTO DATA(oref).
RAISE SHORTDUMP TYPE cx_demo EXPORTING previous = oref.
Raise a short dump- Message
The addition MESSAGE of the statement RAISE SHORTDUMP and of the addition THROW SHORTDUMP in a conditional expression passes the specification of a message to the exception object. Syntax and semantics are the same as in the addition MESSAGE of the statement RAISE EXCEPTION. Keep in mind that this addition cannot be specified after the variant RAISE SHORTDUMP oref.
Raising of a runtime error with an exception object of the exception class CX_DEMO_T100, which implements the interface IF_T100_MESSAGE. The additions MESSAGE and EXPORTING are used to pass the properties of a message that determines the exception text.
RAISE SHORTDUMP TYPE cx_demo_t100
MESSAGE ID 'SABAPDEMOS'
EXPORTING text1 = 'I'
text2 = 'need'
text3 = 'a'
text4 = 'break!'.
Raising of a runtime error with an exception object of the exception class CX_DEMO_DYN_T100, which implements the interface IF_T100_DYN_MSG. The addition USING MESSAGE is used to pass the properties of a previously sent message that determines the exception text.
MESSAGE ID 'SABAPDEMOS'
WITH 'I' 'need' 'a' 'break!'.
RAISE SHORTDUMP TYPE cx_demo_dyn_t100
With this, i hope you get some idea how to handel a dump properly. If you want to know more about RAISE SHORTDUMP and its application, I suggest you to check ABAP Keyword Documentation.