Professional Documents
Culture Documents
Field Group:-Qualifier Section Heading
Field Group:-Qualifier Section Heading
Field Group:-Qualifier Section Heading
{
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
Sample Code
@EndUserText.label: 'EPM Demo: Sales Order Item with Addtl. Data (private view)'
@Analytics.dataCategory: #CUBE
@AccessControl.authorizationCheck: #CHECK
@AbapCatalog.sqlViewName: 'SEPM_PSOIC'
{
@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,
1 as relative_margin,
Example 2
Sample Code
@Analytics.query : true
with parameters
cost_center_hier_param : String
...
@AnalyticsDetails.query : {
displayHierarchy: #ON,
hierarchyBinding :
}
costcenter, // hierarchy node filter
costs,
...
}
Example 3
The system supports variables like $session.system_date for different use cases:
in cube parameters
Sample Code
@Analytics.query : true
define view …
Sample Code
} where
Sample Code
_CostCenter[1: DateTo >= $session.system_date and DateFrom <= $session.system_date]._Text[1: Langu
age = $parameters.P_Language].Text as CostCenterText,
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,
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
{
_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
}
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.
@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.
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;
Examples
Example 1
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
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, , , }
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
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
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
Example 4
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: [#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.
@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,
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.
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: 30 } ]
so.currency_code as CurrencyCode,
@DefaultAggregation: #SUM
@UI.lineItem: [ { position: 40 } ]
so.gross_amount as GrossAmount
}
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
}
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,
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.
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.
@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,
...
}
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,
@Semantics.amount.currencyCode: 'CurrencyCode'
so.actual_amount as ActualAmount
}
VDM Annotations
Examples
Example 1
Sample Code
@VDM.viewType: #BASIC
define view I_SalesOrder ... {
key SalesOrder,
...
}
Example 2
Sample Code
@VDM.private: true
@VDM.viewType: #COMPOSITE
define view P_SalesOrderItemCube ... {
key SalesOrder,
...
}