SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → program editing → Testing and Checking Programs → Checkpoints →
ASSERT
Syntax
ASSERT [ [ID group [SUBKEY sub]]
[FIELDS val1 val2 ...]
CONDITION ] log_exp.
Extras:
1. ... ID group
2. ... SUBKEY sub
3. ... FIELDS val1 val2 ...
4. ... CONDITION
Effect
This statement defines an assertion. Any logical expression can be specified for log_exp. When the program reaches an active assertion, the logical expression is evaluated and the program execution continues from the statement after ASSERT only if the result of log_exp is true. After an inactive assertion, the logical expression log_exp is not evaluated and the program execution continues at the statement after ASSERT.
If the result of log_exp is false, a non-handleable exception is raised for an assertion that is always active (without the addition ID) and the program terminates with the runtime error ASSERTION_FAILED.
For an assertion activated externally (with the addition ID specified), the operation mode specified for a checkpoint group or the current compilation unit determines how the program execution is continued. The following settings are possible:
Programming Guideline
Notes
... ID group
Effect
Without addition ID, the assertion is always active. When using addition ID, the activation and the behavior of the statement are controlled from outside the program by means of a checkpoint group. If the addition ID is specified, the addition CONDITION must be specified before the log_exp logical expression.
The addition ID assigns the assertion to a checkpoint group group. The name of the checkpoint group must be specified directly and the group must exist in the repository. To administer a checkpoint group, use transaction SAAB. In a checkpoint group, activation settings can be made for the assigned checkpoints either directly or using activation variants.
All checkpoint statements associated with the checkpoint group (ASSERT, BREAK-POINT, LOG-POINT) can be activated or deactivated from the checkpoint group. An activation setting consists of the following components:
If the checkpoint statements are activated from the compilation unit, the association with a specific checkpoint group no longer has any meaning.
Notes
Executable Example
Checkpoints and Checkpoint Groups.
... SUBKEY sub
Effect
The addition SUBKEY only takes effect if the statement ASSERT writes entries to a log. If SUBKEY is specified, the content of sub is stored in the log as a subkey. Any existing log entries of the same ASSERT statement are overwritten only if the subkey has the same content. If SUBKEY is not specified, the subkey is initial.
sub is a
character-like expression position of which the first 200 characters are evaluated. An expression or function specified here is evaluated only if the assertion is active and the logical expression is false.
... FIELDS val1 val2 ...
Effect
After the addition FIELDS, a list val1 val2 ... of any values (except reference variables) can be specified. If the statement ASSERT writes entries to a log, the content of the data objects val1 val2 ... is included in the log. If an non-handleable exception is raised, the content of the first eight specified data objects is displayed in the associated short dump. The addition FIELDS is ignored when a jump to ABAP Debugger is performed.
val1 val2 ... are functional operand positions at which data objects or functional methods can be specified. The methods are executed only if the assertion is active and the logical expression is false.
If the addition FIELDS is specified, the addition CONDITION must be specified before the log_exp logical expression.
Notes
... CONDITION
Effect
The addition CONDITION triggers the logical expression. It has to be specified
before log_exp if one of the other additions is specified; otherwise, it can be omitted.