AS ABAP Release 758, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - Programming Language → Data Interfaces and Communication Interfaces → ABAP and XML → XML - Class Libraries → iXML Library → iXML - Classes and Interfaces →iXML - Downcasts
For reference variables with the static type of the interfaces IF_IXML_... of the iXML Library, the usual downcasts with the casting operators ?= and CAST can be used for assignments from more general to more specific types. If a downcast fails, the exception CX_SY_MOVE_CAST_ERROR is raised, which can be handled in a TRY control structure as usual.
The method QUERY_INTERFACE of the interface IF_IXML_UNKNOWN included by every object in iXML Library can be used to simplify exception handling:
type can be used to specify the required special type by specifying a constant ixml_iid... from the type pool IXML. A successful downcast runs as if no method is called. If an error occurs, the exception is handled in the method and an initial reference returned.
Executable Example