We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
CASE TYPE OF oref.
$[WHEN TYPE class$|intf $[INTO target1$].
$[statement_block1$]$]
$[WHEN TYPE class$|intf $[INTO target2$].
$[statement_block2$]$]
...
$[WHEN OTHERS.
$[statement_blockn$]$]
ENDCASE.
Special case distinction for object reference variables. This form of a control structure introduced using CASE checks the dynamic type of a non-initial object reference variable and the static type of an initial object reference variable oref. oref expects an object reference variable with the static type of a class or an interface. oref is a general expression position.
A class class or an interface intf that can be used at this position must be specified after WHEN TYPE. The first statement block statement_block is executed for which the class class or the interface intf is more general than or equal to the following:
If this does not apply to any class class or interface intf, the statement block is executed after WHEN OTHERS. No object type class or intf can be specified if it is known statically that it does not fulfill the condition.
Case distinction for the dynamic type of an object reference variable oref, from more specific to more general classes. In the case shown, c2 is the first class that fulfills the condition. oref can be assigned to ref2 with static type c2 without raising an exception.
Case Distinction CASE TYPE OF for Exceptions
... INTO target
For every statement WHEN TYPE of a case distinction introduced using CASE TYPE OF, a target variable target can be specified after the optional addition INTO as follows:
If the addition INTO is specified in the first WHEN statement that fulfills the condition, the reference oref is assigned to ref before the statement block is executed, whereby both upcasts and downcasts can be performed.
The statement
WHEN TYPE class$|intf INTO ref.
is a semantically identical short form of
WHEN TYPE class$|intf.
ref = oref.
The statement
WHEN TYPE class$|intf INTO DATA(ref).
is a semantically identical short form of
WHEN TYPE class$|intf.
DATA(ref) = CAST class$|intf( oref ).
The following case distinction shows the short form of the case distinction of the previous example.
Case Distinction CASE TYPE OF for RTTI
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki