You are on page 1of 10

OTR Text Translation Tool for Web Dynpro ABAP

Applies to: SAP NetWeaver WebAS 7.00 or higher. Summary: A tool to easy translate OTR Texts in Web Dynpro ABAP Component.

Scope: The Online Text Repository (OTR) is a central storage location for texts, and services for editing and
administering these texts. In BSP applications, you can work with OTR and the ABAP Workbench provide a translation tool to translate the BSP pages and views. In Web Dynpro components every text that you insert in the layout of the views is saved in the system as an OTR text but there isn't a tool to easily translate all created text in the views. I have written a program to facilitate the translation of the OTR text created in view's layout of the web dynpro abap component.

Tool usage: When the program starts, select one or more web dynpro components that contain the view to
translate thought the search help , the source language and the destination language then execute it.

The program shows all views of the selected web dynpro component.

By clicking on "Translate" the translation screen (like the one used for translating BSP page) is shown. This screen is shown thought the function SOTR_API_WB_TRANSLATE.

Installation : To install the translation tool on your system copy the following tool in an SE38 program.
*&---------------------------------------------------------------------* *& Report ZSDN_WDY_OTR_EDITOR *& *&---------------------------------------------------------------------*

REPORT zsdn_wdy_otr_translator. TABLES: wdy_component.


********************************************************************** * Global Types Declaration * **********************************************************************

TYPES: BEGIN OF gsty_wd_out_tab, btn_01 TYPE c LENGTH 10, component_name TYPE wdy_component_name, view_name TYPE wdy_view_name, END OF gsty_wd_out_tab. TYPES: gtty_wd_out_tab TYPE TABLE OF gsty_wd_out_tab. TYPES: BEGIN OF gsty_wdy_cname_f4, component_name TYPE wdy_component_name, description TYPE wdy_md_description, END OF gsty_wdy_cname_f4.
********************************************************************** * CLASS lcl_handle_events DEFINITION ********************************************************************** * **********************************************************************

CLASS lcl_handle_events DEFINITION. PUBLIC SECTION. METHODS: on_link_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row column. ENDCLASS. "lcl_handle_events DEFINITION
********************************************************************** * Global Data Declaration * **********************************************************************

DATA: gt_wd_otr TYPE gtty_wd_out_tab. DATA: go_event_handler TYPE REF TO lcl_handle_events.


********************************************************************** * SELECTION SCREEN * **********************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK b1. SELECT-OPTIONS: pcname FOR wdy_component-component_name OBLIGATORY. PARAMETERS: pslangu TYPE sylangu MATCHCODE OBJECT h_t002 OBLIGATORY. PARAMETERS: pdlangu TYPE sylangu MATCHCODE OBJECT h_t002 OBLIGATORY. SELECTION-SCREEN: END OF BLOCK b1.
********************************************************************** * SEARCH HELP * **********************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pcname-low. * Create Search Help DATA: lt_wdy_component TYPE TABLE OF gsty_wdy_cname_f4. FIELD-SYMBOLS:<lw_wdy_component> TYPE gsty_wdy_cname_f4. SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_wdy_component FROM wdy_component WHERE component_name IN pcname.

LOOP AT lt_wdy_component ASSIGNING <lw_wdy_component>. SELECT SINGLE * INTO CORRESPONDING FIELDS OF <lw_wdy_component> FROM wdy_componentt WHERE langu = sy-langu AND component_name = <lw_wdy_component>-component_name. ENDLOOP. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'COMPONENT_NAME' dynprofield = 'PCNAME' dynpprog = sy-cprog dynpnr = sy-dynnr value_org = 'S' TABLES value_tab = lt_wdy_component.
********************************************************************** * Text Initialization * **********************************************************************

INITIALIZATION. %_pcname_%_app_%-text = 'WD Component Name'. %_pslangu_%_app_% = 'Source Language'. %_pdlangu_%_app_% = 'Destination Language'.

********************************************************************** * START of SELECTION * **********************************************************************

