page of Google searches for both these topics. Now, our team is focusing on reigning the Core Data Services. As of date, we have 13 articles on CDS. Today, we present how to exploit Annotations for translations in CDS.
For novice, Annotation is just an extension to the CDS SQL. In the beginning of the CDS definitions, whatever you see which begins with ‘@’ is an annotation.
ABAP Annotation plays a very important role as they define technical and semantic attributes of a CDS object. They are usually evaluated for every CDS object when activated by the ABAP runtime environment.
In this article I have tried to explain in detail about the ABAP annotations for translatable texts in CDS views. We would end our article with a small ABAP Program written in ADT showing how to consume the same texts in 2 different languages (English and German). This article would act like a step by step guide to meet all the translation requirements in SAP ABAP and CDS.
ABAP annotations starting with EndUserText are used to define translatable semantic texts for aCDS object.
EndUserText.label is available as view annotation (i.e.available at CDS entity level) or as element annotation (i.e. available forindividual element). The maximum length is limited to 60 characters.
EndUserText.quickinfo is only available as elementannotation (i.e. available for individual element). The value is stored asstring and can have arbitrary length.
Also Read : ADT Eclipse/HANA Studio for ABAPers
The values of text annotations are stored in special tables that have language key and that are translatable. The value specified in the source code should consist of text in the original language of the CDS source code and is translated into the required languages.
Translation of CDS views is done as usual in the translatable editor (T-Code SE63). A new object type CDS view has been added to group User Interface Texts.
Please follow the below steps to translate the textsdefined in the given DDL Source:
1. DDL Source whose texts need to be translated –
2. Execute T-Code SE63
3. Choose ‘Short Texts’ from the toolbar
4. On the next dialog window, expand node User Interface Texts.
5. Choose and double click on sub-element DDLS CDS Views.
6. On the next dialog window, enter the name of DDL Source, the source and target language.
7. Click on Edit.
8. Enter the texts in target language specified and click on SAVE button to save the values.
Also Check – How I created my first OData Service in SAP?
Once we have saved the translations, we would require transporting them through various SAP systems in the system landscape. Unfortunately, translations are not added to TR automatically and need to be added manually.
T-Code SLXT isused for this purpose. This T-Code will execute ABAP program RS_LXE_RECORD_TORDER or RS_LXE_LOG_EXPORT depending on theversion of SAP you are using.
Execute T-Code SLXT.
Enter the selection as follows and execute –
On execution, Texts would be saved in the created TR –
Also Explore : How to Consume Custom OData in SAPUI5 Application
The methods of global class CL_DD_DDL_ANNOTATION_SERVICE reads the texts as specified by an input parameter for the language.
If no language is passed to the input parameter, the logon language is used as the default.
Use Case 1) Source Language (English in this case)
Case 2) Target Language (German in this case)
Note – If no text is found for the language, the secondary language in AS ABAP is used.
I hope you found this article useful. The SE63 and the steps to put the translated text into transport remains the same in SAP ECC. Many developers do not get opportunity to work in translated objects if their clients do not have global presence. So, for them, this might act as a reference page to come back in future if they need it.
In the coming days, I would write articles on Associations in CDS. So, please stay tuned.
Your feedback if our motivation. Please leave your thoughts, both positive and not so positive.
We have a very active Telegram (App) SAP Technical Group with more than 3850+ SAP Technical Practitioners from 6 Continents of the SAP World. Please join it using below link.
Telegram SAP Technical Discuss Group. You need to install the Telegram App first on your mobile device. Once you have it on your mobile, you can join the group and also access it from the Web on your computer and laptop.
Free Step by Step Core Data Services Exercises
- CDS Part 1. Core Data Services – Introduction
- CDS Part 2. Core Data Services – Deep Dive
- ABAP on SAP HANA. Part XII. Open SQL, CDS or AMDP, which Code to Data Technique to use?
- CDS Part 3. Expose CDS Views as OData Service through Annotation
- CDS Part 4. Data Access in S/4HANA Cloud – CDS View Introduction
- CDS Part 5. ABAP CDS Views With Authorization
- CDS Part 6. Basic Expressions & Operations Available for CDS View – I
- CDS Part 7. Basic Expressions & Operations Available for CDS View – II
- CDS Part 8. Usage of Built-In Functions in CDS – I
- CDS Part 9. Usage of Built-In Functions in CDS – II
- CDS Part 10. Usage of Built-In Functions in CDS – III
- CDS Part 11. How to Consume CDS View in Smart Business Service KPI Fiori Apps?
- CDS Part 12. Useful 6 CDS Related Tools in ADT
- CDS Part 13. Key Definition in CDS Views
- CDS Part 14. ABAP Annotations for Translatable Texts in CDS Views
- CDS Part 15. Associations in CDS Views – I