Show TOC

Value Help as a Dropdown ListLocate this document in the navigation structure

If your value help contains a fixed number of values, a dropdown list will be rendered.

For information on how value help annotations are set in CDS, see the SAP NetWeaver documentation UI Annotations.

If the entity set of a value help has a fairly stable number of instances, you can render an input field with a value help and dropdown list box (sap.m.ComboBox and in cases of multi selection a sap.m.MultiComboBox) using the metadata extension sap:semantics='fixed-values' on the entity set level and the sap:value-list='fixed-values' on the property level. You must implement these metadata extensions in the DEFINE method of the MPC_EXT class.

In the following example the product category is implemented as a dropdown list box:
DATA lo_annotation TYPE REF TO /iwbep/if_mgw_odata_annotation.
	DATA  lo_property TYPE REF TO /iwbep/if_mgw_odata_property.
	DATA  lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set.
*   DDLB for Category
	lo_entity_set = model->get_entity_set( 'SEPMRA_I_ProductCategory' ).
	lo_annotation = lo_entity_set->create_annotation( 'sap' ).
	lo_annotation->add( iv_key = 'semantics' iv_value = 'fixed-values').
	lo_property = model->get_entity_type( gc_smart_c_producttype )->get_property( 'ProductCategory' ).
	lo_property->set_value_list( /iwbep/if_mgw_odata_property=>gcs_value_list_type_property-fixed_values ).
This will result in the following OData annotations:
Sample Code $metadata
<EntityType Name="SMART_C_ProductType" sap:label="Product" sap:content-version="1">
	<Property Name="ProductCategory" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Category" sap:value-list="fixed-values" />
	<EntityContainer Name="SMART_PROD_MAN_Entities" m:IsDefaultEntityContainer="true" sap:supported-formats="atom json xlsx">
	<EntitySet Name="SEPMRA_I_ProductCategory" EntityType="SMART_PROD_MAN.SEPMRA_I_ProductCategoryType" 
							sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:searchable="true" sap:content-version="1" sap:semantics="fixed-values" />
This is the rendering result:
Figure 1: Product Category Values as Dropdown List Box