PackagePackagetypeA library you install and call yourself.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

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

Last pushLicenceMIT

Where it sits

Lives in
Provides
LocalizationABAPLocalizationcapabilityServing labels, messages and translated content per user locale, including translatable model elements and per-tenant text overrides.

Who is behind it

Jörg KrauseJörg KrausePersonMaintains this
In the atlas: maintains 5, contributes to 6
@jrgkraus
maintainer

What it declares

Every artifact

Type
Package
Origin
Independently maintained

As a package

Where it runs
does not say
Distributed through
does not say

Connections1

README

quoted from jrgkraus/ZOTR_UTILITY under MIT, read
jrgkraus/ZOTR_UTILITY/README.mdOn GitHub

Motivation

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

image

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) image

Make sure to use object type CPUB (Public header - ABAP Objects).

After saving, translation can be called directly:

image

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.

MIT, read
Localization
  1. abap_btocs_deeplDeepL translation plugin for the B-Tocs ABAP SDKfrom ABAP
  2. abap_btocs_libtrlLibreTranslate plugin for the B-Tocs ABAP SDKfrom ABAP
  3. SAP Translation HubTranslation service for software texts and documentsfrom BTP/BAIP
  4. com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versionsfrom CAP
  5. ABAP_DeepL_clientABAP client for the DeepL translation servicefrom ABAP
  6. LISAMCP server for reading and writing ABAP object translationsfrom ABAP
  7. @concircle/i18n-ai-translatorCLI translating UI5 i18n.properties files with OpenAIfrom UI5
  8. ABAP_TRANSLATION_HUBReport pushing ABAP objects to SAP Translation Hub and backfrom ABAP
  9. abap-form-translatorRuntime translation layer for SAP form labels, kept in a tablefrom ABAP
  10. ui5-i18n-excel-converterCLI converting UI5 i18n properties files to Excel and backfrom UI5
  11. ZABAP_TRANSLATIONSExcel export and import of ABAP package or program textsfrom ABAP
  12. @sap/cdsCAP Node.js runtimefrom CAP
  13. @sap-ux/i18nReader and writer for i18n bundles of UI5 or CAP projectsfrom UI5
  14. XLF TranslatorEditor for the translations in an uploaded XLIFF filefrom ABAP

Details

Sources3
dotabapdiscovered herechecked
github.com/jrgkraus/ZOTR_UTILITYtree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

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
discovered viadotabap
first seen in the atlas
ecosystem and domainabap, ui-and-frontend-bridge
abaplint
issues under its own abaplint configuration86
lines176
statements103
objects6
files10
analysed, main
abaplint version2.120.84
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:jrgkraus-zotr-utility
JSON
/artifacts/jrgkraus-zotr-utility.json
MCP
Connecting an agent