SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Web Dynpro Text Translation using Assistance Class

One of the methods to translate text in Web Dynpro applications is using Assistance Class. In this Web Dynpro tutorial, I'll demonstrate a sample case where an assistance class is used for text translation on a Web Dynpro component.

Let's start by calling SE80 transaction in order to start ABAP Workbench. Then open the Web Dynpro component you have created before.
Double click on Web Dynpro component and chage to Edit mode in the ABAP editor.

Click on the Assistance Class text area.

Assistance Class for Web Dynpro translation

Enter a class name in the Assistance Class textbox. For example I used the name ZWD_BLCKORDERS_TXTCLS.

Click Save button. The ABAP Workbench will ask your permission to create the new assistance class.

create Assistance Class

The class ... does not exist
Create class?

Click Yes button in order to create assistance class for your Web Dynpro application.





After the Assistance Class is created within the Web Dynpro component double click on Assistance Class textbox where you have typed the name of the class.

if_wd_component_assistance~get_text method returns text for model class

Now we can use Assistance Class method IF_WD_COMPONENT_ASSISTANCE~GET_TEXT in order to read the translation of text elements within Web Dynpro ABAP codes.

In order to define text elements, follow the menu options : Goto > Text elements

Goto - Text elements menu options

When the text elements screen is displayed, change to Edit mode to define new text elements.

In this ABAP tutorial, I want to create text elements for radio buttons with Active, InActive and All options. Then we will translate these texts into different target languages.

You can create select options in WDDOINIT method of the MAIN view with following text elements: 011 Active, 012 Inactive, and 013 All

assistance class text symbols for text translation in Web Dynpro

After you have defined the text elements you need for your Web Dynpro component, click Save and then Activate

Below is the ABAP code that Web Dynpro developers can use within the Main View WDDOINIT method source code

DATA ld_text_assistance TYPE string. " read TEXT from assistance class

DATA lo_nd_customerstatus TYPE REF TO if_wd_context_node.
DATA lt_customerstatus TYPE wd_this->elements_customerstatus.
DATA ls_customerstatus LIKE LINE OF lt_customerstatus.

* navigate from <CONTEXT> to <CUSTOMERSTATUS> via lead selection
lo_nd_customerstatus = wd_context->get_child_node( name = wd_this->wdctx_customerstatus ).

*----- Create value key list of different text designs
ls_customerstatus-key = '1'.
ld_text_assistance = wd_assist->if_wd_component_assistance~get_text( '011' ).
ls_customerstatus-value = ld_text_assistance. "'Active'.
APPEND ls_customerstatus TO lt_customerstatus.

ls_customerstatus-key = '0'.
ld_text_assistance = wd_assist->if_wd_component_assistance~get_text( '012' ).
ls_customerstatus-value = ld_text_assistance. "'InActive'.
APPEND ls_customerstatus TO lt_customerstatus.

ls_customerstatus-key = 'A'.
ld_text_assistance = wd_assist->if_wd_component_assistance~get_text( '013' ).
ls_customerstatus-value = ld_text_assistance. "'All'.
APPEND ls_customerstatus TO lt_customerstatus.


*----- Fill context node TEXT_DESIGNS
lo_nd_customerstatus->bind_table( new_items = lt_customerstatus set_initial_elements = abap_true ).
Code

Now ABAP developers are ready to translate text into different target languages using Text Elements Translation menu. When you're displaying Assistance Class choose Goto > Translation from menu options.

choose target language for translation text

Then press Enter to continue with next screen in SAP Text translation
As in text translations in ABAP reports, developers can maintain the translated text into the input text areas left empty for translation value. As you can see the SAP system suggests translation values in the target system below the input text area. You can choose the suggested text by double-click on the suggested translation text.

Web Dynpro assistance class text translation

When you are finished with translation for text defined in the Web Dynpro Assistance Class, save your work and exit application.

When you test your SAP Web Dynpro application on a web browser, you can see that the page title is not translated which is actually the translation of Web Dynpro application description. If this is the case you can also translate Web Dynpro application title on web browser as illustrated in the referenced ABAP tutorial.

As last step, you should create a transport request for text translations in the target system in order to release your changes on test and productive SAP system. Please refer to ABAP tutorial Create Transport Request for Text Translations using RS_LXE_RECORD_TORDER for step by step implementation of exporting text translations into a transport request.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.