Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Applies to:

SAP NetWeaver WebAS 7.00 or higher.

Summary

A tool to easy translate OTR Texts in Web Dynpro ABAP Component.

Author:  

Author: Alessandro Lavazzi   
Company:  Techedge
Created on:    03/07/2009
Author(s) Bio
I'm a software engineer and I have started to work on SAP environment on february 2004. I have designed many SAP applications using Web Dynpro ABAP technology.

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.

ZSDN_WDY_OTR_EDITOR
*&---------------------------------------------------------------------*
*& 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 component_name = <lw_wdy_component>-component_name
  AND langu = sy-langu.
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

5 Comments

  1. Former Member

    This tool is a must, it should be part of the standard, you cannot even think about translating a large WDA application in several languages without such a tool!

     Great Work (thumbs up)

    Sergio

  2. Guest

    I do agree completly with Sergio.  I am absolutely overwhelmed by the utility of this program. Thank you very much!

     (thumbs up)

  3. Former Member

    This is a great tool. Thanks for sharing it via SCN!
    I just want to add how it is possible to translate WDY text elements via standard SAP transaction.

    1. Open your Web Dynpro view you want to translate via SE80
    2. Menu: Goto >> Object directory entry. You'll see object, notice it.
    3. Start transaction SE63
    4. Menu: Translation >> ABAP Objects >> Transport Object
    5. Type in your noticed object at field "Transport Entry of Object" and press Edit.
    6. You'll see ever single text under your paket entry.
  4. Guest

    Hi Alessandro,

    thank you very mutch for the tool!

    Toth Bela

  5. Former Member

    Hi,

    A "fork" available here  (wink)

    WDA OTR maintenance tool