
Text elements are really old-school. They are stored with a report or a class and are accessible by other parts of the application only indirectly. There are are approaches to avoid these problems (see this old blog of mine). However, the online text repository (OTR) frame offers a more modern way to handle texts. Here some points that made me switch to OTR:
With OTR texts, all the above is resolved. However, the coding blows up a bit. Instead of writing
logger->add( 'Something's wrong'(001) ).
You have to code something like this:
logger->add( new CL_BSP_GET_TEXT_BY_ALIAS(
)->get_text(
language = sy-langu
alias = 'ZDV24_TEXT_ACCESS_DEMO/EXAMPLE' ) ).
I created a small framework for this in order to streamline the use. It is available for download on github. With this, the coding turns out to be a bit friendlier:
class text definition inheriting from zcl_otr_util_demo_text_enum.
endclass.
class app definition inheriting from zcl_otr_util_demo_texts.
public section.
methods main.
endclass.
CLASS app IMPLEMENTATION.
method main.
cl_demo_output=>display( get_text( text=>the_text ) ).
endmethod.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
8 | |
6 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |