How to Restrict Language for Language-Dependent Text Fields When Creating Custom CDS Views
SAP key user tools allow end users to create their own queries/cubes.
If you want to create a custom CDS view, you can refer to how to build a custom analytical query.
When we build a custom CDS view, we may need to show some language-dependent text fields, such as SalesOrganizationName, DistrubutionChannelName. These language-dependent text fields in many cases are sourced from master data and retrieve master data texts by association _Text.
In the CDS view code, SAP developers can specify the text language as user logon language by using _Text[1: Language=$session.system_language] like below:
The following explains how you can specify text language in custom CDS views when using App Custom CDS Views.
Issue of Duplicate Records
For example, you can get the value of a language-dependent text field just by association like I_BillingDocument._SalesOrganization._Text.SalesOrganizationName. In this case, however, you can’t set the language of SalesOrganizationName.
The system may report a warning “The association _Text can modify the cardinality of the result set”, which means if multiple language versions have been maintained for SalesOrganizationName, results will be duplicated.
Here, you can set language only for fields from the CDS view, but not for text fields from associations, such as SalesOrganizationName.
When you preview data, you will find that there are duplicated records in the newly created custom CDS view if the field SalesOrganizationName has different language versions.
1. If a great number of language versions have been maintained for the text field, the system may get memory dump.
2. (Example) In the preview of custom CDS view, when you set the limit to Max., the system shows 100000 records. However, the actual record quantity may have exceeded 100000.
You can specify language for a text field by adding an association to the text view as follows. And in the condition of association, you can specify the language.
In the preivew of newly created CDS view, you will find that there is no duplicated record anymore.
this is very useful. thanks for sharing.
very Useful document.Thanks for sharing.I was searching everywhere for a solution.Thank you so much