Copyright 2020 - BV TallVision IT

OTR texts or Online Text Repository texts are longtexts which are held in a centrally available storage location, accessible from SAP but also for e.g. BSP (Business Server Pages - the web) applications. OTS is about editing, maintenance and usage of these texts. Texts are cross-client workbench objects.

Maintenance

OTR texts can be maintained via transaction SOTR_EDIT and from transactions of workbench object using OTR, which comprise:

  • BSP application
  • ABAP Object Class (exception texts)
  • Enhancement Framework elements (Implementation, Spot, etc.)
  • ICF service
  • Web Dynpro elements (Application, Component, etc.)
  • (XML) Transformation

An example: creating a text with an alias

Start transaction SOTR_EDIT and select the text type "Short text". Also fill in the language and the actual text (contents) you want to create. The Alias can also be entered, e.g. Z_MYAPPLICATION/FOOTER. Fill in WAPP as the object type (supported object type). A message "Text has been created" will appear and the concept number (e.g. 536DEE3AECCA4CF4E1000000AC138170) will be populated.

Selecting the above text can be done in many ways. There's a suite of function modules available - bu t I prefer the object oriented way, e.g.: 

call method cl_hrrcf_ui_services=>get_otr_text_with_langu
  exporting
    p_alias    = 'Z_MYAPPLICATION/FOOTER'
    p_language = sy-langu
  receiving
    p_text     = lv_footertext.

Note that these hese texts can be translated via transaction SOTR_EDIT, in the menu select from change mode choose Goto => Translation.

An alternative way to fetch texts, which can be used to fetch both short and long texts: first create an instance of class CL_SOTRfor the language you want to fetch texts for, like so:

DATA: lo_sotr type ref to cl_sotr. 

CREATE OBJECT lo_sotr EXPORTING i_langu = 'E'.  "English 

Then all you need to do is call method get_string_by_alias for long texts or get_text_by_alias for short texts.

lo_sotr->get_string_by_alias(
  EXPORTING i_alias = 'Z_MYAPPLICATION/FOOTER_LONGTEXT'
  IMPORTING e_text = lv_footerstring ).

lo_sotr_nl->get_text_by_alias(
  EXPORTING i_alias = 'Z_MYAPPLICATION/FOOTER'
  IMPORTING e_text = lv_footertext ).

Translated values not showing - buffering

The OTR text mechanism is controlled with CAAL-SYSTEM statements and it has a buffering which can cause fresh/new translations to stay unavailable. Here's what you can do to reset that buffering (light to heavy)

  • Run report SOTR_DEFAULT_CONTEXT_FLAG_SET for your package
  • Run report SOTR_BUFFER_RESET for the application
  • Run transaction ST02 and fill in the command box: /$OTR

Definition

The OTR differentiates between short texts up to 255 characters in length (as per above example) and long texts of any length. Each text is stored once per package. General texts that occur often are included in the OTR basic vocabulary and can be used across all packages. Text storage is independent of the BSP that references the texts.

The texts are numbered internally. The text number identifies a text concept, including information about alternate spellings, such as abbreviations or length variants, but also translations of the texts and possible localization-specific variations, such as industry-, country-, or customer-specific variants.

The text repository works with Concepts (a unique internally numbered key)and Aliasses which links a nicely human-readable text to a concept key. An alias can be local or global: an overview of the available aliasses:

  • Global alias for texts (up to 255 characters): table SOTR_ALIA
  • Global alias for longtexts: table SOTR_ALIAU
  • Local alias for texts (up to 255 characters): table SOTR_TXTA1
  • Local alias for longtexts: table SOTR_TXTB1

These tables all have a field ALIAS_NAME which represents (if filled) the unique alias of the text (or longtext). Global aliasses don't have to be unique to the text.

Want more ?

The repository can be used via a set of function modules (there's over 150 function modules and 19 tables with naming convention SOTR_*). There are also a few classes available such as the CL_HRRCF_UI_SERVICES which has some interesting methods:

  • GET_OTR_TEXT Read OTR Text
  • GET_OTR_TEXT_WITH_LANGU Read OTR Text (in specified language)

Class CL_SOTR only has methods on OTR:

  • GET_TEXTS Get OTR Entries (Short Texts)
  • GET_TEXT_BY_ALIAS
  • GET_TEXT
  • GET_STRINGS Get OTR Entries (Strings / long texts)
  • GET_STRING_BY_ALIAS
  • GET_STRING

An example on using the CL_SOTR class:

DATA: lo_sotr  TYPE REF TO cl_sotr,
      lv_string type string. 

  CREATE OBJECT lo_sotr.
* Note: you can specify an alternative language via I_LANGU
  lo_sotr->get_string_by_alias( 
        EXPORTING
          i_alias = 'Z_MYAPPLICATION/FOOTER' 
        IMPORTING
          e_text  = lv_string ).

So a long text is not an internal table with lines, but a string with EOL (End Of Lines). Do you need your text to be available as an internal table with lines ? Do this:

DATA: lt_textlines type standard table of char80. 

SPLIT lv_string AT cl_abap_char_utilities=>cr_lf
  INTO TABLE lt_textlines.

Further reading