-
Notifications
You must be signed in to change notification settings - Fork 0
How to extend the text getter
Jörg Neumann edited this page Apr 25, 2024
·
3 revisions
The text getter can handle OTR-based and T100-based exceptions, which should be enough for most cases. If you should ever have to deal with an exception, that can not be handled by the default implementations, you can enhance the solution by additional text extractors.
The class definition of a new text extractor should look like this:
CLASS zcl_my_text_extractor DEFINITION FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES /usi/if_exception_text.
METHODS constructor
IMPORTING
i_exception TYPE REF TO cx_root.
PRIVATE SECTION.
DATA exception_text TYPE symsg.
ENDCLASS.
The implementation part should look like this:
CLASS zcl_my_text_extractor IMPLEMENTATION.
METHOD constructor.
" It is recommended to fill a private attribute (e.g. exception_text)
" here and to make get_text_as_symsg return that private attribute.
"
" This avoids extracting the text multiple times if somebody should
" call get_text_as_symsg( ) more than once.
ENDMETHOD.
METHOD /usi/if_exception_text~get_text_as_symsg.
r_result = exception_text.
ENDMETHOD.
ENDCLASS.
IMPORTANT: The instance creation must be public and the declaration of the constructor must look exactly like in the example. Otherwise the class will be ignored!
After implementing the new text extractor class it needs to be added to the basic customizing.