Show TOC

Formatting NumbersLocate this document in the navigation structure

Numeric values in overview pages appear in their short format, using the SAPUI5 sap.ui.core.format.NumberFormat utility. You can configure the number of decimal points to display by using information provided in the OData metadata file, or by using annotations.

In the following example, the scale attribute in the OData metadata is set to "3", indicating that the properties Price, Width, Depth, and Height will be displayed with 3 decimal points.

Sample Code
<EntityType Name="Product" sap:content-version="1">
    ...
    <Property Name="Price" Type="Edm.Decimal" Precision="16" Scale="3" sap:unit="CurrencyCode" sap:label="Unit Price"/>
    <Property Name="Width" Type="Edm.Decimal" Precision="13" Scale="3" sap:unit="DimUnit" sap:label="Dimensions"/>
    <Property Name="Depth" Type="Edm.Decimal" Precision="13" Scale="3" sap:unit="DimUnit" sap:label="Dimensions"/>
    <Property Name="Height" Type="Edm.Decimal" Precision="13" Scale="3" sap:unit="DimUnit" sap:label="Dimensions"/>
    ...
</EntityType>

You can also provide number formatting information in the annotation document in the com.sap.vocabularies.UI.v1.DataPoint term, by using the ValueFormat property. The NumberOfFractionalDigits property can be used to determine the number of decimal points. The ScaleFactor property is always ignored, as values are always shown in their short representation.

In the following example, using the com.sap.vocabularies.UI.v1.DataPoint ValueFormat property, the number of decimal points displayed for the Price property is 1, as defined in the NumberOfFractionalDigits property.

Sample Code
<Annotation Term="com.sap.vocabularies.UI.v1.DataPoint" Qualifier="Price">
    <Record Type="com.sap.vocabularies.UI.v1.DataPointType">
        <PropertyValue Property="Title" String="Unit Price"/>
        <PropertyValue Property="Description" Path="Name"/>
        <PropertyValue Property="Value" Path="Price"/>
        <PropertyValue Property="ValueFormat">
            <Record Type="com.sap.vocabularies.UI.v1.NumberFormat">
                <PropertyValue Property="ScaleFactor" Decimal="1000"/>
                <PropertyValue Property="NumberOfFractionalDigits" int="1"/>
            </Record>
        </PropertyValue>
    </Record>
</Annotation>