Domain Fixed Values as CDS Value Help in S/4HANA

“Fiori Elements” is a great opportunity for rapid application development for simple scenarios. In lot of cases ABAP developers maintain domain fixed values to have a drop-down list automatically generated by one of the UI technologies like GUI and WebDynpro. Domain fixed value often represent a Status or something like that, where we can say the values are static. In case of OData services and UI5 such control is not generated automatically, but you need to put annotations in your CDS View to make this working. We’ll use CDS Views in the below snippets, to retrive domain low fixed values and their description. The approach below is not the only one, which can lead to the same result. At the end the Object Page template in Fiori Elements ( or your app importing annotation file) will consider the annotations and display a proper value help.

The CDS as solution is also available in non S4/HANA releaes, you can find it in the good old ECC or ERP, and can have a goog play with data modelling having NW 7.50 for example, of course with lot of restrictions. CDS Value help solution in non-S/4HANA systems.

Step 1 – Reuse CDS View I_DomainFixedValue

Our goal is to provide value help in Material Plant Data for the Discontuniation Indicator. The corersponding domain is KZAUS. See below the place to enter your domain name at the end.

Important

  1. cast the DomainValue to the data element of your CDS Entity Property for which you want to apply the Value Help
  2. @ObjectModel.representativeKey annotation must rerer the key field field name you gave as alias for the DomainValue property
@AbapCatalog.sqlViewName: 'ZDDICVIEWNAME'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Discontinuation Indicator Value Help'
@ClientHandling.algorithm: #SESSION_VARIABLE 

@VDM.viewType: #CONSUMPTION
@ObjectModel.dataCategory: #TEXT
@ObjectModel.representativeKey: 'zzDiscontinuationInd'


@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.sizeCategory: #S
@ObjectModel.usageType.dataClass: #CUSTOMIZING
define view ZC_DiscontinuationIndVH 
as select from I_DomainFixedValue 
{
  @ObjectModel.text.element:  [ 'DomainText' ]    
  key cast ( DomainValue as kzaus ) as zzDiscontinuationInd,

  @Semantics.text: true
  _DomainFixedValueText[1: Language = $session.system_language].DomainText as DomainText    
}
 where SAPDataDictionaryDomain    = 'KZAUS'

Step 2 – Apply the Value Help using annnotations

As you know :), we do not bloat the Consumption views with annotations, so that the data we modelled gets not lost in the jungle of annotations. Therefore use ADT to create a MetaDataExtension data definition, and refer the newly created Value Help entity as value help for the property. To do that, use annotation: @Consumption.valueHelpDefinition

@Metadata.layer: #CUSTOMER
annotate view C_Productplant with
{
  @UI: {
     fieldGroup: [{qualifier: 'PlantGeneralData', position: 91, label:'Discontinuation indicator'}]
  }
  @Consumption.valueHelpDefinition: [{ entity: { name : 'ZC_DiscontinuationIndVH', element : 'zzDiscontinuationInd' } }]
  zzDiscontinuationInd;
...
}
@Metadata.layer: #CUSTOMER
annotate view C_Productplant with
{
  @UI: {
     fieldGroup: [{qualifier: 'PlantGeneralData', position: 91, label:'Discontinuation indicator'}]
  }
  @Consumption.valueHelpDefinition: [{ entity: { name : 'ZC_DiscontinuationIndVH', element : 'zzDiscontinuationInd' } }]
  zzDiscontinuationInd;
...
}