START-OF-SELECTION. DATA: gr_table TYPE REF TO cl_salv_table, gr_display TYPE REF TO cl_salv_display_settings, gr_functions TYPE REF TO cl_salv_functions, gr_events TYPE REF TO cl_salv_events_table, gr_columns TYPE REF TO cl_salv_columns_table, gr_column TYPE REF TO cl_salv_column_table, l_color TYPE lvc_s_colo. FIELD-SYMBOLS:<lw_wd_otr> TYPE gsty_wd_out_tab. SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_wd_otr FROM wdy_view WHERE component_name IN pcname AND version = 'A' AND type = 'CL_WDY_MD_VIEW'. LOOP AT gt_wd_otr ASSIGNING <lw_wd_otr>. <lw_wd_otr>-btn_01 = 'Translate'. ENDLOOP. * Create ALV table cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = gt_wd_otr ). * Set zebra layout gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). * Display all standard function

gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). * Set the column BTN_01 as a link to tranlate gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'BTN_01' ). l_color-col = '4'. l_color-int = '1'. l_color-inv = '0'. gr_column->set_color( l_color ). gr_column->set_cell_type( 5 ). * Set event hadler gr_events = gr_table->get_event( ). CREATE OBJECT go_event_handler. SET HANDLER go_event_handler->on_link_click FOR gr_events. * Set event hadler gr_table->display( ).
********************************************************************** * CLASS lcl_handle_events IMPLEMENTATION **********************************************************************

CLASS lcl_handle_events IMPLEMENTATION. METHOD on_link_click. DATA: l_object_name TYPE trobj_name. DATA: lw_wd_compview TYPE gsty_wd_out_tab. IF column = 'BTN_01'. READ TABLE gt_wd_otr INDEX row INTO lw_wd_compview. CONCATENATE lw_wd_compview-component_name '%' lw_wd_compview-view_name INTO l_object_name. CONDENSE l_object_name NO-GAPS. CALL FUNCTION 'SOTR_API_WB_TRANSLATE' EXPORTING source_langu = pslangu target_langu = pdlangu pgmid = 'LIMU' object = 'WDYV' obj_name = l_object_name EXCEPTIONS no_entry_found = 1 internal_error = 2 no_authorization = 3 error_in_context = 4 user_cancelled = 5 error_in_transport_request = 6 OTHERS = 7. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDIF. ENDMETHOD. "on_single_click ENDCLASS. "lcl_handle_events IMPLEMENTATION "on_double_click

Creating OTR Alias Text


Prerequisites
You have integrated the terms you want to create as alias texts in accordance with the OTR Directives) into your BSP layout.

Procedure
You can create OTR alias texts in the following ways: By double-clicking on the OTR alias in the page editor By choosing the menu option Goto OTR from the BSP application Using transaction SOTR_EDIT

Creating OTR alias text by double-clicking from the BSP application


1. In your BSP application double-click on an OTR alias text that is not yet available. 2. Confirm the prompt asking you if the text should be created. The screen below appears:

If you have not yet specified a packet name for the OTR alias in your BSP, the system automatically extends the prefix in the page as well as in the OTR. 3. Enter the required text up to a maximum length of 255 characters. 4. Enter the length of the text in the Maximum Length field. Always consider translation needs by entering a longer length than the text itself. If you do not enter a value in this field, the system stores the OTR alias in its current length.

5. To save the text choose Enter or Save. 6. If you do not want to change the text any more, you can also choose Release at this point.
If you release the text it will be released for translation. You cannot change released texts.

7. If the OTR text contains abbreviations or anything else that make translation difficult, once you
have pressed the Release button, the system sends a further popup where you can enter explanations or comments. Enter a comment and choose .

Creating OTR alias text using the BSP application menu


1. In your BSP choose Goto OTR OTR Browser.
On the following screen first of all the texts of the packet you are currently editing are displayed. The packet SOTR_VOCABULARY_BASIC contains standard texts for you to use. You can use these texts across all applications. All other texts on the other hand should always be assigned to one packet only.

