SAP CONDITIONAL EXPRESSION RESULT



Get Example source ABAP code based on a different SAP table
  


• THROW COND
• THROW SWITCH

COND, SWITCH, result

ABAP_SYNTAX
... operand
$| ${ THROW $[RESUMABLE$|SHORTDUMP$] cx_class( $[ message$]
$[p1 = a1 p2 = a2 ...$] ) $} ...

ABAP_ALTERNATIVES:
1 ... operand
2 ... THROW $[RESUMABLE$|SHORTDUMP$] cx_class( $[message$] $[p1 = a1 p2 = a2 ...$] )

What does it do?
These specifications after THEN and ELSE in the conditional expressions COND and SWITCH determine the result of the expression when the corresponding branch is selected.

ABAP Alternative 1 ... operand

What does it do?
If an operand operand is specified, its value is converted to the data type type if necessary and returned as the result of the conditional expression. operand is a general expression position with the following restrictions:
If operand is specified as a string expression, type must be character-like.
If operand is specified as a bit expression, type must be byte-like.



Latest notes:

When an operand is specified, the conditional operators COND and SWITCH create a temporary data object whose data type is determined by the specified type and whose content is determined by the selected operand. This data object is used as the operand of a statement and then deleted. It is deleted either when the current statement is completed or when a relational expression is evaluated after the truth value is determined.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Specification of the operands sum and sum + 1. The number of times a random number is less than half of its maximum value is counted.
ABEXA 00884
ABAP_EXAMPLE_END
• MESSAGE THROW
• RESUMABLE THROW
• SHORTDUMP THROW
• = THROW

ABAP Alternative 2 ... THROW $[RESUMABLE$|SHORTDUMP$] cx_class( $[message$] $[p1 = a1 p2 = a2 ...$] )

What does it do?
The specification of THROW raises either an exception or a runtime error.
If the addition SHORTDUMP is not specified, THROW works like the statement RAISE EXCEPTION TYPE and raises an exception of the exception class cx_class. The following applies here:
The addition RESUMABLE can be used to make the exception resumable.
A message can be passed to the exception object using the addition message.
The input parameters p1, p2, ... of the instance constructor can be filled with actual parameters a1, a2.
If the addition SHORTDUMP is specified, THROW works like the statement RAISE SHORTDUMP TYPE and raises a runtime error with the exception class cx_class, whereby a message can be also passed and the input parameters can be filled.



Latest notes:

If the exception class is specified after THROW, the parentheses must always be specified, even if no messages or actual parameters are passed. EXPORTING cannot be specified, nor is it necessary.
NON_V5_HINTS
Like the statement RAISE EXCEPTION , the specification THROW without the addition SHORTDUMP cannot be used in a method or function module in whose interface non-class-based exceptions are declared. Furthermore, it does not allow simultaneous use of the statement CATCH SYSTEM-EXCEPTIONS for the obsolete handling of catchable runtime errors, and the statements RAISE or MESSAGE RAISING to raise non-class-based exceptions in the current processing block.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Raising of an exception of the class CX_DEMO_DYN_T100 that implements the interface IF_T100_DYN_MSG.
ABEXA 00885
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Raising of a runtime error with an exception object of the class CX_DEMO_DYN_T100, which implements the interface IF_T100_DYN_MSG.
ABEXA 00886
ABAP_EXAMPLE_END