The Growing Guide to RAP Value Helps

🚧 Work in Progress: This guide grows as I do.

General

General things that are good to know

Key & Text Display in Value Helps

When implementing value helps, remember that you can also customize how the input field displays the key and description usingĀ @ObjectModel.text.elementĀ andĀ @UI.textArrangement.

Consumption layer

define view entity ZC_BPWF_BC

as projection on ZI_BPWF_BC

{

key HeaderUuid,

key BankUuid,

@ObjectModel.text.element: ['BankCountryName']

@Consumption.valueHelpDefinition: [{ entity: { name: 'I_CountryVH', element : 'Country' }, useForValidation: true }]

BankCountry,

_BankCountry._Text.CountryName as BankCountryName : localized,

_BankCountry

}

Metadata extension

annotate view ZC_BPWF_BC with

{

...

@UI.textArrangement: #TEXT_ONLY

BankCountry;

}

The following options are available:Ā #TEXT_FIRST,Ā #TEXT_LAST,#TEXT_ONLY,#TEXT_SEPERATE.

Why interface associations and value help entities can differ

The association in the interface view and the value help definition in the consumption view do not need to be the same.

Interface view

The interface view is used for the technical data model. It defines semantic associations such as _Country for navigation and text retrieval.

association [0..1] to I_Country as _Country on $projection.Country = _Country.Country

...

country as Country,

...

_Country

Consumption view

The consumption view is used for the UI layer. It can provide a different value help entity, in this caseĀ I_Country_VH, which is optimized for search and end-user experience.

@ObjectModel.text.element: ['CountryName']

  

@Consumption.valueHelpDefinition: [{ entity: { name: 'I_CountryVH', element : 'Country' }, useForValidation: true }]

  

Country,

  

_Country._Text.CountryName as CountryName : localized,

additionalBinding

If your view uses a different property name than the element in the value help CDS you must useĀ additionalBinding.

@Consumption.valueHelpDefinition: [{ entity: { name: 'C_TaxTypeVHTemp', element: 'TaxType' }, additionalBinding: [{ localElement: 'Taxtype1' }], useForValidation: true }]

Taxtype1,

Value help with dependent keys

Sometimes a field’s value help depends on another field. In this case, the cds view must pass all required keys to the value help. This is done usingĀ additionalBinding.

šŸ’”When IndustrySystemType is selected first, the value help for IndustrySector will automatically be pre-filtered – When IndustrySector is selected first through the value help, the IndustrySystemType will be automatically set.

@ObjectModel.text.element: [ 'IndustrySystemName']

@Consumption.valueHelpDefinition: [{ entity: { name: 'C_IndustrySystemVHTemp', element: 'IndustrySystemType' }, useForValidation: true }]

IndustrySystemType,

_IndustrySystem._Text.IndustrySystemName as IndustrySystemName : localized,

@ObjectModel.text.element: [ 'IndustrySectorName']

@Consumption.valueHelpDefinition: [{ entity: { name: 'C_Industryvhtemp', element: 'IndustrySector' }, additionalBinding: [{ localElement: 'IndustrySystemType', element: 'IndustrySystemType' }], useForValidation: true }]

IndustrySector,

_IndustrySector._IndustryKeyText.IndustryName as IndustrySectorName : localized,

Domain value help

For simple code lists defined in ABAP dictionary domains, you can generate value helps extremely quickly using SAP delivered domain value cds views. UseĀ I_DomainFixedValueĀ (safe choice) orĀ DDCDS_CUSTOMER_DOMAIN_VALUEĀ (successor).

define view entity ZI_XXXVH

as select from I_DomainFixedValue

{

@ObjectModel.text.element: ['DomainText']

key DomainValue as Xxx,

@Semantics.text: true

_DomainFixedValueText[1: Language = $session.system_language].DomainText as XxxText

}

where

SAPDataDictionaryDomain = 'ZXXX';

Leave a Reply

Your email address will not be published. Required fields are marked *