In this topic, we explain how to provide value help for your Fiori apps based on the modeled view approach.
The following figure depicts the components involved and development activites required to provide the value help option based on modeled value help view.
You can use a database table or database view, or a suitable CDS view as the data source for the value help view to be modeled. In our sample code, we use the predefined CDS view SEPM_I_BusinessPartner_E, which represents a business partner data definition from the EPM data model.
The following set of CDS annotations is relevant for modeled value help views:
The annotations (required) at view level are:
Annotation and Value |
Effect |
---|---|
@Search.searchable: true |
These annotations is necessary to define that the search function is supported for the view. |
@EndUserText.label: '<text>' |
Specifies the heading text that will be visible in the value help dialog |
The annotations (required) on the field level are:
Annotation and Value |
Effect |
---|---|
@Search.defaultSearchElement: true |
Denotes that it is possible to search for the annotated field in the freestyle search field in the value help dialog |
@Search.fuzzinessThreshold: <value> |
Defines how fuzzy the text search applied to the annotated field should be For example, the value 0.8 refers to a similarity of 80%. |
Example:
In this example, the CDS view ZDEMO_I_BP_ValueHelp selects dedicated fields for the value help from the core business data view SEPM_I_BusinessPartner_E. The annotation @EndUserText.label provides a text that will be displayed in the heading of the value help dialog. The annotations @Search.searchable: true and Search.defaultSearchElement: true are necessary to define that the search function is supported.
... @EndUserText.label: 'Business Partner Value Help' @Search.searchable: true define view ZDEMO_I_BP_ValueHelp as select from SEPM_I_BusinessPartner_E { key BusinessPartner, BusinessPartnerRole, @Search.defaultSearchElement: true @Search.fuzzinessThreshold: 0.8 CompanyName, LegalForm, EmailAddress }
To enable value help in the Fiori app, the following two additions in the consumer view are required:
a. First, add the association to the value help provider view that contains the value list.
b. Then add the annotation @Consumption.valueHelp to the field for which a value help should be made available.
The annotation (required) at the field level:
Annotation and Value |
Effect |
---|---|
@Consumption.valueHelp: '<_AssocToValueHelpProvider>' |
Assigns the association
‘_AssocToValueHelpProvider’ to the
annotated view field: The association’s target view
(modeled view) serves as a value help provider and is
used to retrieve the values of the value help.
Note When you add this annotation, enhanced
modeling options are available to you, in contrast
to the foreign key-based value help approach: you
can specify a dedicated DCL, provide a specific set
of fields (display fields), and even define specific
WHERE conditions.
|
Example:
The consumer view ZDEMO_C_BP_CONSUMER in the listing below defines a data model for the sales order header. Here, the association _BusinessPartnerValueHelp with the target view that represents a value field list for business partner data (ZDEMO_I_BP_ValueHelp) is also defined. This association defines a value help for the annotated field SO.BusinessPartner using the @Consumption.valueHelp annotation
... define view ZDEMO_C_BP_CONSUMER as select from SEPM_I_SalesOrder_E as SO // Association to BP value help association [0..1] to ZDEMO_I_BP_ValueHelp as _BusinessPartnerValueHelp on $projection.BusinessPartner = _BusinessPartnerValueHelp.BusinessPartner ... { /* Field list */ ... @Consumption.valueHelp: '_BusinessPartnerValueHelp' SO.BusinessPartner, ... /* List of associations */ ... _BusinessPartnerValueHelp }
Create either an OData service automatically by adding the annotation @OData.publish: true into the consumer view or manually using the SEGW transaction. In the latter case, you must expose the association to the value help provider view.
More on this: Generating an OData Service Based on a CDS ViewThe figure below gives an idea of what the value help dialog based on the modeled value help view looks like. Note that in the case of the modeled help view, all those fields that are defined in the underlying modeled help view (ZDEMO_I_BP_ValueHelp) are displayed in the value help dialog. The header text in this dialog originates from the modeled value help view through the @EndUserText.label annotation.