ZOTR_UTILITY
A small ABAP framework that reads language-dependent texts from SAP's online text repository through inheritance and named constants rather than a direct API call with a string alias.
Apart from the well-known text elements in programs, SAP offers a more modern way to use language-dependent texts: the online text repository, but reading one still means calling CL_BSP_GET_TEXT_BY_ALIAS by hand with a package-prefixed alias every time. This package wraps that call in two superclasses: one sets the package prefix once, for a class to inherit from wherever it needs texts; the other declares each text as a class-data constant, so it is referenced by name instead of a string alias. Where a text is not present in the logon language, the framework provides the English text if one is available.
Facts
Where it sits
Who is behind it
In the atlas: maintains 5, contributes to 6@jrgkrausmaintainer
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Serving labels, messages and content per user locale
Download
README
quoted from jrgkraus/ZOTR_UTILITY under MIT, readMotivation
For language dependent user interface texts, we used to use text elements in the last decades. However, there is a more modern option for storing texts: the online text repository, that came with BSP and WebDynpro technology, and it is used also by exception classes. What if we want to use this also in our application classes? Here is a package, that offers two classes for an easy usage of OTR texts. They are intended to be used for inheritance.
The SAP basics
Apart from the well-known text elements in programs, SAP offers a more modern way to use language-dependent texts: the online text repository (OTR).
Texts can be maintained by transaction SOTR_EDIT
The alias can be used to fetch the text in ABAP using class CL_BSP_GET_TEXT_BY_ALIAS. In order to not interfere with other packages, use the package as a prefix (recommendation from SAP)
Make sure to use object type CPUB (Public header - ABAP Objects).
After saving, translation can be called directly:
Then, the text can be fetched in ABAP like this:
data(text) = new CL_BSP_GET_TEXT_BY_ALIAS(
)->get_text(
language = sy-langu
alias = 'ZOTR_UTILITY/EXAMPLE' ).
Of course that's not quite convenient. So I created a framework for this
The framework
To use the framework, two classes have to be implemented.
Class to read the texts:
class ZCL_OTR_UTIL_DEMO_TEXTS definition
public
inheriting from zcl_otr_util_texts
create public .
public section.
METHODS constructor.
protected section.
private section.
endclass.
class ZCL_OTR_UTIL_DEMO_TEXTS implementation.
method constructor.
super->constructor( ).
me->package = 'ZOTR_UTILITY'.
endmethod.
endclass.
The only purpose is to setup the prefix for the texts of this package. It is designed to be used as a super class wherever texts are needed. I use this eclipse template to create it:
class ${enclosing_object} definition
public
inheriting from zcl_dv24_text_access
create public .
public section.
METHODS constructor.
protected section.
private section.
endclass.
class ${enclosing_object} implementation.
method constructor.
super->constructor( ).
me->package = '${enclosing_package}'.
endmethod.
endclass.
With this, no further edits are needed .
ENUM class for the texts
class ZCL_OTR_UTIL_DEMO_TEXT_ENUM definition
public
inheriting from zcl_otr_util_enum_texts
create public .
public section.
class-data the_text type self read-only.
class-methods class_constructor.
protected section.
private section.
endclass.
class ZCL_OTR_UTIL_DEMO_TEXT_ENUM implementation.
method class_constructor.
define _element.
&1 = new #( &2 ).
insert value #( value = &2
instance = &1 ) into table elements.
end-of-definition.
_element:
_null ' ',
the_text 'EXAMPLE'.
endmethod.
endclass.
Here, all the texts used in the package can be inserted. The template I use is like this:
class ${enclosing_object} definition
public
inheriting from zcl_dv24_text_enum
create public .
public section.
class-data ${first_element} type self read-only.
class-methods class_constructor.
protected section.
private section.
endclass.
class ${enclosing_object} implementation.
method class_constructor.
define _element.
&1 = new #( &2 ).
insert value #( value = &2
instance = &1 ) into table elements.
end-of-definition.
_element:
_null ' ',
${first_element} '${cursor}'.
endmethod.
endclass.
With this setup, the usage is very simple:
report zp_dv24_text_demo.
class text definition inheriting from zcl_dv24_demo_text_enum.
endclass.
class app definition inheriting from zcl_dv24_demo_texts.
public section.
methods main.
endclass.
CLASS app IMPLEMENTATION.
method main.
cl_demo_output=>display( get_text( text=>the_text ) ).
endmethod.
ENDCLASS.
start-of-selection.
new app( )->main( ).
If the text is not present in the logon language, the framework will provide the text in English, if available.
Others providing
Compare all 15 on the Localization page →- abap_btocs_deeplabap_btocs_deeplA plugin for the B-Tocs ABAP SDK that lets an SAP ABAP server translate with DeepL through an SM59 RFC destination, using a DeepL API key, with a demo program for the first call.independent, abapDeepL translation plugin for the B-Tocs ABAP SDKfrom ABAP
- abap_btocs_libtrlabap_btocs_libtrlA plugin for the B-Tocs ABAP SDK that lets an SAP ABAP server translate with LibreTranslate through an SM59 RFC destination, against an instance hosted on-premise, on a hyperscaler, on SAP BTP or as SaaS.independent, abapLibreTranslate plugin for the B-Tocs ABAP SDKfrom ABAP
- SAP Translation HubSAP Translation HubSAP's translation service for software texts and documents, drawing on repositories of verified and company translations and on machine translation by SAP's neural MT or large language models.sap official, btpTranslation service for software texts and documentsfrom BTP/BAIP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- ABAP_DeepL_clientABAP_DeepL_clientAn ABAP client for the DeepL translation service, so text can be sent for translation from inside the system rather than through a tool outside it.independent, abapABAP client for the DeepL translation servicefrom ABAP
- LISALISAAn MCP server that lets an AI client read and write the translations of ABAP repository objects through three tools, backed by an ABAP HTTP service on SAP's XCO i18n APIs.independent, abapMCP server for reading and writing ABAP object translationsfrom ABAP
- @concircle/i18n-ai-translator@concircle/i18n-ai-translatorA CLI that translates a UI5 app's i18n.properties with OpenAI and writes the language files back, masking placeholders, applying a glossary and caching what has been translated.independent, ui5CLI translating UI5 i18n.properties files with OpenAIfrom UI5
- ABAP_TRANSLATION_HUBABAP_TRANSLATION_HUBA report that pushes an ABAP object list to SAP Translation Hub and pulls the finished translations back, meant to run as a job after the evaluation job has finished.independent, abapReport pushing ABAP objects to SAP Translation Hub and backfrom ABAP
- abap-form-translatorabap-form-translatorA runtime translation layer for Smartform and Adobe form labels, matching structure fields against a table maintained in a RAP Fiori app, so a label changes without SE63 or a transport.independent, abapRuntime translation layer for SAP form labels, kept in a tablefrom ABAP
- ui5-i18n-excel-converterui5-i18n-excel-converterA command-line tool that exports a UI5 app's i18n properties files to an Excel sheet of keys and languages for translators and imports the translated sheet back into the files.independent, ui5CLI converting UI5 i18n properties files to Excel and backfrom UI5
- ZABAP_TRANSLATIONSZABAP_TRANSLATIONSAn ABAP tool that exports the texts of a package or program to an Excel file and imports them back in bulk once translated, covering eight object types from programs and classes to domain values.independent, abapExcel export and import of ABAP package or program textsfrom ABAP
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtimefrom CAP
- @sap-ux/i18n@sap-ux/i18nA library that reads and writes the i18n bundles of a UI5 or CAP project from Node code, the i18n.properties file of a UI5 app and the i18n folder of a CAP project alike.sap official, ui5Reader and writer for i18n bundles of UI5 or CAP projectsfrom UI5
- XLF TranslatorXLF TranslatorTakes an uploaded XLIFF file and makes every entry that carries a translation element editable in the page, aimed mainly at the ABAP Cloud content the Maintain Translation app generates.independent, abapEditor for the translations in an uploaded XLIFF filefrom ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
History in the atlas
- First seen.
For your agent
- Ref
artifact:jrgkraus-zotr-utility- JSON
- /artifacts/jrgkraus-zotr-utility.json
- MCP
- Connecting an agent