Field Group:-Qualifier Section Heading

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

place the cursor on the ON keyword and use the keyboard shortcut CTRL+1 On Clause Wizard

ctrl + D deletes a line


F2 -on- element fn+F2 on remote desktop - addln. info.

Dependencies of CDS View:


DDL source: Open With > Dependency Analyzer

Generic node key of Raw 16, should be casted to SYS UUID


Node key of Raw type should be casted to SEPM_SO_UUID
key cast( Persistence.node_key as SEPM_SO_UUID preserving type ) as
SalesOrderUUID,

........................... ................. ..................

Data Field-like Annotations:


@UI.lineItem
@UI.selectionField
@UI.identification
@UI.fieldGroup

Field Group:-Qualifier  Section Heading


x

x used to define DataFields

x Mark Fields as Global Filters


Analytics @@
replication-enabled Master Data:

Example for replication-enabled master data. @analytics.dataExtraction.enabled: true


@objectmodel.representativekey: 'EmployeeUUID'
Sample Code
@EndUserText.label: 'EPM Demo: Employee'
@Analytics:{ dataCategory: #DIMENSION , dataExtraction.enabled: true }
//@VDM.viewType: #BASIC
@AccessControl.authorizationCheck: #CHECK
@ObjectModel.representativeKey: 'EmployeeUUID'
@AbapCatalog.sqlViewName: 'SEPM_IEMPLOYEE'
define view SEPM_I_Employee as
select from snwd_employees

association [0..1] to SEPM_I_Company as _Company on $projection.Compan


yUUID = _Company.CompanyUUID
...

{
key snwd_employees.node_key as EmployeeUUID, @objectmodel.foreignkey.association: true
@ObjectModel.foreignKey.association: '_Company' projecion column in association
snwd_employees.parent_key as CompanyUUID,
...}

Example 2

Example for transactional data (fact).

Sample Code
@EndUserText.label: 'EPM Demo: Sales Order Item with Addtl. Data (private view)'
@Analytics.dataCategory: #CUBE
@AccessControl.authorizationCheck: #CHECK
@AbapCatalog.sqlViewName: 'SEPM_PSOIC'

define view SEPM_P_SalesOrderItemCube


with parameters
P_DisplayCurrency : snwd_curr_code //forCURRENCY CONVERSION , TODO: data element with bet
ter description

as select from SEPM_I_SalesOrderItem

association [0..1] to SEPM_I_SalesOrder_E as _SalesOrder_E on $projection.salesor


der = _SalesOrder_E.SalesOrder
...

{
@ObjectModel.foreignKey.association: '_SalesO
rder_E'
key _SalesOrder.SalesOrder,
_SalesOrder_E,
...}
@analyticdetails.query.axis:
AnalyticsDetails Annotations
Sample Code @analyticdetails.query.formula: ' '
@Analytics.query : true
define view fincancial as select from sales

{
@AnalyticsDetails.query.axis : #ROWS
..............................................
product,
@AnalyticsDetails.query.axis : #COLUMNS
@AnalyticsDetails.query.formula : 'revenue - cost'
........................................
1 as absolute_margin,

@AnalyticsDetails.query.formula : 'NDIV0($projection.absolute_margin / revenue ) * 100'

1 as relative_margin,

@AnalyticsDetails.query.formula : 'CASE WHEN $projection.relative_margin > 20 THEN revenue ELSE


0 END'
1 as revenue_for_margin_gt_20

Example 2

Display hierarchy selection: Specify the hierarchy directly.

Sample Code
@Analytics.query : true

define view costcenter_reporting

with parameters

cost_center_hier_param : String

as select from costcenters

...

@AnalyticsDetails.query : {

displayHierarchy: #ON,

hierarchyInitialLevel: 3, // three levels of the hierarchy will be opened at start

hierarchySettings{hidePostedNodesValues: true }, // don't show posted node values

hierarchyBinding :

[ { type : #CONSTANT, value : 'CONTR_AREA_10' },

{ type : #PARAMETER, value : 'cost_center_hier_param' }

}
costcenter, // hierarchy node filter

costs,

...

}
Example 3

Use of $session variables, especially $session.system_date.

The system supports variables like $session.system_date for different use cases:

in cube parameters

Sample Code
@Analytics.query : true

define view …

as select from zCostCenter_Flt( P_KeyDate: $session.system_date )

in queries on time-dependent master data in where clauses

Sample Code
} where

DateTo >= $session.system_date and

DateFrom <= $session.system_date

in paths to time-dependent attributes or texts

Sample Code
_CostCenter[1: DateTo >= $session.system_date and DateFrom <= $session.system_date]._Text[1: Langu
age = $parameters.P_Language].Text as CostCenterText,

in restricted key figures

Sample Code
case when PostingDate = $session.system_date
labelElement: 'companyname'
Consumption Annotations
quickInfoElement : 'description'
Sample Code
DEFINE VIEW SalesOrder
AS SELECT FROM sepm_cds_sales_order AS so
{
key so.sales_order_id AS SalesOrderId,

.......................................................
@Consumption.labelElement: 'CompanyName'
@Consumption.quickInfoElement: 'CompanyDescription'
......................
so.buyer_guid AS BuyerGuid,

so.company_name AS CompanyName,

so.description AS CompanyDescription
}

Example 2

The annotation Consumption.groupWithElement is used to define that the element CompanyName depends
semantically on the element BuyerGuid. In the case of an aggregated table, the fields can be displayed combined:

Sample Code
DEFINE VIEW SalesOrder with parameters
AS SELECT FROM sepm_cds_sales_order AS so
{
key so.sales_order_key AS NodeKey,

so.buyer_guid AS BuyerGuid,

@Consumption.groupWithElement: 'BuyerGuid' groupWithElement


so.company_name AS CompanyName,

so.currency_code AS CurrencyCode,

@DefaultAggregation: #SUM
so.gross_amount AS GrossAmount
}

Example 3

The annotation Consumption.hidden is used to prevent fields from being exposed by OData. The annotation, therefore,
prevents fields from being available to the client. This is necessary for system parameters because these parameters need to
be filled by the runtime-engine, but must not be available to the client:

Sample Code
DEFINE VIEW SalesOrder
AS SELECT FROM sepm_cds_sales_order AS so
ASSOCIATION [0..1] TO sepm_cds_business_partner AS _Customer
on $projection.BuyerGuid = _Customer.business_partner_key
{

key so.sales_order_id AS SalesOrderId,


@consumption.hidden; true
.................................
@Consumption.hidden: true
so.buyer_guid AS BuyerGuid,

_Customer.company_name AS CompanyName
} ....
Example 4

The annotation Consumption.defaultValue is used to specify default values for parameters. In this example, the
currency EUR is used:

Sample Code
DEFINE VIEW SalesOrder with parameters
@Consumption.defaultValue: 'EUR'
........................................... @consumption.defaultValue: 'EUR'
p_TargetCurrency : snwd_curr_code
AS SELECT FROM sepm_cds_sales_order AS so
{
key so.sales_order_key AS NodeKey,

$parameters.p_TargetCurrency AS CurrencyCode,

currency_conversion(
amount => so.gross_amount,
source_currency => so.currency_code,
target_currency => $parameters.p_TargetCurrency,
exchange_rate_date => CAST( '20150101' AS abap.dats )
) AS GrossAmount
}

Example 5

The annotation Consumption.valueHelp is used to expose an association as a value help. In this example, the CDS
view CurrencyCodeValueHelp is used for the field CurrencyCode:

Sample Code
DEFINE VIEW CurrencyCodeValueHelp
AS SELECT FROM currency_code
{
key CurrencyCode,
CurrencyName,
CurrencyDescription
}

DEFINE VIEW SalesOrder


AS SELECT FROM sepm_cds_sales_order AS so
ASSOCIATION [0..1] TO CurrencyCodeValueHelp AS _Currency
on $projection.BuyerGuid = _Customer.business_partner_key
{
so.sales_order_id AS SalesOrderId,
@consumption.valuehelp: 'Currency'
.............................................
@Consumption.valueHelp: '_Currency'
so.currency_code AS CurrencyCode,

so.gross_amount AS GrossAmount
}

Example 6

The association Consumption.semanticObject is used to assign semantic objects to CDS views or elements that can be
used in the UI for intent-based navigation.

Sample Code @consumption.semanticobject: ' BusinessPartner'


......................................
@Consumption.semanticObject: 'SalesOrder'
DEFINE VIEW SalesOrder
AS SELECT FROM sepm_cds_sales_order AS so
{
so.sales_order_id AS SalesOrderId,

@Consumption.semanticObject: 'BusinessPartner'
so.buyer_guid AS BuyerGuid,
}

Example 7

The annotation Consumption.filter is used to enable filters for values. In this example, product_hierarchy is filtered
for several single values of calendar_day, and for one single interval of product.

@consumption.filter: { selectionType: #single, multipleselections:false, mandatory:


Sample Code
@Analytics.query : true false }
DEFINE VIEW product_hierarchy
AS SELECT FROM sales
{
...
@Consumption.filter : { selectionType : #SINGLE, multipleSelections : true}
calendar_day, //several single values are allowed
@Consumption.filter : { selectionType : #INTERVAL, multipleSelections : false }
product, // single interval allowed
...
}

Example 8

The annotation Consumption.filter is used to enable filters for values. In this example, costcenter_reporting is
label value
filtered hierarchically for the constant CONTR_AREA_10 and for the parameter cost_center_hier_param.
type value
Sample Code
@Analytics.query : true filter in hierarchy CDS view
DEFINE VIEW costcenter_reporting
with parameters cost_center_hier_param : String selectiontype: #hierarchy_node
AS SELECT FROM costcenters
{ hierarchybindings:
...
@Consumption.filter : {
[ { type: #constant, value: 'Contr' },
selectionType : #HIERARCHY_NODE, { type: #parameter, value: ' ' } ]
multipleSelections : false,
hierarchyBinding :
[ { type : #CONSTANT, value : 'CONTR_AREA_10' },
{ type : #PARAMETER, value : 'cost_center_hier_param' } ]
}
costcenter, // hierarchy node filter

costs,
...
}

Example 9

This example shows how to specify hierarchy nodes as default value in the Consumption.filter annotation. A
consumption view should provide a prompt for a hierarchy node of a costcenter hierarchy with
default 1000/ALL (HierarchyNode).

Sample Code
@Consumption.filter{ selectionType: #HIERARCHY_NODE ;
defaultHierarchyNode: { nodeType : ‘HierarchyNode’ ;
node: [ { element: ‘ControllingArea’ ; value:
‘1000’ };
{ element: ‘HierarchyNode’ ; value: ‘
ALL’ } ] };
hierarchyBinding: [ … ] };
costCenter;

Example 10

This example shows how to enable the Consumption.derivation annotation to return hierarchy nodes. The
annotationConsumption.derivation.resultHierarchyNode is used to return hierarchy nodes. Given a
view CostcenterResponsible with fields field1, field2, field3, field4, and responsible. The query view should filter by the
costcenter nodes the given responsible (parameter) is responsible for.

Sample Code
@Consumption.filter: { selectionType: #HIERARCHY_NODE ;
hierarchyBinding: [ … ] };
@Consumption.derivation.resultHierarchyNode:
{ lookupEntity: ‘CostcenterResponsible’;
nodeTypeElement: ‘field1’;
mapping: [ { hierarchyElement : ‘ControllingArea’ ; lookupElement: ‘field2’ } ;
{ hierarchy Element: ‘CostCenter’ ; lookupElement: ‘field3’ };
{ hierarchyElement: ‘HierarchyNode’ ; lookupElement: ‘field4’ } ] };
@Consumption.hidden: true;
costCenter;

The hierarchy binding is derived from Consumption.filter.hierarchyBinding. Consumption.derivation can


only be used in combination withConsumption.filter. Futhermore Consumption.filter.selectionType:
#HIERARCHY_NODE has to be true.
DefaultAggregation Annotations

Examples
Example 1

Counters and exception aggregation

For CDS views representing master data reports (i.e. the FROM clause refers to a CDS view categoriezed as #DIMENSION), a
counter of the different dimension values can be defined by combining the annotation DefaultAggregation: #SUM with a
select list entry containing constant value 1:

Sample Code
counters for CDS view as Dimension
@EndUserText.label: 'CostCenters per ControllingArea'
controllingArea,
@Analytics.query: true @DefaultAggregation: #SUM
define view ControllingAreaView 1 as costCenterCount
as SELECT from CostCenterDimension {

controllingArea,

@DefaultAggregation: #SUM
................................
1 as costCenterCount // because of #SUM aggregation this will be mapped to measure 1ROWCOUNT g
...................................
enerated for InfoProvider

This way no exception aggregation is involved which leads to improved performance of the report.
DefaultAggregation Annotations

Examples
Example 1

Parent Child Hierarchy for Views with Associations: @analytics.dacategory: replicationEnabled

Sample Code
@Analytics : { dataCategory : #DIMENSION, replicationEnabled }
@Hierarchy.parentChild : [ { name : ‘Organisation’, recurseBy : ‘Manager’} ]
entity Employee {
key ID : String(8);
Manager : Association to this;
... @Hierarchy.parentchild: [ { name: 'organisation', recurseBy: 'Manager' } ]
};
Example 2 entity Employee { key ID: string(8), Manager: Association to this, , , }

Parent Child Hierarchy for Views without Associations:

Sample Code
@Analytics : { dataCategory : #DIMENSION, replicationEnabled }
@Hierarchy.parentChild : [ { name : ‘Organisation’,
recurse : { parent : [ ‘Manager’ ] ,
child : [ ‘ID’] }
} ]
entity Employee {
key ID : String(8);
Manager : String(8);
...
};
Example 3

Hierarchy Directory Association:

Sample Code
@Analytics : { dataCategory : #HIERARCHY }
@Hierarchy.parentChild : {
recurseBy : ‘ParentNode’,
directory: ‘CostCenterHierarchyDirectory’
}
entity CostCenterHierarchyNode {
key CostCenterHierarchyDirectory : Association to CostCenterHierarchyDirectory;
key HierarchyNode : CostCenterHierarchyNode;
ParentNode : Association to this;
...
};
@objectmodel.modelcategory: #business_object
ObjectModel Annotations @objectmodel.compositionroot: true
@objectmodel.association.type: #
Examples -Item
Example 1

This example demonstrates how you can define a compositional hierarchy.


BOPF annotations
Sample Code
@ObjectModel.modelCategory: #BUSINESS_OBJECT
@ObjectModel.compositionRoot: true
define view I_SalesOrder
association [0..*] to I_SalesOrderItem as _Item ... {
.................................................................
@ObjectModel.association.type: #TO_COMPOSITION_CHILD
_Item, ...
}

define view I_SalesOrderItem


association [1..1] to I_SalesOrder as _SalesOrder ... {
@ObjectModel.association.type: [#TO_COMPOSITION_ROOT,
#TO_COMPOSITION_PARENT]
_SalesOrder, ...
}

Example 2

This example demonstrates how you can define foreign key relationship.

Sample Code
define view I_SalesOrderItem
association [0..1] to I_Material as _Material
on $projection.Material = _Material.Material ... {
@ObjectModel.foreignKey.association: ’_Material’
Material,
@objectmodel.foreignkey.association: '_Material'
_Material, ...
}

@ObjectModel.representativeKey: ’Material’
define view I_Material ... { @objectmodel.representativekey: ' Material '
key Material, ...
}

Example 3

This example demonstrates how you can define language-dependent texts

Association to text table inside view


Sample Code
@objectmodel.text.association: '_Text'
define view I_Material
association [0..*] to I_MaterialText as _Text ... {
@ObjectModel.text.association: ’_Text’
key Material,
_Text, ...
}
outside annotation:
@ObjectModel.dataCategory: #TEXT @obectmodel.datacategory: #TEXT
@objectmodel.representativekey: 'Material'
@ObjectModel.representativeKey: ’Material’
define view I_MaterialText ... {
key Material,
@Semantics.language: true
key Language,
@Semantics.text: true
MaterialName,
@Semantics.text: true
MaterialDescription, ...
}

Example 4

This example demonstrates how you can define language-independent texts

Sample Code
define view I_Plant ... {
@ObjectModel.text.element: [’PlantName’]
key Plant,
@Semantics.text: true
PlantName, ...
}

Example 5
BOPF achieves its tranactional behavior through: below Annotations
This example demonstrates how you can define the transactional behavior BOPF = Transactional Behavior

Sample Code
@ObjectModel.compositionRoot: true
@ObjectModel.transactionalProcessingEnabled: true
@ObjectModel.writeDraftPersistence: ‘<DraftDDICTable>’
define view I_MaterialWithDraft ... {
...
}
@objectmodel.modelcategory: 'BusinessObject'
@objectmodel.compositionroot: true
@objectmodel.writedraftpersistence: 'DDICTable :ZOFT_smeal'
@objectmodel.transactionalprocessingenabled: true
Semantics Annotations

Examples

Example 1

The following CDS view fetches the contact data. Here, the annotations assign to the corresponding fields the relevant
semantic information, such as first name, last name, and so on.

Sample Code
DEFINE VIEW ContactPerson ...
ASSOCIATION [1..1] TO FormattedName AS _FormattedName ON ...
{
...
@Semantics.name.givenName
FirstName, @semantics.name.givenname (first name)
@semantics.name.additionalname (middle name)
@Semantics.name.additionalName
MiddleName, @semantics.name.familyname (last name)
@Semantics.name.familyName @semantics.user.id (systemUser)
LastName, @semantics.telephone.type: [#work, #Pref]
@Semantics.user.id @semantics.telphone.type: [#cell]
SystemUser,
@semantics.telphone.fax: [#fax]
Initials,

GenderCode,

AddressUUID,

@Semantics.telephone.type: [#WORK, #PREF]


PhoneNumber,

@Semantics.telephone.type: [#FAX]
FaxNumber,

@Semantics.telephone.type: [#CELL]
MobilePhoneNumber,

@Semantics.eMail.address
EmailAddress,

PreferredLanguage,

@Semantics.contact.birthDate
BirthDate, @semantics.contact.birthdate
@Semantics.name.fullName @semantics.name.fullname
_FormattedName.FormattedContactName,
...
}

Example 2
The following CDS view fetches sales order items. Here, the annotations assign the units and currencies to the corresponding
fields.

Sample Code @semantics.currencycode


DEFINE VIEW SalesOrderItem as select from ... Currency as CurrencyCode
{
,
... @semantics.amount.currencycode: 'CurrencyCode'
gross_amount as GrossAmount,
@Semantics.currencyCode
currency_code as CurrencyCode,

@Semantics.amount.currencyCode: 'CurrencyCode'
gross_amount as GrossAmount, @semantics.unitofmeasure
unit_of_measure as UnitOfMeasure,
@Semantics.unitOfMeasure
unit_of_measure as UnitOfMeasure,

@Semantics.quantity.unitOfMeasure: 'UnitOfMeasure'
quantity as Quantity,

... @semantics.quantity.unitofmeasure: 'UnitOfMeasure'


} quantity as quantity

Example 3

The following CDS view fetches geographic data of cities annotating the corresponding location fields according to a
standardized format:

Sample Code
DEFINE VIEW myGeoAttributeView as select from ...
{
@Semantics.address.city
cartoid, @semantics.address.city
@Semantics.geoLocation.longitude city_id
Longitude,
@semantics.geolocation.longitude
@Semantics.geoLocation.latitude longitude
latitude,
@semantics.geolocation.latitude
@Semantics.geoLocation.normalizedName
name latitude
} @semantics.geolocation.normaizedname
name
Example 4

The following CDS view fetches language-dependant data annotating the corresponding language fields and text fields:
............................
Sample Code
DEFINE VIEW chartOfAccountsTexts AS SELECT FROM ...
{
@semantics.language: true
key ktopl AS chartOfAccounts, @semantics.text: true
@Semantics.language: true
key spras AS language,

@Semantics.text: true
ktplt AS chartOfAccountsName
}
Example 1: @UI.headerInfo

In this example, the element @UI.headerInfo.typeNamePlural is used to define, what can be shown in the title of a table or list.

Sample Code @UI.headerInfo: { typenameplural: 'sales orders' }


...
@UI.headerInfo: { typeNamePlural: 'Sales Orders' }
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {
...
}

Example 2: @UI.lineItem elements in columns of the table: @UI.lineItem

The annotation @UI.lineItem is used to define what elements are shown in the table-columns.

Since the desired columns of a table depend on the use-case (an overview may require more fields than a value-help) several
list-layouts can be defined, distinguished by a qualifier. If the CDS view contains analytical annotations, for
example @DefaultAggregation, they are considered automatically. No additional UI annotations are required.

Sample Code
...
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {
@UI.lineItem: [ { position: 10 }, { qualifier: 'ValueList', position: 10 } ]
key so.sales_order_id as SalesOrder,

@UI.lineItem: [ { position: 20 }, { qualifier: 'ValueList', position: 20 } ]


so.customer.company_name as CompanyName,

@UI.lineItem: [ { position: 30 } ]
so.currency_code as CurrencyCode,

@DefaultAggregation: #SUM
@UI.lineItem: [ { position: 40 } ]
so.gross_amount as GrossAmount
}

Example 3: @UI.selectionField @UI.selectionField ---> Global Filter

The annotation @UI.selectionField is used to enable specific elements for selection, for example using a filter bar.

If the CDS view is annotated as @Search.searchable or if a value help is available for the element, this is considered. No
additional UI annotations are required to expose the search field or value help.

Sample Code
...
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {
key so.sales_order_id as SalesOrder,

@UI.selectionField: [ { position: 10 } ]
so.customer.company_name as CompanyName,
...
}
Example 4: @UI.identification @UI.Identification -- what elements are shown on detail page

The annotation @UI.Identification is used to define which elements are shown on a detail page.

Sample Code
...
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {
@UI.identification: [ { position: 10 } ]
key so.sales_order_id as SalesOrder,

@UI.identification: [ { position: 20 } ]
so.customer.company_name as CompanyName,

@UI.identification: [ { position: 30 } ]
so.currency_code as CurrencyCode,

@UI.identification: [ { position: 40 } ]
so.gross_amount as GrossAmount
}

Example 5: @UI.fieldGroup group several fields -- section header

The annotation @UI.fieldGroup is used to group several fields, for example, for sections of forms. Similar to the
annotation @UI.lineItem, the different field groups have unique qualifiers.

Sample Code
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {
@UI.identification: [ { qualifier: 'GeneralInformation', position: 10 } ]
key so.sales_order_id as SalesOrder,

@UI.identification: [ { qualifier: 'GeneralInformation', position: 20 } ]


so.customer.company_name as CompanyName,

@UI.identification: [ { qualifier: 'SalesData', position: 30 } ]


so.currency_code as CurrencyCode,

@UI.identification: [ { qualifier: 'SalesData', position: 40 } ]


so.gross_amount as GrossAmount
}

Example 6:@UI.badge

The annotation @UI.badge represents the view of a business card. A badge can be considered as the combination of the
annotations @UI.headerInfo and @UI.identification. The properties ImageUrl, TypeImageUrl, and Title correspond to the
properties from the annotation @UI.HeaderInfo. In addition to the Titleproperty, the
properties HeadLine, MainInfo and SecondaryInfo of the same format can be specified.

Sample Code @UI.badge


@UI.badge: {
title: { T H M S
label: 'Sales Order',
value: 'SalesOrderID' -- Reference to element in projection-list
},
headLine: {
label: 'Customer',
value: 'CompanyName' -- Reference to element in projection-list
},
mainInfo: {
label: 'Gross Amount',
value: 'GrossAmount' -- Reference to element in projection-list
},
secondaryInfo: {
label: 'Billing Status',
value: 'BillingStatus' -- Reference to element in projection-list
}
}

define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {


key so.sales_order_id as SalesOrder,
so.customer.company_name as CompanyName,
so.gross_amount as GrossAmount,
so.billing_status as BillingStatus,
...
}

Example 7: @UI.chart Q Title Descrip C.Type D M

The annotation @UI.chart is used to define the properties of a chart. The annotation is defined at view level and refers to the
elements that are supposed to be used in the chart. Additionally, a title and description can be provided.

Sample Code @UI.chart


...
@UI.chart: { qualifier: ' xxx'' ,
title: 'Gross Amount by Customer',
description: 'Line-chart displaying the gross amount by customer',
chartType: #LINE,
dimensions: [ 'CompanyName' ], -- Reference to one element
measures: [ 'GrossAmount' ] -- Reference to one or more elements
}

define view ZExample_SalesOrder as select from sepm_cds_sales_order as so {


key so.sales_order_id as SalesOrder,
so.customer.company_name as CompanyName,
so.currency_code as CurrencyCode,

@Semantics.amount.currencyCode: 'CurrencyCode'
so.gross_amount as GrossAmount,
...
}

Example 8: @UI.hidden

The annotation @UI.hidden prevents fields from being displayed, leaving them available for client.

This is sensible if the CDS has technical keys, for example Guids, that have to be exposed to the OData service to work, but
are usually not supposed to be displayed on the UI. Another use case are fields that are required in other calculations.

In the following example, a data point with precalculated criticality and trend is exposed. These fields are required in the client
to calculate the corresponding values, but are not supposed to be displayed directly.

Sample Code
...
define view ZExample_SalesOrdersByCustomer as select from ... as so {
@UI.hidden
key so.buyer_guid as BuyerGuid,
...
@UI.dataPoint: {
criticality: 'AmountCriticality', -- Reference to element
trend: 'AmountTrend', -- Reference to element
}

so.actual_amount as ActualAmount,

@UI.hidden
so.criticality as AmountCriticality,

@UI.hidden
so.trend as AmountTrend
}

Example 9: @UI.masked

The annotation @UI.masked marks a field that may contain sensitive data and should therefore not be displayed in clear text
by the client.

This annotation does not influence how data is transferred. If a field is marked as @UI.masked, dataof this field is still
transferred to the client like any other property.

Sample Code
...
define view Destination as select from ... {
@UI.identification: [ { position: 10 } ]
key DestinationID,
...
@UI.identification: [ { position: 20 } ]
AuthType, -- None, Basic, SSO, ...

@UI.identification: [ { position: 30 } ]
BasicAuthUserName,

@UI.identification: [ { position: 40 } ]

@UI.masked
BasicAuthPassword,
...
}

Example 10:@UI.multiLineText

The annotation @UI.multiLineText marks a field, for example a description, that is supposed to be displayed by controls that
support multiline-input, for example a text area.

@UI.multiLineText
Sample Code
...
define view Product as select from ... {
@UI.identification: [ { position: 10 } ]
key ProductID,

@UI.identification: [ { position: 20 } ]
ProductName,
@UI.identification: [ { position: 30 } ]

@UI.multiLineText: true
Description,
...
}

Example 11: @UI.dataPoint


defines a single point of data, typically a number that can be enriched with
business-relevant data.
The annotation @UI.dataPoint defines a single point of data, typically a number, that can be enriched with business-relevant
data, for example if a high or low value is desired, or if the value is increasing to decreasing.

The simplest variant of a data point consists of a value and a tile. In this case, only the value itself is exposed, without
additional information. Eg: USD to INR is high or low from last year
Is the value increasing or decreasing over time
Sample Code
...
define view ZExample_SalesOrdersByCustomer as select from ... as so {
key so.buyer_guid as BuyerGuid,

@Semantics.currencyCode: true
so.currency_code as CurrencyCode,

@UI.dataPoint: { title: 'Gross Amount' }

@Semantics.amount.currencyCode: 'CurrencyCode'
so.actual_amount as ActualAmount

}
VDM Annotations

Examples
Example 1

Defining a public basic VDM interface view:

Sample Code
@VDM.viewType: #BASIC
define view I_SalesOrder ... {
key SalesOrder,
...
}
Example 2

Defining a private composite VDM interface view:

Sample Code
@VDM.private: true
@VDM.viewType: #COMPOSITE
define view P_SalesOrderItemCube ... {
key SalesOrder,
...
}

You might also like