2. Select a text from the existing texts, choose


new text in your packet. 3. Continue as described in the section above.

, to change an existing text, or choose

to create a

Creating OTR alias text using transaction SOTR_EDIT


1. Call transaction SOTR_EDIT.
2. Enter the language you want to create the text in and the alias name. 3. Choose Create. 4. On the next screen enter the package name, the alias name, the object type (for BSP applications this is always WAPP) and the alias text and then choose Save. After saving you will find in the Concept field a unique GUID under which you will find your text in the OTR.

Translating OTR Texts


Use: You can translate released texts.
You use the translation transaction SE63 to do this. Translate long texts and short texts separately.

Prerequisites: As a translator, you must be registered in the translation environment and


assigned to a package.

Procedure : The procedure is described in the documentation


Translators, in the Translating OTR Texts section.

Translation Tools for

Translating OTR Texts


Purpose
Texts created in the Online Text Repository (OTR) are not stored and managed in the same way as most other texts in the SAP System. OTR texts are translated in their own special OTR text editor.

Integration
OTR objects are translated in transaction SE63_OTR. It enables you to call up text objects in a standard worklist that contains three nodes: OTR levels 1, 2, and 3. At this time, texts only exist for OTR level 1. You can also access text objects directly. To do so, call transaction SE63_OTR and choose Translation Short Texts or Translation Long Texts. Alternatively, you can enter the object types technical key directly in the command field. You can also access transaction SE63_OTR from transaction SE63. To do so, choose Translation OTR Objects. For more information on the translation transaction, see Quick Start for Translators.

Features
Search Options for Direct Access
If you use the Translation menu to access an OTR object type directly, the system displays a dialog box that provides you with various search options:

Search for a specific package Search for a text in the OTR Search for the logical OTR ID

Context Information
Context information is displayed in the lower section of the OTR translation editor or in a separate dialog box.

...

An up-to-date where-used list containing all the objects in which the OTR text occurs Existing translations into other languages Administrative information such as:

Alias Package Original language Translation level Created by Created on Object type Technical name

Editor Functions
OTR translation takes place in a separate editor with the following special functions:

Context information is displayed in the lower section of the editor.

The OTR long text editor includes pushbuttons that enable you to format your texts (bold, italics). The OTR long text editor includes special functions that enable you to edit long texts with HTML formats: ...

Display preview of source and target text as in browser Copy tags to target text (with or without source text)

Constraints
OTR texts are not included in the statistics. You have to call up an OTR worklist to find out if you have any OTR texts to translate.

See also:
Translating an OTR Short Text Translating an OTR Long Text Calling Up a Worklist for OTR Objects

Notes on the Transport


An OTR text not assigned to a local or private packet is included in a transportable change request when the text is created. This ensures that new or changed texts are also transported into the subsequent systems. The connection to the Change & Transport System is thus guaranteed.

Transporting OTR Texts


The OTR texts you have created are transported together with the associated object. A corresponding entry is generated in the transport request for the first OTR text: OTR short texts: object type LIMU SOTT OTR long texts: object type LIMU SOTU Texts that are not yet released for translation are also transported together with the object. When texts are released for translation, an additional transport request is created for these texts. You have to release this request if you want the texts to be transported to the translation system for translation. If the transport request for the texts for translation is not released, the texts are not transported. You can, however, also transport all texts that belong to a package, independently of an object. To do this, create a transport request: For OTR short texts, use the object type R3TR SOTR For OTR long texts, use the object type R3TR SOTS Enter the respective package name as the object name. The OTR texts are thus transported in their respective original language.If, however, you only want to transport texts in a particular language, create a transport request as follows: For OTR short texts, use the object type LANG SOTR For OTR long texts, use the object type LANG SOTS Enter the respective package name as the object name. In this case, the system asks you which language you want to transport the texts in.

You might also like