Skip to Content
Product Information
Author's profile photo Joey Tan

How to Restrict Language for Language-Dependent Text Fields When Creating Custom CDS Views

Introduction

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:

1.png

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.

2.png

Here, you can set language only for fields from the CDS view, but not for text fields from associations, such as SalesOrganizationName.

3.png

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.

Note:

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.

4.png

Feasible Solution

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.

5.1.png

In the preivew of newly created CDS view, you will find that there is no duplicated record anymore.

5.png

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sai Giridhar Kasturi
      Sai Giridhar Kasturi

      this is very useful. thanks for sharing.

      Author's profile photo Sumy James
      Sumy James

      very Useful document.Thanks for sharing.I was searching everywhere for a solution.Thank you so much