Technical Articles
Simple CDS view & datasource for all Domain based Text datasource
Introduction
For BW system we need many times, text datasources based on domain values. We have predefined datasources which are domain based and SAP delivered. With the help of CDS, we can create just only CDS view to support all the domain text needs.
Applies to
BW/4HANA
Summary
Create a CDS view to support all domain based text datasources.
Author : Lakshminarasimhan Narasimhamurthy
Created on : 04/Mar/2022
Body
Requirement
We build only one CDS view, which will extract all domain texts. Based on this CDS view we will create one datasource at BW/4HANA side.
This datasource will satisfy all the domain text needs. All we need to do is that when ever domain text is needed, the datasource will be mapped to the respective InfoObject with filter on the domain values at the DTP level.
Below is the CDS view built in S4 side on top of table dd07t. This is built as text datasource.
@AbapCatalog.sqlViewName: 'ZCAXXDOMAINTEXT'
@AbapCatalog.compiler.compareFilter: true
--@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@Analytics.dataExtraction.enabled: true
@Analytics.dataCategory: #DIMENSION
@ObjectModel.representativeKey: ['Domname','As4local','Valpos','As4vers']
@EndUserText.label: 'Domain Texts'
define view ZCAXX_DOMAINTEXT as select from dd07t {
key domname as Domname,
key as4local as As4local,
key valpos as Valpos,
key as4vers as As4vers,
domvalue_l as DomvalueL,
domvalue_h as DomvalueH,
appval as Appval
}
Now create the Datasource at the BW/4HANA side, based on the SQL view generated via CDS. In our case it is ZCAXXDOMAINTEXT. We will create datasource based on this view.
now this datasource can be used to load domain text when ever you need domain text within your BW/4HANA system.
When it comes to the texts, we should also consider language. There are standard CDS views that include the language too, they can be found by using "where used" for the table. And I doubt you need to select as4local, standard views typically have it in WHERE condition.
I really don't understand why SAP doesn't just provide a standard "all purpose" view for this. At least I've not been able to find one. There are dozens of designated views for specific fields that do the same thing.